From b1ede7b46d9efe3852203bb8fca98e02e30d0a6b Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Wed, 1 Jun 2022 19:25:42 -0400 Subject: [PATCH] Faster RNG init --- Grid/lattice/Lattice_rng.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Grid/lattice/Lattice_rng.h b/Grid/lattice/Lattice_rng.h index e5e63716..34df8da2 100644 --- a/Grid/lattice/Lattice_rng.h +++ b/Grid/lattice/Lattice_rng.h @@ -424,9 +424,30 @@ public: // MT implementation does not implement fast discard even though // in principle this is possible //////////////////////////////////////////////// +#if 1 + thread_for( lidx, _grid->lSites(), { + int gidx; + Coordinate pcoor; + Coordinate lcoor; + Coordinate gcoor; + _grid->LocalIndexToLocalCoor(lidx,lcoor); + pcoor=_grid->ThisProcessorCoor(); + _grid->ProcessorCoorLocalCoorToGlobalCoor(pcoor,lcoor,gcoor); + + int o_idx; + int i_idx; + int rank; + _grid->GlobalCoorToRankIndex(rank,o_idx,i_idx,gcoor); + assert(rank == _grid->ThisRank() ); + int l_idx=generator_idx(o_idx,i_idx); + _generators[l_idx] = master_engine; + Skip(_generators[l_idx],gidx); // Skip to next RNG sequence + }); +#else // Everybody loops over global volume. thread_for( gidx, _grid->_gsites, { + // Where is it? int rank; int o_idx; @@ -443,6 +464,7 @@ public: Skip(_generators[l_idx],gidx); // Skip to next RNG sequence } }); +#endif #else //////////////////////////////////////////////////////////////// // Machine and thread decomposition dependent seeding is efficient