From 1fc01c700aa8a887fe11f4a33bfa87744b84ee5e Mon Sep 17 00:00:00 2001 From: Frederic Perez Date: Thu, 25 Apr 2024 10:05:25 +0200 Subject: [PATCH] add smilei_omp_threads in namelist --- .../gpu/tst3d_gpu_o2_thermal_plasma_medium.py | 2 +- .../gpu/tst3d_gpu_o2_thermal_plasma_short.py | 1 - .../gpu/tst3d_v_o2_thermal_plasma_medium.py | 2 +- .../gpu/tst3d_v_o2_thermal_plasma_short.py | 1 - benchmarks/tst2d_18_em_pml.py | 1 - benchmarks/tst2d_s_o4_laser_wake_vay.py | 2 -- benchmarks/tst2d_s_o4_radiation_pressure_acc.py | 2 -- .../tst2d_tasks_01_radiation_pressure_acc.py | 1 - benchmarks/tst2d_v_o2_em_propagation.py | 2 -- benchmarks/tst2d_v_o4_em_propagation.py | 2 -- benchmarks/tst2d_v_o4_laser_wake_vay.py | 2 -- .../tst2d_v_o4_multiphoton_Breit_Wheeler.py | 3 --- benchmarks/tst2d_v_o4_radiation_pressure_acc.py | 2 -- benchmarks/tst3d_s_o4_em_propagation.py | 2 -- doc/Sphinx/Overview/releases.rst | 11 ++++++----- doc/Sphinx/Use/namelist.rst | 17 ++++++++++++----- src/Params/Params.cpp | 14 +++++++++----- src/Python/pyinit.py | 3 ++- 18 files changed, 31 insertions(+), 39 deletions(-) diff --git a/benchmarks/gpu/tst3d_gpu_o2_thermal_plasma_medium.py b/benchmarks/gpu/tst3d_gpu_o2_thermal_plasma_medium.py index a50614236..cb8c8f26a 100644 --- a/benchmarks/gpu/tst3d_gpu_o2_thermal_plasma_medium.py +++ b/benchmarks/gpu/tst3d_gpu_o2_thermal_plasma_medium.py @@ -66,7 +66,7 @@ def InitialChargeDensity(x, y, z): number_of_patches = kPatchPerGridDimension, EM_boundary_conditions = [ ["periodic"] ], print_every = 10, - random_seed = smilei_mpi_rank) + ) Vectorization(mode = "off") diff --git a/benchmarks/gpu/tst3d_gpu_o2_thermal_plasma_short.py b/benchmarks/gpu/tst3d_gpu_o2_thermal_plasma_short.py index 548746977..a627232f9 100644 --- a/benchmarks/gpu/tst3d_gpu_o2_thermal_plasma_short.py +++ b/benchmarks/gpu/tst3d_gpu_o2_thermal_plasma_short.py @@ -61,7 +61,6 @@ gpu_computing = True, # random_seed = 0xDEADBEEF, - random_seed = smilei_mpi_rank, ) Vectorization( diff --git a/benchmarks/gpu/tst3d_v_o2_thermal_plasma_medium.py b/benchmarks/gpu/tst3d_v_o2_thermal_plasma_medium.py index 524f564d0..92c598c19 100644 --- a/benchmarks/gpu/tst3d_v_o2_thermal_plasma_medium.py +++ b/benchmarks/gpu/tst3d_v_o2_thermal_plasma_medium.py @@ -67,7 +67,7 @@ def InitialChargeDensity(x, y, z): number_of_patches = kPatchPerGridDimension, EM_boundary_conditions = [ ["periodic"] ], print_every = 10, - random_seed = smilei_mpi_rank) + ) Vectorization(mode = "on") diff --git a/benchmarks/gpu/tst3d_v_o2_thermal_plasma_short.py b/benchmarks/gpu/tst3d_v_o2_thermal_plasma_short.py index 3672fd9d0..bc553aa62 100644 --- a/benchmarks/gpu/tst3d_v_o2_thermal_plasma_short.py +++ b/benchmarks/gpu/tst3d_v_o2_thermal_plasma_short.py @@ -61,7 +61,6 @@ gpu_computing = False, # random_seed = 0xDEADBEEF, - random_seed = smilei_mpi_rank, ) Vectorization( diff --git a/benchmarks/tst2d_18_em_pml.py b/benchmarks/tst2d_18_em_pml.py index 18dc5ee09..703fe50fc 100755 --- a/benchmarks/tst2d_18_em_pml.py +++ b/benchmarks/tst2d_18_em_pml.py @@ -25,7 +25,6 @@ ['PML','PML'], ], number_of_pml_cells = [[10,10],[10,10]], - random_seed = smilei_mpi_rank ) Antenna( diff --git a/benchmarks/tst2d_s_o4_laser_wake_vay.py b/benchmarks/tst2d_s_o4_laser_wake_vay.py index 4a4725b51..bb75f29e6 100644 --- a/benchmarks/tst2d_s_o4_laser_wake_vay.py +++ b/benchmarks/tst2d_s_o4_laser_wake_vay.py @@ -28,8 +28,6 @@ solve_poisson = False, print_every = 100, - - random_seed = smilei_mpi_rank ) MovingWindow( diff --git a/benchmarks/tst2d_s_o4_radiation_pressure_acc.py b/benchmarks/tst2d_s_o4_radiation_pressure_acc.py index 7adbc8844..755cbf763 100755 --- a/benchmarks/tst2d_s_o4_radiation_pressure_acc.py +++ b/benchmarks/tst2d_s_o4_radiation_pressure_acc.py @@ -28,8 +28,6 @@ ['silver-muller'], ['periodic'], ], - - random_seed = smilei_mpi_rank ) Vectorization( diff --git a/benchmarks/tst2d_tasks_01_radiation_pressure_acc.py b/benchmarks/tst2d_tasks_01_radiation_pressure_acc.py index 9d4c9af87..6a8530bf0 100644 --- a/benchmarks/tst2d_tasks_01_radiation_pressure_acc.py +++ b/benchmarks/tst2d_tasks_01_radiation_pressure_acc.py @@ -39,7 +39,6 @@ ['periodic'], ], cluster_width = 16, - random_seed = smilei_mpi_rank ) diff --git a/benchmarks/tst2d_v_o2_em_propagation.py b/benchmarks/tst2d_v_o2_em_propagation.py index cc152fa80..76741f1bd 100644 --- a/benchmarks/tst2d_v_o2_em_propagation.py +++ b/benchmarks/tst2d_v_o2_em_propagation.py @@ -32,8 +32,6 @@ ], EM_boundary_conditions_k = [[cos(ang), sin(ang)],[-1.,0.],[0.,1.],[0.,-1.]], - - random_seed = smilei_mpi_rank ) Vectorization( diff --git a/benchmarks/tst2d_v_o4_em_propagation.py b/benchmarks/tst2d_v_o4_em_propagation.py index c6ed8b064..2e15305b0 100644 --- a/benchmarks/tst2d_v_o4_em_propagation.py +++ b/benchmarks/tst2d_v_o4_em_propagation.py @@ -32,8 +32,6 @@ ], EM_boundary_conditions_k = [[cos(ang), sin(ang)],[-1.,0.],[0.,1.],[0.,-1.]], - - random_seed = smilei_mpi_rank ) Vectorization( diff --git a/benchmarks/tst2d_v_o4_laser_wake_vay.py b/benchmarks/tst2d_v_o4_laser_wake_vay.py index 969263838..9e56337d0 100644 --- a/benchmarks/tst2d_v_o4_laser_wake_vay.py +++ b/benchmarks/tst2d_v_o4_laser_wake_vay.py @@ -28,8 +28,6 @@ solve_poisson = False, print_every = 100, - - random_seed = smilei_mpi_rank ) Vectorization( diff --git a/benchmarks/tst2d_v_o4_multiphoton_Breit_Wheeler.py b/benchmarks/tst2d_v_o4_multiphoton_Breit_Wheeler.py index 7db269c5e..91907aee9 100755 --- a/benchmarks/tst2d_v_o4_multiphoton_Breit_Wheeler.py +++ b/benchmarks/tst2d_v_o4_multiphoton_Breit_Wheeler.py @@ -95,9 +95,6 @@ def n0_positron(x,y): simulation_time = Tsim, EM_boundary_conditions = [field_cond, field_cond], - - random_seed = smilei_mpi_rank, - reference_angular_frequency_SI = wr ) diff --git a/benchmarks/tst2d_v_o4_radiation_pressure_acc.py b/benchmarks/tst2d_v_o4_radiation_pressure_acc.py index c0feb79d2..353418604 100644 --- a/benchmarks/tst2d_v_o4_radiation_pressure_acc.py +++ b/benchmarks/tst2d_v_o4_radiation_pressure_acc.py @@ -28,8 +28,6 @@ ['silver-muller'], ['periodic'], ], - - random_seed = smilei_mpi_rank ) diff --git a/benchmarks/tst3d_s_o4_em_propagation.py b/benchmarks/tst3d_s_o4_em_propagation.py index 6a87f2dfa..ef97569d5 100755 --- a/benchmarks/tst3d_s_o4_em_propagation.py +++ b/benchmarks/tst3d_s_o4_em_propagation.py @@ -21,8 +21,6 @@ simulation_time = Tsim, EM_boundary_conditions = [ ['silver-muller'] ], - - random_seed = smilei_mpi_rank ) LaserGaussian3D( diff --git a/doc/Sphinx/Overview/releases.rst b/doc/Sphinx/Overview/releases.rst index 8027d2f3d..5c3e9d046 100755 --- a/doc/Sphinx/Overview/releases.rst +++ b/doc/Sphinx/Overview/releases.rst @@ -30,6 +30,12 @@ Changes made in the repository (not released) * Features: * Relativistic field initialization now supports multiple species and both direction propagations. + * Added the argument ``phase_offset`` in laser definitions such as ``LaserGaussian2D``. + * The ``LaserGaussianAM`` definition will only use one coordinate for its ``focus`` argument + (the transverse coordinate of the focus in this geometry is zero). + * Small improvements in PML for envelope model (AM and 2D). + * Deprecated ``smilei_rand_max``. + * New namelist variables ``smilei_omp_threads`` and ``smilei_total_cores``. * Happi: @@ -44,11 +50,6 @@ Changes made in the repository (not released) * Dark theme (click the switch on the bottom left, or set browser preferences). -* Added the argument ``phase_offset`` in laser definitions such as ``LaserGaussian2D``. -* The ``LaserGaussianAM`` definition will only use one coordinate for its ``focus`` argument - (the transverse coordinate of the focus in this geometry is zero). -* Small improvements in PML for envelope model (AM and 2D). - * Bug fixes: * ``dump_minutes`` often failed to write some checkpoint files. diff --git a/doc/Sphinx/Use/namelist.rst b/doc/Sphinx/Use/namelist.rst index ad318954c..f7deebcae 100755 --- a/doc/Sphinx/Use/namelist.rst +++ b/doc/Sphinx/Use/namelist.rst @@ -60,7 +60,8 @@ for each MPI process). The following steps are executed: * The rank of the current MPI process as :py:data:`smilei_mpi_rank`. * The total number of MPI processes as :py:data:`smilei_mpi_size`. - * The maximum random integer as :py:data:`smilei_rand_max`. + * The number of OpenMP threads per MPI :py:data:`smilei_omp_threads`. + * The total number of cores :py:data:`smilei_total_cores`. #. The namelist(s) is executed. @@ -3619,9 +3620,15 @@ namelist. They should not be re-defined by the user! The total number of MPI processes. -.. - <> - .. py:data:: smilei_rand_max +.. py:data:: smilei_omp_threads + + The number of OpenMP threads per MPI. + +.. py:data:: smilei_total_cores - The largest random integer. + The total number of cores. +.. note:: + + These variables can be access during ``happi`` post-processing, e.g. + ``S.namelist.smilei_mpi_size``. \ No newline at end of file diff --git a/src/Params/Params.cpp b/src/Params/Params.cpp index bc9fb8ed4..803cdf9e5 100755 --- a/src/Params/Params.cpp +++ b/src/Params/Params.cpp @@ -129,16 +129,20 @@ Params::Params( SmileiMPI *smpi, std::vector namelistsFiles ) : PyObject_SetAttrString( Py_main, "_test_mode", Py_False ); PyTools::checkPyError(); - // here we add the rank, in case some script need it + // we add the rank, in case some script needs it PyModule_AddIntConstant( Py_main, "smilei_mpi_rank", smpi->getRank() ); - // here we add the MPI size, in case some script need it + // we add the MPI size, in case some script needs it PyModule_AddIntConstant( Py_main, "smilei_mpi_size", smpi->getSize() ); namelist += string( "smilei_mpi_size = " ) + to_string( smpi->getSize() ) + "\n"; - // here we add the larget int, important to get a valid seed for randomization - PyModule_AddIntConstant( Py_main, "smilei_rand_max", RAND_MAX ); - namelist += string( "smilei_rand_max = " ) + to_string( RAND_MAX ) + "\n\n"; + // we add the openMP size, in case some script needs it + PyModule_AddIntConstant( Py_main, "smilei_omp_threads", smpi->getOMPMaxThreads() ); + namelist += string( "smilei_omp_threads = " ) + to_string( smpi->getOMPMaxThreads() ) + "\n"; + + // we add the total number of cores, in case some script needs it + PyModule_AddIntConstant( Py_main, "smilei_total_cores", smpi->getGlobalNumCores() ); + namelist += string( "smilei_total_cores = " ) + to_string( smpi->getGlobalNumCores() ) + "\n"; // Running pyprofiles.py runScript( string( reinterpret_cast( pyprofiles_py ), pyprofiles_py_len ), "pyprofiles.py", globals ); diff --git a/src/Python/pyinit.py b/src/Python/pyinit.py index 56febc475..f5aeeb7e1 100755 --- a/src/Python/pyinit.py +++ b/src/Python/pyinit.py @@ -645,7 +645,8 @@ class MultiphotonBreitWheeler(SmileiComponent): # Smilei-defined smilei_mpi_rank = 0 smilei_mpi_size = 1 -smilei_rand_max = 2**31-1 +smilei_omp_threads = 1 +smilei_total_cores = 1 # Variable to set to False for the actual run (useful for the test mode) _test_mode = True