Commit 65a76e3b authored by Maxime Rey's avatar Maxime Rey
Browse files

New function: 'strongscaling', checks how a simulation gets more efficient...

New function: 'strongscaling', checks how a simulation gets more efficient with an increasing number of cpus.
parent ce804c70
......@@ -43,6 +43,7 @@ Utils to compute and plot several useful quantities:
- Utils
- plot_dexter, plot_data
- runtime, plot_runtime,
- strongscaling
- axis_format_10pow.
The use of all these functions is shown in plots.ipynb.
......@@ -3856,7 +3857,6 @@ def plot_runtime(genpath, folders, labels, logstr='logs', fmt='h', xlims=None, y
ax.plot(gyr_output, output_times/24, color=colors[ind_f], label=labels[ind_f])
ax.scatter(gyr_restart, restart_times/24, color=colors[ind_f], marker='+', s=150)
ax.set_xlabel('Time [Gyrs]')
......@@ -3886,8 +3886,41 @@ def plot_runtime(genpath, folders, labels, logstr='logs', fmt='h', xlims=None, y
def strongscaling(path2file, ncpus=[128,256,384,448], mincoarse=100):
Estimates how the simulation time improves with more cpu by comparing how long the coarse timesteps take (important thing: the coarse timesteps are equivalent in the simulation)
You should name the files filename128, filename256, filename384, etc.. In that example, use path2file='filename' and ncpus=[128,256,384].
mincoarse is used to avoid the first coarse steps when averaging as they are shorter.
import matplotlib.pyplot as plt
import numpy as np
coarsetime = []
for ncpu in ncpus:
file_name = path2file+str(ncpu)+'/logs'
temp_tcoarse, coarsenb = [], []
with open(file_name, 'r') as read_obj:
for line in read_obj:
if 'Main' in line:
coarsenb.append(int(line[line.find(' '):line.rfind('mcons')]))
if 'Time elapsed since last coarse step' in line:
temp_tcoarse.append(float(line[line.find(':')+1:line.rfind('s ')]))
coarsenb = np.array(coarsenb)
temp_tcoarse = np.array(temp_tcoarse)
if ncpu==min(ncpus):
ncpus = np.array(ncpus)
coarsetime = np.array(coarsetime)
speedup = coarsetime[np.where(ncpus==min(ncpus))] / coarsetime # speedup = t_min / t_coarse
plt.plot(ncpus/min(ncpus), speedup, marker='x', label='$t_{coarse,min} / t_{coarse}$')
yisx = np.linspace(1,max(ncpus)/min(ncpus),3)
plt.plot(yisx, yisx, c='k')
plt.xlabel('$n_{cpu} / min(n_{cpu})$')
def axis_format_10pow(value, tick_number, int_only=True): # The one that supposedly works. Have to check though.
# Make it s.t. one can choose between nothing and 3.6 (dec or only int)
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