diff --git a/lib/communicator/Communicator_mpi.cc b/lib/communicator/Communicator_mpi.cc index 1a48d856..470a06c7 100644 --- a/lib/communicator/Communicator_mpi.cc +++ b/lib/communicator/Communicator_mpi.cc @@ -26,6 +26,8 @@ Author: Peter Boyle *************************************************************************************/ /* END LEGAL */ #include +#include +#include #include namespace Grid { diff --git a/lib/communicator/Communicator_shmem.cc b/lib/communicator/Communicator_shmem.cc index b7a263a4..3c76c808 100644 --- a/lib/communicator/Communicator_shmem.cc +++ b/lib/communicator/Communicator_shmem.cc @@ -27,6 +27,7 @@ Author: Peter Boyle /* END LEGAL */ #include #include +#include namespace Grid { @@ -51,7 +52,7 @@ typedef struct HandShake_t { } HandShake; std::array make_psync_init(void) { - array ret; + std::array ret; ret.fill(SHMEM_SYNC_VALUE); return ret; } @@ -109,7 +110,7 @@ void CartesianCommunicator::GlobalSum(uint32_t &u){ source = u; dest = 0; - shmem_longlong_sum_to_all(&dest,&source,1,0,0,_Nprocessors,llwrk,psync); + shmem_longlong_sum_to_all(&dest,&source,1,0,0,_Nprocessors,llwrk,psync.data()); shmem_barrier_all(); // necessary? u = dest; } @@ -125,7 +126,7 @@ void CartesianCommunicator::GlobalSum(uint64_t &u){ source = u; dest = 0; - shmem_longlong_sum_to_all(&dest,&source,1,0,0,_Nprocessors,llwrk,psync); + shmem_longlong_sum_to_all(&dest,&source,1,0,0,_Nprocessors,llwrk,psync.data()); shmem_barrier_all(); // necessary? u = dest; } @@ -137,7 +138,8 @@ void CartesianCommunicator::GlobalSum(float &f){ source = f; dest =0.0; - shmem_float_sum_to_all(&dest,&source,1,0,0,_Nprocessors,llwrk,psync); + shmem_float_sum_to_all(&dest,&source,1,0,0,_Nprocessors,llwrk,psync.data()); + shmem_barrier_all(); f = dest; } void CartesianCommunicator::GlobalSumVector(float *f,int N) @@ -148,14 +150,16 @@ void CartesianCommunicator::GlobalSumVector(float *f,int N) static std::array psync = psync_init; if ( shmem_addr_accessible(f,_processor) ){ - shmem_float_sum_to_all(f,f,N,0,0,_Nprocessors,llwrk,psync); + shmem_float_sum_to_all(f,f,N,0,0,_Nprocessors,llwrk,psync.data()); + shmem_barrier_all(); return; } for(int i=0;i &lis SHMEM_VET(recv); // shmem_putmem_nb(recv,xmit,bytes,dest,NULL); shmem_putmem(recv,xmit,bytes,dest); + + if ( CommunicatorPolicy == CommunicatorPolicySequential ) shmem_barrier_all(); } void CartesianCommunicator::SendToRecvFromComplete(std::vector &list) { // shmem_quiet(); // I'm done - shmem_barrier_all();// He's done too + if( CommunicatorPolicy == CommunicatorPolicyConcurrent ) shmem_barrier_all();// He's done too } void CartesianCommunicator::Barrier(void) { @@ -301,13 +310,13 @@ void CartesianCommunicator::Broadcast(int root,void* data, int bytes) int words = bytes/4; if ( shmem_addr_accessible(data,_processor) ){ - shmem_broadcast32(data,data,words,root,0,0,shmem_n_pes(),psync); + shmem_broadcast32(data,data,words,root,0,0,shmem_n_pes(),psync.data()); return; } for(int w=0;wHaloGatherDir(source,XpCompress,Xp,face_idx); this->HaloGatherDir(source,YpCompress,Yp,face_idx); this->HaloGatherDir(source,ZpCompress,Zp,face_idx); diff --git a/lib/util/Init.cc b/lib/util/Init.cc index 639e8506..972cb1a8 100644 --- a/lib/util/Init.cc +++ b/lib/util/Init.cc @@ -390,6 +390,9 @@ void Grid_finalize(void) MPI_Finalize(); Grid_unquiesce_nodes(); #endif +#if defined (GRID_COMMS_SHMEM) + shmem_finalize(); +#endif } void * Grid_backtrace_buffer[_NBACKTRACE];