Skip to content

Commit

Permalink
ci: run black on plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
ogiorgis committed Jan 30, 2024
1 parent 7fcd03f commit f444e2c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from runpy import run_path

import numpy as np
Expand All @@ -7,24 +6,24 @@

array = np.array

d = run_path('Results_bench/bench.py')
d = run_path("Results_bench/bench.py")

nb_procs = d['nb_procs']
times_fft = d['times_fft']
times_ifft = d['times_ifft']
nb_procs = d["nb_procs"]
times_fft = d["times_fft"]
times_ifft = d["times_ifft"]

fig = plt.figure()
ax = plt.gca()

for cls, nb_proc in nb_procs.items():
ax.plot(nb_proc, times_fft[cls], 'bo--')
ax.plot(nb_proc, times_ifft[cls], 'ro--')
ax.plot(nb_proc, times_fft[cls], "bo--")
ax.plot(nb_proc, times_ifft[cls], "ro--")

ax.set_xlabel('number of processes')
ax.set_ylabel('time (s)')
ax.set_xlabel("number of processes")
ax.set_ylabel("time (s)")

ind_base = 0
cls_base = 'FFT2DMPIWithFFTW1D'
cls_base = "FFT2DMPIWithFFTW1D"

nb_proc_base = nb_procs[cls_base][ind_base]

Expand All @@ -34,14 +33,14 @@

for cls, nb_proc in nb_procs.items():

speedup_fft = times_fft[cls_base][ind_base]/times_fft[cls]
speedup_ifft = times_ifft[cls_base][ind_base]/times_ifft[cls]
speedup_fft = times_fft[cls_base][ind_base] / times_fft[cls]
speedup_ifft = times_ifft[cls_base][ind_base] / times_ifft[cls]

ax.plot(nb_proc, nb_proc_base*speedup_fft/nb_proc, 'bo--')
ax.plot(nb_proc, nb_proc_base*speedup_ifft/nb_proc, 'ro--')
ax.plot(nb_proc, nb_proc_base * speedup_fft / nb_proc, "bo--")
ax.plot(nb_proc, nb_proc_base * speedup_ifft / nb_proc, "ro--")

ax.set_xlabel('number of processes')
ax.set_ylabel('speedup divided by the number of processes')
ax.set_xlabel("number of processes")
ax.set_ylabel("speedup divided by the number of processes")


plt.show()
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

import os

import subprocess32 as subprocess

import numpy as np

output_dir = 'Results_bench'
output_dir = "Results_bench"


def call_bash(commands):
Expand All @@ -25,39 +24,43 @@ def call_bash(commands):

for i, nb_proc in enumerate(nb_procs_all):

command = './test_bench.out --N0={} --N1={}'.format(N0, N1)
command = "./test_bench.out --N0={} --N1={}".format(N0, N1)

if nb_proc != 1:
command = 'mpirun -np {} '.format(nb_proc) + command
command = "mpirun -np {} ".format(nb_proc) + command

txt = call_bash(command)

blocks = txt.split('--------')
blocks = txt.split("--------")
# print('\n'.join(lines))

for block in blocks:
if 'Initialization' in block:
if "Initialization" in block:
lines = block.splitlines()
for line in lines:
if line.startswith('Initialization ('):
cls = line.split('(')[1].split(')')[0]
if line.startswith("Initialization ("):
cls = line.split("(")[1].split(")")[0]
if cls not in classes:
classes.append(cls)
nb_procs[cls] = []
times_fft[cls] = []
times_ifft[cls] = []

for line in lines:
if line.startswith('nb_proc:'):
if line.startswith("nb_proc:"):
nb_procs[cls].append(int(line.split()[1]))
if line.startswith('time fft'):
if line.startswith("time fft"):
times_fft[cls].append(float(line.split()[3]))
if line.startswith('time ifft'):
if line.startswith("time ifft"):
times_ifft[cls].append(float(line.split()[3]))

print('class ' + cls +
': times fft and ifft: {:5.3f} ; {:5.3f}'.format(
times_fft[cls][-1], times_ifft[cls][-1]))
print(
"class "
+ cls
+ ": times fft and ifft: {:5.3f} ; {:5.3f}".format(
times_fft[cls][-1], times_ifft[cls][-1]
)
)

src = """
from numpy import array
Expand All @@ -69,12 +72,22 @@ def call_bash(commands):

for cls in classes:
src += (
"\nnb_procs['" + cls + "'] = " + repr(np.array(nb_procs[cls])) +
"\ntimes_fft['" + cls + "'] = " + repr(np.array(times_fft[cls])) +
"\ntimes_ifft['" + cls + "'] = " + repr(np.array(times_ifft[cls])))
"\nnb_procs['"
+ cls
+ "'] = "
+ repr(np.array(nb_procs[cls]))
+ "\ntimes_fft['"
+ cls
+ "'] = "
+ repr(np.array(times_fft[cls]))
+ "\ntimes_ifft['"
+ cls
+ "'] = "
+ repr(np.array(times_ifft[cls]))
)

if not os.path.exists(output_dir):
os.mkdir(output_dir)

with open(output_dir + '/bench.py', 'w') as f:
f.write(src + '\n')
with open(output_dir + "/bench.py", "w") as f:
f.write(src + "\n")

0 comments on commit f444e2c

Please sign in to comment.