Added more profiling timers

This commit is contained in:
Martin Lilleeng Sætra
2022-04-07 09:07:20 +00:00
parent 124e033ff5
commit 8fd9d3d850
3 changed files with 52 additions and 25 deletions

View File

@@ -201,13 +201,13 @@ class MPISimulator(Simulator.BaseSimulator):
Class which handles communication between simulators on different MPI nodes
"""
def __init__(self, sim, grid):
self.profiling_data = { 'start': {}, 'end': {} }
self.profiling_data["start"]["t_halo_exchange"] = 0
self.profiling_data["end"]["t_halo_exchange"] = 0
self.profiling_data["start"]["t_step"] = 0
self.profiling_data["end"]["t_step"] = 0
self.profiling_data["n_time_steps"] = 0
self.profiling_data["start"]["t_mpi_sim_init"] = time.time()
self.profiling_data_mpi = { 'start': {}, 'end': {} }
self.profiling_data_mpi["start"]["t_step_mpi_halo_exchange"] = 0
self.profiling_data_mpi["end"]["t_step_mpi_halo_exchange"] = 0
self.profiling_data_mpi["start"]["t_step_mpi"] = 0
self.profiling_data_mpi["end"]["t_step_mpi"] = 0
self.profiling_data_mpi["n_time_steps"] = 0
self.profiling_data_mpi["start"]["t_sim_mpi_init"] = time.time()
self.logger = logging.getLogger(__name__)
autotuner = sim.context.autotuner
@@ -292,18 +292,26 @@ class MPISimulator(Simulator.BaseSimulator):
self.out_s = np.empty_like(self.in_s)
self.logger.debug("Simlator rank {:d} initialized on {:s}".format(self.grid.comm.rank, MPI.Get_processor_name()))
self.profiling_data["end"]["t_mpi_sim_init"] = time.time()
self.profiling_data_mpi["end"]["t_sim_mpi_init"] = time.time()
def substep(self, dt, step_number):
self.profiling_data["start"]["t_halo_exchange"] += time.time()
self.exchange()
self.profiling_data["end"]["t_halo_exchange"] += time.time()
if self.profiling_data_mpi["n_time_steps"] > 0:
self.profiling_data_mpi["start"]["t_step_mpi_halo_exchange"] += time.time()
self.exchange()
self.sim.stream.synchronize() # only necessary for profiling!
if self.profiling_data_mpi["n_time_steps"] > 0:
self.profiling_data_mpi["end"]["t_step_mpi_halo_exchange"] += time.time()
self.profiling_data_mpi["start"]["t_step_mpi"] += time.time()
self.profiling_data["start"]["t_step"] += time.time()
self.sim.substep(dt, step_number)
self.profiling_data["end"]["t_step"] += time.time()
self.profiling_data["n_time_steps"] += 1
self.sim.stream.synchronize() # only necessary for profiling!
if self.profiling_data_mpi["n_time_steps"] > 0:
self.profiling_data_mpi["end"]["t_step_mpi"] += time.time()
self.profiling_data_mpi["n_time_steps"] += 1
def getOutput(self):
return self.sim.getOutput()
@@ -422,6 +430,4 @@ class MPISimulator(Simulator.BaseSimulator):
#Wait for sending to complete
for comm in comm_send:
comm.wait()