Note
Go to the end to download the full example code.
Read Shamrock MPI timers#
7 import numpy as np
8
9 import shamrock
10
11 # If we use the shamrock executable to run this script instead of the python interpreter,
12 # we should not initialize the system as the shamrock executable needs to handle specific MPI logic
13 if not shamrock.sys.is_initialized():
14 shamrock.change_loglevel(1)
15 shamrock.sys.init("0:0")
-> modified loglevel to 0 enabled log types :
log status :
- Loglevel: 1, enabled log types :
[xxx] Info: xxx ( logger::info )
[xxx] : xxx ( logger::normal )
[xxx] Warning: xxx ( logger::warn )
[xxx] Error: xxx ( logger::err )
18 before_mpi_timers = shamrock.comm.get_timers()
19 print(f"before_mpi_timers = {before_mpi_timers}")
before_mpi_timers = {'total': 2.7099999933000163e-07, 'MPI_Barrier': 2.7099999933000163e-07}
Force some MPI time in the most rude way possible
23 for i in range(1000):
24 shamrock.sys.mpi_barrier()
27 after_mpi_timers = shamrock.comm.get_timers()
28 print(f"after_mpi_timers = {after_mpi_timers}")
after_mpi_timers = {'total': 2.6085999991209974e-05, 'MPI_Barrier': 2.6085999991209974e-05}
Compute the delta
32 delta = shamrock.comm.mpi_timers_delta(before_mpi_timers, after_mpi_timers)
33
34 for k in sorted(delta):
35 print(f"{k} = {delta[k]} s")
MPI_Allgather = 0.0 s
MPI_Allgatherv = 0.0 s
MPI_Allreduce = 0.0 s
MPI_Barrier = 2.5814999991879972e-05 s
MPI_Exscan = 0.0 s
MPI_File_close = 0.0 s
MPI_File_open = 0.0 s
MPI_File_read = 0.0 s
MPI_File_read_at = 0.0 s
MPI_File_set_view = 0.0 s
MPI_File_write = 0.0 s
MPI_File_write_all = 0.0 s
MPI_File_write_at = 0.0 s
MPI_Gather = 0.0 s
MPI_Gatherv = 0.0 s
MPI_Get_count = 0.0 s
MPI_Irecv = 0.0 s
MPI_Isend = 0.0 s
MPI_Probe = 0.0 s
MPI_Recv = 0.0 s
MPI_Send = 0.0 s
MPI_Test = 0.0 s
MPI_Type_size = 0.0 s
MPI_Wait = 0.0 s
MPI_Waitall = 0.0 s
total = 2.5814999991879972e-05 s
Total running time of the script: (0 minutes 0.679 seconds)
Estimated memory usage: 210 MB