Skip to content

Commit

Permalink
++
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Sep 28, 2024
1 parent dc03f03 commit 62c04ab
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
7 changes: 6 additions & 1 deletion pyphare/pyphare/simulator/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
#

import os
import datetime
import atexit
import time as timem
Expand All @@ -11,6 +12,7 @@


life_cycles = {}
PHARE_SIM_MON = os.getenv("PHARE_SIM_MON", "False").lower() in ("true", "1", "t")


@atexit.register
Expand Down Expand Up @@ -171,12 +173,15 @@ def times(self):
self.timeStep(),
)

def run(self, plot_times=False, monitoring=False):
def run(self, plot_times=False, monitoring=None):
"""monitoring requires phlop"""
from pyphare.cpp import cpp_lib

self._check_init()

if monitoring is None: # check env
monitoring = PHARE_SIM_MON

if self.simulation.dry_run:
return self
if monitoring:
Expand Down
2 changes: 1 addition & 1 deletion src/phare/phare.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SamraiLifeCycle
PHARE_WITH_PHLOP( //
if (auto e = core::get_env("PHARE_SCOPE_TIMING", "false"); e == "1" || e == "true")
phlop::ScopeTimerMan::INSTANCE()
.file_name(".phare_times." + std::to_string(core::mpi::rank()) + ".txt")
.file_name(".phare/timings/rank." + std::to_string(core::mpi::rank()) + ".txt")
.init(); //
)
}
Expand Down
4 changes: 3 additions & 1 deletion tests/functional/harris/harris_2d_lb.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

mpl.use("Agg")

SCOPE_TIMING = os.getenv("PHARE_SCOPE_TIMING", "True").lower() in ("true", "1", "t")
LOAD_BALANCE = os.getenv("LOAD_BALANCE", "True").lower() in ("true", "1", "t")

cpp = cpp_lib()
Expand Down Expand Up @@ -200,7 +201,8 @@ def test_run(self):
Simulator(config()).run().reset()
if cpp.mpi_rank() == 0:
plot(diag_dir)
m_plotting.plot_run_timer_data(diag_dir, cpp.mpi_rank())
if SCOPE_TIMING:
m_plotting.plot_run_timer_data(diag_dir, cpp.mpi_rank())
cpp.mpi_barrier()
return self

Expand Down
23 changes: 23 additions & 0 deletions tools/python3/phloping.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,26 @@ def normalised_times_for_L(self, ilvl):
def file_parser(run, rank, times_filepath):
supe = phfile_parser(times_filepath)
return ScopeTimerFile(supe.id_keys, supe.roots, run, str(rank))


def write_root_as_csv(scope_timer_file, outfile, headers=None, regex=None):
from contextlib import redirect_stdout

with open(outfile, "w") as f:
with redirect_stdout(f):
print_root_as_csv(scope_timer_file, headers, regex)


def print_root_as_csv(scope_timer_file, headers=None, regex=None, n_parts):
stf = scope_timer_file # alias
stf = file_parser(stf) if isinstance(stf, str) else stf

if headers:
print(",".join(headers))
for root in stf.roots:
s = stf(root.k)
if regex and regex not in s:
continue
bits = s.split(",")
dim = int(bits[1])
print(f"{s}{root.t},{root.t/n_parts}")

0 comments on commit 62c04ab

Please sign in to comment.