From 137886c3168da88a2604627d6a71ba9c2b9ca299 Mon Sep 17 00:00:00 2001 From: Chulwoo Jung Date: Thu, 19 Oct 2017 10:28:57 -0400 Subject: [PATCH] Addressed when coor.size() != dim.size() in Lexicographic --- lib/communicator/Communicator_base.cc | 19 +++++++++++++++---- lib/qcd/utils/SpaceTimeGrid.cc | 1 + lib/util/Lexicographic.h | 4 ++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/communicator/Communicator_base.cc b/lib/communicator/Communicator_base.cc index ce9a3cf0..82913935 100644 --- a/lib/communicator/Communicator_base.cc +++ b/lib/communicator/Communicator_base.cc @@ -102,7 +102,6 @@ void CartesianCommunicator::GlobalSumVector(ComplexD *c,int N) CartesianCommunicator::CartesianCommunicator(const std::vector &processors,const CartesianCommunicator &parent) { _ndimension = processors.size(); - assert(_ndimension = parent._ndimension); ////////////////////////////////////////////////////////////////////////////////////////////////////// // split the communicator @@ -121,10 +120,22 @@ CartesianCommunicator::CartesianCommunicator(const std::vector &processors, std::vector scoor(_ndimension); // coor of split within parent std::vector ssize(_ndimension); // coor of split within parent + std::vector pcoor(_ndimension,0); + std::vector pdims(_ndimension,1); + + if(parent._processors.size()==4 && _ndimension==5){ + for(int i=0;i<4;i++) pcoor[i+1]=parent._processor_coor[i]; + for(int i=0;i<4;i++) pdims[i+1]=parent._processors[i]; + } else { + assert(_ndimension == parent._ndimension); + for(int i=0;i<_ndimension;i++) pcoor[i]=parent._processor_coor[i]; + for(int i=0;i<_ndimension;i++) pdims[i]=parent._processors[i]; + } + for(int d=0;d<_ndimension;d++){ - ccoor[d] = parent._processor_coor[d] % processors[d]; - scoor[d] = parent._processor_coor[d] / processors[d]; - ssize[d] = parent._processors[d]/ processors[d]; + ccoor[d] = pcoor[d] % processors[d]; + scoor[d] = pcoor[d] / processors[d]; + ssize[d] = pdims[d] / processors[d]; } int crank,srank; // rank within subcomm ; rank of subcomm within blocks of subcomms Lexicographic::IndexFromCoor(ccoor,crank,processors); diff --git a/lib/qcd/utils/SpaceTimeGrid.cc b/lib/qcd/utils/SpaceTimeGrid.cc index b2b5d9c8..bdc4262b 100644 --- a/lib/qcd/utils/SpaceTimeGrid.cc +++ b/lib/qcd/utils/SpaceTimeGrid.cc @@ -50,6 +50,7 @@ GridCartesian *SpaceTimeGrid::makeFourDimDWFGrid(const std::vector & latt,c GridCartesian *SpaceTimeGrid::makeFiveDimGrid(int Ls,const GridCartesian *FourDimGrid) { int N4=FourDimGrid->_ndimension; + assert(N4==4); std::vector latt5(1,Ls); std::vector simd5(1,1); diff --git a/lib/util/Lexicographic.h b/lib/util/Lexicographic.h index b922dba5..23c21c1f 100644 --- a/lib/util/Lexicographic.h +++ b/lib/util/Lexicographic.h @@ -18,6 +18,10 @@ namespace Grid{ static inline void IndexFromCoor (const std::vector& coor,int &index,const std::vector &dims){ int nd=dims.size(); + if(nd > coor.size()) { + std::cout<< "coor.size "<dims.size "<