From 063ee2295a8ae2d6f61ff4c202d25807c521858e Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Sat, 28 Sep 2024 16:13:13 +0200 Subject: [PATCH] ++ --- pyphare/pyphare/cpp/validate.py | 5 +++-- pyphare/pyphare/simulator/simulator.py | 11 +++++++---- tools/python3/phloping.py | 2 +- tools/python3/plotting.py | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pyphare/pyphare/cpp/validate.py b/pyphare/pyphare/cpp/validate.py index cf42e6ec8..c80ba4c84 100644 --- a/pyphare/pyphare/cpp/validate.py +++ b/pyphare/pyphare/cpp/validate.py @@ -107,11 +107,12 @@ def log_runtime_config(): git_hash=get_git_hash(), ) + rank_info_dir = DOT_PHARE_DIR / "rank_info" if cpp_lib.mpi_rank() == 0: - DOT_PHARE_DIR.mkdir(exist_ok=True, parents=True) + rank_info_dir.mkdir(exist_ok=True, parents=True) cpp_lib.mpi_barrier() - rank_dir = DOT_PHARE_DIR / f"rank_{cpp_lib.mpi_rank()}" + rank_dir = rank_info_dir / f"{cpp_lib.mpi_rank()}" rank_dir.mkdir(exist_ok=True) with open(rank_dir / "runtime_config.json", "w") as f: diff --git a/pyphare/pyphare/simulator/simulator.py b/pyphare/pyphare/simulator/simulator.py index e39f33050..a1ed93d3d 100644 --- a/pyphare/pyphare/simulator/simulator.py +++ b/pyphare/pyphare/simulator/simulator.py @@ -8,11 +8,13 @@ import time as timem import numpy as np import pyphare.pharein as ph +from pathlib import Path from . import monitoring as mon life_cycles = {} -PHARE_SIM_MON = os.getenv("PHARE_SIM_MON", "False").lower() in ("true", "1", "t") +SIM_MONITOR = os.getenv("PHARE_SIM_MON", "False").lower() in ("true", "1", "t") +SCOPE_TIMING = os.getenv("PHARE_SCOPE_TIMING", "False").lower() in ("true", "1", "t") @atexit.register @@ -27,6 +29,9 @@ def simulator_shutdown(): def make_cpp_simulator(dim, interp, nbrRefinedPart, hier): from pyphare.cpp import cpp_lib + if SCOPE_TIMING: + Path(".phare/timings").mkdir(exist_ok=True) + make_sim = f"make_simulator_{dim}_{interp}_{nbrRefinedPart}" return getattr(cpp_lib(), make_sim)(hier) @@ -180,7 +185,7 @@ def run(self, plot_times=False, monitoring=None): self._check_init() if monitoring is None: # check env - monitoring = PHARE_SIM_MON + monitoring = SIM_MONITOR if self.simulation.dry_run: return self @@ -281,6 +286,4 @@ def _log_to_file(self): from pyphare.cpp import cpp_lib if os.environ["PHARE_LOG"] != "NONE" and cpp_lib().mpi_rank() == 0: - from pathlib import Path - Path(".log").mkdir(exist_ok=True) diff --git a/tools/python3/phloping.py b/tools/python3/phloping.py index b795be173..d80e6c562 100644 --- a/tools/python3/phloping.py +++ b/tools/python3/phloping.py @@ -157,7 +157,7 @@ def write_root_as_csv(scope_timer_file, outfile, headers=None, regex=None): print_root_as_csv(scope_timer_file, headers, regex) -def print_root_as_csv(scope_timer_file, headers=None, regex=None, n_parts): +def print_root_as_csv(scope_timer_file, n_parts, headers=None, regex=None): stf = scope_timer_file # alias stf = file_parser(stf) if isinstance(stf, str) else stf diff --git a/tools/python3/plotting.py b/tools/python3/plotting.py index 5db7d9824..7fc295f13 100644 --- a/tools/python3/plotting.py +++ b/tools/python3/plotting.py @@ -25,7 +25,7 @@ def plot_run_timer_data(diag_dir=None, rank=0): parser.add_argument("-d", "--dir", default=".", help="Diagnostics directory") diag_dir = parser.parse_args().dir run = Run(diag_dir) - res = phloping.file_parser(run, rank, Path(f".phare_times.{rank}.txt")) + res = phloping.file_parser(run, rank, Path(f".phare/timings/rank.{rank}.txt")) fig, ax = plt.subplots() L0X = res.time_steps_for_L(0) ax.plot(L0X, res.normalised_times_for_L(0), ":", label="L0 times", color="black")