mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-10-31 12:04:33 +00:00 
			
		
		
		
	Make my own reduction a configure flag
This commit is contained in:
		| @@ -57,18 +57,29 @@ int                      CartesianCommunicator::ProcessorCount(void)    { return | |||||||
| // very VERY rarely (Log, serial RNG) we need world without a grid | // very VERY rarely (Log, serial RNG) we need world without a grid | ||||||
| //////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// | ||||||
|  |  | ||||||
|  | #ifdef USE_GRID_REDUCTION | ||||||
|  | void CartesianCommunicator::GlobalSum(ComplexF &c) | ||||||
|  | { | ||||||
|  |   GlobalSumP2P(c); | ||||||
|  | } | ||||||
|  | void CartesianCommunicator::GlobalSum(ComplexD &c) | ||||||
|  | { | ||||||
|  |   GlobalSumP2P(c); | ||||||
|  | } | ||||||
|  | #else | ||||||
| void CartesianCommunicator::GlobalSum(ComplexF &c) | void CartesianCommunicator::GlobalSum(ComplexF &c) | ||||||
| { | { | ||||||
|   GlobalSumVector((float *)&c,2); |   GlobalSumVector((float *)&c,2); | ||||||
| } | } | ||||||
| void CartesianCommunicator::GlobalSumVector(ComplexF *c,int N) |  | ||||||
| { |  | ||||||
|   GlobalSumVector((float *)c,2*N); |  | ||||||
| } |  | ||||||
| void CartesianCommunicator::GlobalSum(ComplexD &c) | void CartesianCommunicator::GlobalSum(ComplexD &c) | ||||||
| { | { | ||||||
|   GlobalSumVector((double *)&c,2); |   GlobalSumVector((double *)&c,2); | ||||||
| } | } | ||||||
|  | #endif | ||||||
|  | void CartesianCommunicator::GlobalSumVector(ComplexF *c,int N) | ||||||
|  | { | ||||||
|  |   GlobalSumVector((float *)c,2*N); | ||||||
|  | } | ||||||
| void CartesianCommunicator::GlobalSumVector(ComplexD *c,int N) | void CartesianCommunicator::GlobalSumVector(ComplexD *c,int N) | ||||||
| { | { | ||||||
|   GlobalSumVector((double *)c,2*N); |   GlobalSumVector((double *)c,2*N); | ||||||
|   | |||||||
| @@ -257,6 +257,25 @@ CartesianCommunicator::~CartesianCommunicator() | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | #ifdef USE_GRID_REDUCTION | ||||||
|  | void CartesianCommunicator::GlobalSum(float &f){ | ||||||
|  |   CartesianCommunicator::GlobalSumP2P(f); | ||||||
|  | } | ||||||
|  | void CartesianCommunicator::GlobalSum(double &d) | ||||||
|  | { | ||||||
|  |   CartesianCommunicator::GlobalSumP2P(d); | ||||||
|  | } | ||||||
|  | #else | ||||||
|  | void CartesianCommunicator::GlobalSum(float &f){ | ||||||
|  |   int ierr=MPI_Allreduce(MPI_IN_PLACE,&f,1,MPI_FLOAT,MPI_SUM,communicator); | ||||||
|  |   assert(ierr==0); | ||||||
|  | } | ||||||
|  | void CartesianCommunicator::GlobalSum(double &d) | ||||||
|  | { | ||||||
|  |   int ierr = MPI_Allreduce(MPI_IN_PLACE,&d,1,MPI_DOUBLE,MPI_SUM,communicator); | ||||||
|  |   assert(ierr==0); | ||||||
|  | } | ||||||
|  | #endif | ||||||
| void CartesianCommunicator::GlobalSum(uint32_t &u){ | void CartesianCommunicator::GlobalSum(uint32_t &u){ | ||||||
|   int ierr=MPI_Allreduce(MPI_IN_PLACE,&u,1,MPI_UINT32_T,MPI_SUM,communicator); |   int ierr=MPI_Allreduce(MPI_IN_PLACE,&u,1,MPI_UINT32_T,MPI_SUM,communicator); | ||||||
|   assert(ierr==0); |   assert(ierr==0); | ||||||
| @@ -287,20 +306,11 @@ void CartesianCommunicator::GlobalMax(double &d) | |||||||
|   int ierr = MPI_Allreduce(MPI_IN_PLACE,&d,1,MPI_DOUBLE,MPI_MAX,communicator); |   int ierr = MPI_Allreduce(MPI_IN_PLACE,&d,1,MPI_DOUBLE,MPI_MAX,communicator); | ||||||
|   assert(ierr==0); |   assert(ierr==0); | ||||||
| } | } | ||||||
| void CartesianCommunicator::GlobalSum(float &f){ |  | ||||||
|   int ierr=MPI_Allreduce(MPI_IN_PLACE,&f,1,MPI_FLOAT,MPI_SUM,communicator); |  | ||||||
|   assert(ierr==0); |  | ||||||
| } |  | ||||||
| void CartesianCommunicator::GlobalSumVector(float *f,int N) | void CartesianCommunicator::GlobalSumVector(float *f,int N) | ||||||
| { | { | ||||||
|   int ierr=MPI_Allreduce(MPI_IN_PLACE,f,N,MPI_FLOAT,MPI_SUM,communicator); |   int ierr=MPI_Allreduce(MPI_IN_PLACE,f,N,MPI_FLOAT,MPI_SUM,communicator); | ||||||
|   assert(ierr==0); |   assert(ierr==0); | ||||||
| } | } | ||||||
| void CartesianCommunicator::GlobalSum(double &d) |  | ||||||
| { |  | ||||||
|   int ierr = MPI_Allreduce(MPI_IN_PLACE,&d,1,MPI_DOUBLE,MPI_SUM,communicator); |  | ||||||
|   assert(ierr==0); |  | ||||||
| } |  | ||||||
| void CartesianCommunicator::GlobalSumVector(double *d,int N) | void CartesianCommunicator::GlobalSumVector(double *d,int N) | ||||||
| { | { | ||||||
|   int ierr = MPI_Allreduce(MPI_IN_PLACE,d,N,MPI_DOUBLE,MPI_SUM,communicator); |   int ierr = MPI_Allreduce(MPI_IN_PLACE,d,N,MPI_DOUBLE,MPI_SUM,communicator); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user