mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-13 20:57:06 +01:00
Shmem related fixes for shmem compile
This commit is contained in:
@ -44,12 +44,14 @@ CartesianCommunicator::CartesianCommunicator(const std::vector<int> &processors)
|
||||
shmem_init_thread(SHMEM_THREAD_FUNNELED);
|
||||
_processor = shmem_my_pe();
|
||||
|
||||
CoorFromIndex(_processor_coor,_processor,_processors);
|
||||
Lexicographic::CoorFromIndex(_processor_coor,_processor,_processors);
|
||||
|
||||
for(int i=0;i<_ndimension;i++){
|
||||
_Nprocessors*=_processors[i];
|
||||
}
|
||||
|
||||
if ( _processor == 0 ) {
|
||||
printf("I'm running SHMEM communications %d \n",_processor);
|
||||
}
|
||||
int Size = shmem_n_pes();
|
||||
assert(Size==_Nprocessors);
|
||||
}
|
||||
@ -67,13 +69,13 @@ void CartesianCommunicator::GlobalSum(uint32_t &u){
|
||||
u = dest;
|
||||
}
|
||||
void CartesianCommunicator::GlobalSum(float &f){
|
||||
static float source = u;
|
||||
static float source = f;
|
||||
static float dest = 0 ;
|
||||
static float llwrk[_SHMEM_REDUCE_MIN_WRKDATA_SIZE];
|
||||
static long psync[_SHMEM_REDUCE_SYNC_SIZE];
|
||||
|
||||
shmem_float_sum_to_all(&dest,&source,1,0,0,_Nprocessors,llwrk,psync);
|
||||
u = dest;
|
||||
f = dest;
|
||||
}
|
||||
void CartesianCommunicator::GlobalSumVector(float *f,int N)
|
||||
{
|
||||
@ -83,20 +85,20 @@ void CartesianCommunicator::GlobalSumVector(float *f,int N)
|
||||
static long psync[_SHMEM_REDUCE_SYNC_SIZE];
|
||||
|
||||
for(int i=0;i<N;i++){
|
||||
source = u[i];
|
||||
source = f[i];
|
||||
shmem_float_sum_to_all(&dest,&source,1,0,0,_Nprocessors,llwrk,psync);
|
||||
u[i] = dest;
|
||||
f[i] = dest;
|
||||
}
|
||||
}
|
||||
void CartesianCommunicator::GlobalSum(double &d)
|
||||
{
|
||||
static double source = u;
|
||||
static double source = d;
|
||||
static double dest = 0 ;
|
||||
static double llwrk[_SHMEM_REDUCE_MIN_WRKDATA_SIZE];
|
||||
static long psync[_SHMEM_REDUCE_SYNC_SIZE];
|
||||
|
||||
shmem_double_sum_to_all(&dest,&source,1,0,0,_Nprocessors,llwrk,psync);
|
||||
u = dest;
|
||||
d = dest;
|
||||
}
|
||||
void CartesianCommunicator::GlobalSumVector(double *d,int N)
|
||||
{
|
||||
@ -106,9 +108,9 @@ void CartesianCommunicator::GlobalSumVector(double *d,int N)
|
||||
static long psync[_SHMEM_REDUCE_SYNC_SIZE];
|
||||
|
||||
for(int i=0;i<N;i++){
|
||||
source = u[i];
|
||||
source = d[i];
|
||||
shmem_double_sum_to_all(&dest,&source,1,0,0,_Nprocessors,llwrk,psync);
|
||||
u[i] = dest;
|
||||
d[i] = dest;
|
||||
}
|
||||
}
|
||||
void CartesianCommunicator::ShiftedRanks(int dim,int shift,int &source,int &dest)
|
||||
@ -117,21 +119,21 @@ void CartesianCommunicator::ShiftedRanks(int dim,int shift,int &source,int &dest
|
||||
assert(std::abs(shift) <_processors[dim]);
|
||||
|
||||
coor[dim] = (coor[dim] + shift + _processors[dim])%_processors[dim];
|
||||
IndexFromCoor(coor,source,_processors);
|
||||
Lexicographic::IndexFromCoor(coor,source,_processors);
|
||||
|
||||
coor[dim] = (coor[dim] - shift + _processors[dim])%_processors[dim];
|
||||
IndexFromCoor(coor,dest,_processors);
|
||||
Lexicographic::IndexFromCoor(coor,dest,_processors);
|
||||
|
||||
}
|
||||
int CartesianCommunicator::RankFromProcessorCoor(std::vector<int> &coor)
|
||||
{
|
||||
int rank;
|
||||
IndexFromCoor(coor,rank,_processors);
|
||||
Lexicographic::IndexFromCoor(coor,rank,_processors);
|
||||
return rank;
|
||||
}
|
||||
void CartesianCommunicator::ProcessorCoorFromRank(int rank, std::vector<int> &coor)
|
||||
{
|
||||
CoorFromIndex(coor,rank,_processors);
|
||||
Lexicographic::CoorFromIndex(coor,rank,_processors);
|
||||
}
|
||||
|
||||
// Basic Halo comms primitive
|
||||
@ -187,7 +189,9 @@ void CartesianCommunicator::Broadcast(int root,void* data, int bytes)
|
||||
}
|
||||
void CartesianCommunicator::BroadcastWorld(int root,void* data, int bytes)
|
||||
{
|
||||
Broadcast(root,data,bytes);
|
||||
static long psync[_SHMEM_REDUCE_SYNC_SIZE];
|
||||
assert( (bytes % 4)==0);
|
||||
shmem_broadcast32(data,data,bytes/4,root,0,0,shmem_n_pes(),psync);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user