From 295127d45606897d1a97ec7a73b8ade6031c3f26 Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Thu, 10 Oct 2024 21:58:26 +0000 Subject: [PATCH] Deterministic homebrew reduction --- Grid/communicator/Communicator_base.h | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Grid/communicator/Communicator_base.h b/Grid/communicator/Communicator_base.h index cd682dd0..3f38edd3 100644 --- a/Grid/communicator/Communicator_base.h +++ b/Grid/communicator/Communicator_base.h @@ -128,6 +128,34 @@ public: void GlobalXOR(uint32_t &); void GlobalXOR(uint64_t &); + template void GlobalSumP2P(obj &o) + { + std::vector column; + obj accum = o; + int source,dest; + for(int d=0;d<_ndimension;d++){ + column.resize(_processors[d]); + column[0] = accum; + std::vector list; + for(int p=1;p<_processors[d];p++){ + ShiftedRanks(d,p,source,dest); + SendToRecvFromBegin(list, + &column[0], + dest, + &column[p], + source, + sizeof(obj),d*100+p); + + } + CommsComplete(list); + for(int p=1;p<_processors[d];p++){ + accum = accum + column[p]; + } + } + Broadcast(0,accum); + o=accum; + } + template void GlobalSum(obj &o){ typedef typename obj::scalar_type scalar_type; int words = sizeof(obj)/sizeof(scalar_type);