fix larger than memory error

This commit is contained in:
Aitor Morales-Gregorio 2025-09-26 08:58:03 +02:00
parent 895ba73144
commit eae8e29f47
3 changed files with 17 additions and 13 deletions

View file

@ -3,11 +3,11 @@ import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patheffects as PathEffects
N_processes = 5
N_threads = 5
N_processes = 16
N_threads = 16
# Load measured timings
times = np.empty((N_processes, N_threads))
times = np.ones((N_processes, N_threads))
for fname in os.listdir('timings'):
values = open(f'timings/{fname}').read().split()
n_processes = int(values[0])
@ -25,6 +25,7 @@ fig_time.colorbar(im, ax=axs_time, label='Measured computation time (s)')
""" Plot speedup """
workers = np.arange(N_processes + 1)[:, None] * np.arange(N_threads + 1)
speedup = times[0, 0] / times
speedup[times == 0] = np.nan
fig_speedup, axs_speedup = plt.subplots()
im = axs_speedup.imshow(speedup.T, origin='lower')
@ -36,13 +37,13 @@ for axs, data in zip([axs_time, axs_speedup], [times, speedup]):
axs.set_xlabel('# processes')
axs.set_ylabel('# threads')
axs.set_xticks(np.arange(N_processes))
axs.set_xticklabels(np.arange(N_processes)+1)
axs.set_xticklabels(np.arange(N_processes)+1, fontsize=6)
axs.set_yticks(np.arange(N_threads))
axs.set_yticklabels(np.arange(N_threads)+1)
axs.set_yticklabels(np.arange(N_threads)+1, fontsize=6)
for i in range(N_processes):
for j in range(N_threads):
txt = axs.text(i, j, f'{data[i, j]:.2f}', fontsize=10, color='w',
txt = axs.text(i, j, f'{data[i, j]:.2f}', fontsize=4, color='w',
ha='center', va='center', fontweight='bold')
txt.set_path_effects([PathEffects.withStroke(linewidth=0.5, foreground='k')])
axs.spines[['right', 'top']].set_visible(False)