Commit aadd8dcf authored by sfritschi's avatar sfritschi
Browse files

Added strong scaling analysis

parent d48199e0
import sys
sys.path.append('../')
import matplotlib.pyplot as plt
from netflow import *
from time import perf_counter
def main():
if len(sys.argv) != 4:
raise AssertionError("Usage: python3 generate.py <n1> <n2> <n3>")
basenet = netflow.load_network_from('../netflow/network/network.h5')
print("Network statistics:")
print("Throats: %d" % len(basenet.throats))
pore_throat_counts = [len(pore.throats) for pore in basenet.pores]
print("Max. number of throats per pore: %d" % max(pore_throat_counts))
print("Min. number of throats per pore: %d" % min(pore_throat_counts))
print("Avg. number of throats per pore: %f" % (sum(pore_throat_counts) / len(pore_throat_counts)))
target = [int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3])]
print("Target size: {}".format(target))
cutoff = 0.5 * max([basenet.ub[i] - basenet.lb[i] \
for i in range(len(basenet.ub))])
i = 0
max_ = 5
speedups = []
threads = []
times = []
while (i <= max_):
nthreads = 1 << i
print(nthreads)
start = perf_counter()
dendro = netflow.generate_dendrogram(basenet=basenet, targetsize=target, \
cutoff=cutoff, sd=42, nthreads=nthreads, mute=True)
end = perf_counter()
elapsed = end - start
print("Generated network statistics:")
print("Throats: %d" % len(dendro.throats))
print("Pores: %d" % len(dendro.pores))
threads.append(nthreads)
times.append(elapsed)
speedups.append(times[0] / times[i])
i += 1
plt.figure()
plt.title(r"Strong Scaling for targetsize {}".format(target))
plt.xlabel(r"#processes")
plt.ylabel(r"Speedup")
plt.plot(threads, speedups, '--bo')
plt.savefig('plots/strong_scaling.png')
if __name__ == '__main__':
main()
#!/bin/bash
bsub -n 48 -W 00:30 -R fullnode python3 perf.py 4 4 4
...@@ -226,9 +226,6 @@ class CellList: ...@@ -226,9 +226,6 @@ class CellList:
n = len(pores) n = len(pores)
for poreIdx in pores: for poreIdx in pores:
if tid == 0:
print(f"progress {((poreIdx+1) / n)*100.:.1f}%", end="\r", flush=True)
candidates = self.find_candidates(poreIdx) candidates = self.find_candidates(poreIdx)
...@@ -237,7 +234,7 @@ class CellList: ...@@ -237,7 +234,7 @@ class CellList:
lt = self.throatL[throatIdx] lt = self.throatL[throatIdx]
# Find best match among candidates # Find best match among candidates
matchIdx, matchLen = min(candidates.items(), key=lambda il: abs(il[1] - lt)) matchIdx, _ = min(candidates.items(), key=lambda il: abs(il[1] - lt))
# Remove match from candidates # Remove match from candidates
del candidates[matchIdx] del candidates[matchIdx]
# Put best match index in poreThroatTable # Put best match index in poreThroatTable
...@@ -995,6 +992,8 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \ ...@@ -995,6 +992,8 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
# Free memory associated with cellList (not needed anymore) # Free memory associated with cellList (not needed anymore)
del cellList del cellList
# DEBUG
"""
percent = k / (k + len(throats)) * 100. percent = k / (k + len(throats)) * 100.
print("\b"*24 + "{0:d} throats in total, {1:d} unrealised ({2:.1f}%)".\ print("\b"*24 + "{0:d} throats in total, {1:d} unrealised ({2:.1f}%)".\
format(len(throats), k, percent)) format(len(throats), k, percent))
...@@ -1002,7 +1001,7 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \ ...@@ -1002,7 +1001,7 @@ def generate_dendrogram(basenet: Network, targetsize: List[int], \
print("Avg. throat length difference: %e" % avg_throat_diff) print("Avg. throat length difference: %e" % avg_throat_diff)
print("Relative to Lmax: %.1f%%" % (avg_throat_diff / basenet.Lmax * 100.)) print("Relative to Lmax: %.1f%%" % (avg_throat_diff / basenet.Lmax * 100.))
print("Percentage where match was fully-connected: %.1f%%" % (n_already_taken / total * 100.)) print("Percentage where match was fully-connected: %.1f%%" % (n_already_taken / total * 100.))
"""
# assemble and return network # assemble and return network
network = Network(lb=[0.0 for k in range(d)], network = Network(lb=[0.0 for k in range(d)],
ub=L, Lmax=basenet.Lmax, label='from_' + basenet.label) ub=L, Lmax=basenet.Lmax, label='from_' + basenet.label)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment