Skip to content
Snippets Groups Projects
Commit e0b7a528 authored by Pierre Augier's avatar Pierre Augier
Browse files

More profiling + use fft3d.mpi_with_fftw1d for examples phaseshift (seems faster)

parent ae0dedfb
No related branches found
No related tags found
1 merge request!156Topic/default/phaseshift3d
......@@ -16,5 +16,6 @@
"""
from contextlib import redirect_stdout
from pathlib import Path
import sys
from fluiddyn.util import mpi
......@@ -19,5 +20,6 @@
from fluiddyn.util import mpi
from fluiddyn.io.tee import MultiFile
from run_simul import parser, init_params, init_state, Simul
......@@ -26,6 +28,17 @@
parser.set_defaults(max_elapsed="10:00:00", t_end=1.0)
class Tee:
def __init__(self, files):
self.files = list(files)
def __enter__(self):
sys.stdout = MultiFile(self.files + [sys.stdout])
def __exit__(self, *args):
sys.stdout = sys.__stdout__
def main(args):
params = init_params(args)
params.time_stepping.max_elapsed = None
......@@ -37,6 +50,6 @@
base_name_file = f"tmp_profile/{sim.name_run}."
name_file_log = base_name_file + "log"
with open(name_file_log, "w") as file:
with redirect_stdout(file):
with Tee([file]):
run_profile(sim, path_results=base_name_file + "pstats")
......@@ -41,8 +54,5 @@
run_profile(sim, path_results=base_name_file + "pstats")
with open(name_file_log) as file:
print(file.read())
if __name__ == "__main__":
args = parser.parse_args()
......
......@@ -125,6 +125,9 @@
if args.coef_dealiasing > 2 / 3:
params.oper.truncation_shape = "no_multiple_aliases"
if mpi.nb_proc > 1:
params.oper.type_fft = "fft3d.mpi_with_fftw1d"
params.output.sub_directory = sub_directory
params.output.periods_print.print_stdout = 0.5
params.output.periods_save.phys_fields = 4
......
......@@ -19,8 +19,8 @@
coefficients = np.array([2 / 3, 0.90, 1.0])
nx_bigs = [800, 400, 256, 128]
nb_procs = [20, 10, 4, 2]
nx_bigs = [800, 640, 400, 256, 128]
nb_procs = [20, 10, 10, 4, 2]
def compute(nx, nb_processes=20, verbose=True):
......
......@@ -71,6 +71,9 @@
path, t_as_str = get_path_file(sim, path_results, "profile", ".pstats")
path = Path(path)
if mpi.rank > 0:
path = path.with_name(path.stem + f"_rank{mpi.rank}" + path.suffix)
with stdout_redirected(not verbose):
sim.time_stepping.init_from_params()
t0 = time()
......@@ -80,7 +83,7 @@
t_end = time()
sim.time_stepping.finalize_main_loop()
if sim.oper.rank == 0:
if mpi.rank == 0:
times = analyze_stats(path, nb_dim, plot)
print(f"\nelapsed time = {t_end - t0:.3f} s")
name_solver = sim.__module__.rsplit(".", maxsplit=1)[0]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment