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);