6060max_int32 = np .iinfo (np .int32 ).max
6161
6262# parse command line arguments
63- parser = argparse .ArgumentParser (description = ' Run a Benchmark with NEST' )
64- parser .add_argument (' --noRunSim' , action = "store_false" , help = ' Skip running simulations, only do plotting' )
65- parser .add_argument (' --enable_profiling' , action = "store_true" , help = "Run the benchmark with profiling enabled with AMDuProf" )
63+ parser = argparse .ArgumentParser (description = " Run a Benchmark with NEST" )
64+ parser .add_argument (" --noRunSim" , action = "store_false" , help = " Skip running simulations, only do plotting" )
65+ parser .add_argument (" --enable_profiling" , action = "store_true" , help = "Run the benchmark with profiling enabled with AMDuProf" )
6666parser .add_argument ("--short_sim" , action = "store_true" , help = "Run benchmark with profiling on 2 nodes with 2 iterations" )
6767parser .add_argument ("--enable_mpi" , action = "store_true" , default = False , help = "Run benchmark with MPI (default: thread-based benchmarking)" )
6868
129129
130130# output folder
131131if args .enable_mpi :
132- output_folder = os .path .join (os .path .dirname (__file__ ), os .pardir , ' Output_MPI' )
132+ output_folder = os .path .join (os .path .dirname (__file__ ), os .pardir , " Output_MPI" )
133133else :
134- output_folder = os .path .join (os .path .dirname (__file__ ), os .pardir , ' Output_threads' )
134+ output_folder = os .path .join (os .path .dirname (__file__ ), os .pardir , " Output_threads" )
135135
136136
137137def log (message ):
@@ -169,7 +169,7 @@ def start_strong_scaling_benchmark_threads(iteration):
169169 for combination in combinations :
170170 rng_seed = rng .integers (0 , max_int32 )
171171
172- command = [' bash' , '-c' , f'source { PATHTOSTARTFILE } && python3 { PATHTOFILE } --simulated_neuron { combination ["neuronmodel" ]} --network_scale { MPI_STRONG_SCALE_NEURONS } --threads { combination ["n_threads" ]} --iteration { iteration } --rng_seed { rng_seed } --benchmarkPath { dirname } ' ]
172+ command = [" bash" , "-c" , f'source { PATHTOSTARTFILE } && python3 { PATHTOFILE } --simulated_neuron { combination ["neuronmodel" ]} --network_scale { MPI_STRONG_SCALE_NEURONS } --threads { combination ["n_threads" ]} --iteration { iteration } --rng_seed { rng_seed } --benchmarkPath { dirname } ' ]
173173
174174 log (combination ["name" ])
175175
@@ -188,7 +188,7 @@ def start_strong_scaling_benchmark_threads(iteration):
188188 f .write (result .stderr )
189189
190190 if result .returncode != 0 :
191- log (f"\033 [91m{ combination [' name' ]} failed\033 [0m" )
191+ log (f"\033 [91m{ combination [" name" ]} failed\033 [0m" )
192192 log (f"\033 [91m{ result .stderr } failed\033 [0m" )
193193
194194def start_strong_scaling_benchmark_mpi (iteration ):
@@ -231,7 +231,7 @@ def start_weak_scaling_benchmark_threads(iteration):
231231 for combination in combinations :
232232 rng_seed = rng .integers (0 , max_int32 )
233233
234- command = [' bash' , '-c' , f'source { PATHTOSTARTFILE } && python3 { PATHTOFILE } --simulated_neuron { combination ["neuronmodel" ]} --network_scale { NETWORK_BASE_SCALE * combination ["n_threads" ]} --threads { combination ["n_threads" ]} --rng_seed { rng_seed } --iteration { iteration } --benchmarkPath { dirname } ' ]
234+ command = [" bash" , "-c" , f'source { PATHTOSTARTFILE } && python3 { PATHTOFILE } --simulated_neuron { combination ["neuronmodel" ]} --network_scale { NETWORK_BASE_SCALE * combination ["n_threads" ]} --threads { combination ["n_threads" ]} --rng_seed { rng_seed } --iteration { iteration } --benchmarkPath { dirname } ' ]
235235
236236 combined = combination ["neuronmodel" ]+ "," + str (combination ["networksize" ])
237237 log (f"\033 [93m{ combined } \033 [0m" if DEBUG else combined )
@@ -248,7 +248,7 @@ def start_weak_scaling_benchmark_threads(iteration):
248248 f .write (result .stderr )
249249
250250 if result .returncode != 0 :
251- log (f"\033 [91m{ combination [' neuronmodel' ]} failed\033 [0m" )
251+ log (f"\033 [91m{ combination [" neuronmodel" ]} failed\033 [0m" )
252252 log (f"\033 [91m{ result .stderr } failed\033 [0m" )
253253
254254def start_weak_scaling_benchmark_mpi (iteration ):
@@ -321,15 +321,15 @@ def _plot_scaling_data(ax, sim_data: dict, file_prefix: str, abs_or_rel: str):
321321 x = sorted (values .keys (), key = lambda k : int (k ))
322322 # Real Time Factor
323323 reference_y = np .array ([np .mean (
324- [iteration_data [' max_time_simulate' ] / (iteration_data ["biological_time" ] / 1000 ) for iteration_data in
324+ [iteration_data [" max_time_simulate" ] / (iteration_data ["biological_time" ] / 1000 ) for iteration_data in
325325 referenceValues [nodes ].values ()]) for nodes in x ])
326326 y = np .array ([np .mean (
327- [iteration_data [' max_time_simulate' ] / (iteration_data ["biological_time" ] / 1000 ) for iteration_data in
327+ [iteration_data [" max_time_simulate" ] / (iteration_data ["biological_time" ] / 1000 ) for iteration_data in
328328 values [nodes ].values ()]) for nodes in x ])
329329 y_factor = y / reference_y # Calculate the factor of y in comparison to the reference value
330330
331331 y_std = np .array ([np .std (
332- [iteration_data [' max_time_simulate' ] / (iteration_data ["biological_time" ] / 1000 ) for iteration_data in
332+ [iteration_data [" max_time_simulate" ] / (iteration_data ["biological_time" ] / 1000 ) for iteration_data in
333333 values [nodes ].values ()]) for nodes in x ])
334334 y_factor_std = y_std / reference_y # Calculate the standard deviation of the factor
335335
@@ -343,7 +343,7 @@ def _plot_scaling_data(ax, sim_data: dict, file_prefix: str, abs_or_rel: str):
343343 _y_std = y_std / 60
344344 _y = y / 60
345345
346- ax .errorbar (x , _y , yerr = _y_std , label = legend [neuron ], color = palette (colors [neuron ]), linestyle = '-' ,marker = 'o' , markersize = 4 , ecolor = ' gray' , capsize = 2 , linewidth = 2 )
346+ ax .errorbar (x , _y , yerr = _y_std , label = legend [neuron ], color = palette (colors [neuron ]), linestyle = "-" ,marker = "o" , markersize = 4 , ecolor = " gray" , capsize = 2 , linewidth = 2 )
347347
348348 min_y = min (min_y , np .amin (_y ))
349349 max_y = max (max_y , np .amax (_y ))
@@ -372,18 +372,18 @@ def plot_scaling_data(sim_data_weak: dict, sim_data_strong: dict, file_prefix: s
372372 max_y = max (_max_y , max_y )
373373
374374 if abs_or_rel == "abs" :
375- ax [i , 0 ].set_ylabel (' Wall clock time [min]' )
376- ax [i , 0 ].set_yscale (' log' )
375+ ax [i , 0 ].set_ylabel (" Wall clock time [min]" )
376+ ax [i , 0 ].set_yscale (" log" )
377377 else :
378- ax [i , 0 ].set_ylabel (' Wall clock time (ratio)' )
378+ ax [i , 0 ].set_ylabel (" Wall clock time (ratio)" )
379379 ax [i , 1 ].set_yticklabels ([]) # hide y tick labels from bottom right plot, ticks/labels are same as for bottom left
380380
381381 # column labels
382382 ax [0 , 0 ].text (0.5 , 1.1 , "Strong scaling" , transform = ax [0 , 0 ].transAxes , ha = "center" , fontsize = 16 )
383383 ax [0 , 1 ].text (0.5 , 1.1 , "Weak scaling" , transform = ax [0 , 1 ].transAxes , ha = "center" , fontsize = 16 )
384384
385385 for _ax in ax .flatten ():
386- _ax .set_xscale (' log' )
386+ _ax .set_xscale (" log" )
387387 _ax .xaxis .set_minor_locator (matplotlib .ticker .NullLocator ())
388388
389389 ax [0 , 0 ].legend ()
@@ -396,14 +396,14 @@ def plot_scaling_data(sim_data_weak: dict, sim_data_strong: dict, file_prefix: s
396396
397397 if args .enable_mpi :
398398 for _ax in ax [1 , :]:
399- _ax .set_xlabel (' Number of nodes' )
399+ _ax .set_xlabel (" Number of nodes" )
400400
401401 for _ax in ax .flatten ():
402402 _ax .set_xlim (MPI_SCALES [0 ], MPI_SCALES [- 1 ])
403403 _ax .set_xticks (MPI_SCALES , MPI_SCALES )
404404 else :
405405 for _ax in ax [1 , :]:
406- _ax .set_xlabel (' Number of threads' )
406+ _ax .set_xlabel (" Number of threads" )
407407
408408 for _ax in ax .flatten ():
409409 _ax .set_xlim (N_THREADS [0 ], N_THREADS [- 1 ])
@@ -419,10 +419,10 @@ def plot_scaling_data(sim_data_weak: dict, sim_data_strong: dict, file_prefix: s
419419
420420
421421 for _ax in ax .flatten ():
422- _ax .spines [' top' ].set_visible (False )
423- _ax .spines [' right' ].set_visible (False )
424- _ax .spines [' left' ].set_visible (False )
425- _ax .spines [' bottom' ].set_visible (False )
422+ _ax .spines [" top" ].set_visible (False )
423+ _ax .spines [" right" ].set_visible (False )
424+ _ax .spines [" left" ].set_visible (False )
425+ _ax .spines [" bottom" ].set_visible (False )
426426
427427 for _ax in ax [0 , :]:
428428 _ax .set_xticklabels ([]) # hide x tick labels for number of threads/processes from top two panels
@@ -483,15 +483,15 @@ def plot_memory_scaling_benchmark(sim_data: dict, file_prefix: str):
483483 _y = rss
484484 _y_std = rss_std
485485
486- _ax .errorbar (x , _y , yerr = _y_std , color = palette (colors [neuron ]), linestyle = linestyles ["rss" ], label = legend [neuron ], ecolor = ' gray' , capsize = 2 , linewidth = 2 , marker = 'o' , markersize = 4 )
486+ _ax .errorbar (x , _y , yerr = _y_std , color = palette (colors [neuron ]), linestyle = linestyles ["rss" ], label = legend [neuron ], ecolor = " gray" , capsize = 2 , linewidth = 2 , marker = "o" , markersize = 4 )
487487 print ("mem for neuron " + neuron + " = " + str (_y ) + ", std dev = " + str (_y_std ))
488488
489489 if abs_or_rel == "abs" :
490- _ax .set_yscale (' log' )
490+ _ax .set_yscale (" log" )
491491
492- ax [0 ].legend (loc = ' upper left' )
493- ax [0 ].set_ylabel (' Memory [GiB]' )
494- ax [1 ].set_ylabel (' Memory (ratio)' )
492+ ax [0 ].legend (loc = " upper left" )
493+ ax [0 ].set_ylabel (" Memory [GiB]" )
494+ ax [1 ].set_ylabel (" Memory (ratio)" )
495495 # Create a legend for the neurons
496496 # neuron_handles = [plt.Line2D([0], [0], color=palette(colors[key]), lw=2) for key in legend.keys()]
497497 for _ax in [ax [1 ]]:
@@ -501,27 +501,27 @@ def plot_memory_scaling_benchmark(sim_data: dict, file_prefix: str):
501501 _ax .yaxis .set_major_formatter (formatter )
502502
503503 for _ax in ax :
504- _ax .set_xscale (' log' )
504+ _ax .set_xscale (" log" )
505505 _ax .xaxis .set_minor_locator (matplotlib .ticker .NullLocator ())
506506
507- _ax .spines [' top' ].set_visible (False )
508- _ax .spines [' right' ].set_visible (False )
509- _ax .spines [' left' ].set_visible (False )
510- _ax .spines [' bottom' ].set_visible (False )
507+ _ax .spines [" top" ].set_visible (False )
508+ _ax .spines [" right" ].set_visible (False )
509+ _ax .spines [" left" ].set_visible (False )
510+ _ax .spines [" bottom" ].set_visible (False )
511511
512512 if args .enable_mpi :
513- _ax .set_xlabel (' Number of nodes' )
513+ _ax .set_xlabel (" Number of nodes" )
514514 _ax .set_xticks (MPI_SCALES , MPI_SCALES )
515515 _ax .set_xlim (MPI_SCALES [0 ], MPI_SCALES [- 1 ])
516516 else :
517- _ax .set_xlabel (' Number of threads' )
517+ _ax .set_xlabel (" Number of threads" )
518518 _ax .set_xticks (N_THREADS , N_THREADS )
519519 _ax .set_xlim (N_THREADS [0 ], N_THREADS [- 1 ])
520520
521521 fig .subplots_adjust (left = 0.2 , right = .9 , bottom = 0.15 , top = 0.9 )
522522
523- fig .savefig (os .path .join (output_folder , file_prefix + ' _memory.png' ))
524- fig .savefig (os .path .join (output_folder , file_prefix + ' _memory.pdf' ))
523+ fig .savefig (os .path .join (output_folder , file_prefix + " _memory.png" ))
524+ fig .savefig (os .path .join (output_folder , file_prefix + " _memory.pdf" ))
525525
526526
527527def process_data (dir_name : str , mode = "MPI" ):
@@ -636,7 +636,7 @@ def read_isis_from_files(neuron_models):
636636
637637 print ("Reading ISIs from: " + os .path .join (output_folder , filename ))
638638
639- with open (os .path .join (output_folder , filename ), 'r' ) as file :
639+ with open (os .path .join (output_folder , filename ), "r" ) as file :
640640 isis = [float (line .strip ()) for line in file ]
641641 if iteration >= len (data [neuron_model ]["isis" ]):
642642 data [neuron_model ]["isis" ].append ([])
@@ -732,21 +732,21 @@ def plot_isi_distributions(neuron_models, data):
732732 plt .bar (data ["bin_centers" ], 100 * 2 * data [neuron_model ]["counts_std" ], data ["bin_centers" ][1 ] - data ["bin_centers" ][0 ], bottom = 100 * (data [neuron_model ]["counts_mean" ] - data [neuron_model ]["counts_std" ]), alpha = .5 , color = palette (colors [neuron_model ]))
733733 plt .step (data ["bin_edges" ][:- 1 ], 100 * data [neuron_model ]["counts_mean" ], label = legend [neuron_model ], linewidth = 2 , alpha = .5 , where = "post" , color = palette (colors [neuron_model ]))
734734
735- plt .xlabel (' ISI [ms]' )
736- plt .ylabel (' Frequency of occurrence [%]' )
735+ plt .xlabel (" ISI [ms]" )
736+ plt .ylabel (" Frequency of occurrence [%]" )
737737 plt .grid (True )
738738 plt .subplots_adjust (left = 0.2 , right = .9 , bottom = 0.15 , top = 0.9 )
739739 plt .legend ()
740740
741741 plt .xlim (0 , 160 ) # XXX hard-coded...
742742
743- plt .gca ().spines [' top' ].set_visible (False )
744- plt .gca ().spines [' right' ].set_visible (False )
745- plt .gca ().spines [' left' ].set_visible (False )
746- plt .gca ().spines [' bottom' ].set_visible (False )
743+ plt .gca ().spines [" top" ].set_visible (False )
744+ plt .gca ().spines [" right" ].set_visible (False )
745+ plt .gca ().spines [" left" ].set_visible (False )
746+ plt .gca ().spines [" bottom" ].set_visible (False )
747747
748- plt .savefig (os .path .join (output_folder , ' isi_distributions.png' ))
749- plt .savefig (os .path .join (output_folder , ' isi_distributions.pdf' ))
748+ plt .savefig (os .path .join (output_folder , " isi_distributions.png" ))
749+ plt .savefig (os .path .join (output_folder , " isi_distributions.pdf" ))
750750
751751
752752if __name__ == "__main__" :
0 commit comments