15#include <Schema_Comm_Vecteurs.h>
16#include <Comm_Group.h>
17#include <communications.h>
27ArrOfTID Schema_Comm_Vecteurs::tmp_area_tid_;
30bool check_comm_vector =
false;
48 for (
int i = 0; i < n*2; i++)
62 for (
int i = 0; i < min_buf_size; i++)
89 const char* env_var = getenv(
"TRUST_USE_MPI_GPU_AWARE");
94 if (getenv(
"MPICH_GPU_SUPPORT_ENABLED") ==
nullptr)
95 Process::exit(
"You try to enable GPU communications on Cray MPICH with TRUST_USE_MPI_GPU_AWARE=1 but forgot to set also MPICH_GPU_SUPPORT_ENABLED=1 !");
97 std::cerr <<
"[MPI] Enabling GPU capability to communicate between devices." << std::endl;
128#if defined(TRUST_USE_CUDA) && !defined(MPIX_CUDA_AWARE_SUPPORT)
129 Process::exit(
"MPI version is detected as not CUDA-Aware. You can't use TRUST_USE_MPI_GPU_AWARE=1");
151 for (
int i = 0; i < n; i++)
156 Cerr <<
"Error in Schema_Comm_Vecteurs::end_init(): send_size_ and recv_size_ don't match, see log files" << finl;
174 for (i = 0; i < nsend; i++)
182 for (i = 0; i < nrecv; i++)
212 Cerr <<
"Internal error in Schema_Comm_Vecteurs::begin_comm(): buffers already locked by another communication" << finl;
219 char *ptr =
sdata_.buffer_base_;
222 for (
int i = 0; i < nsend; i++)
225 sdata_.buf_pointers_[pe] = ptr;
236 char * ptr =
sdata_.buffer_base_;
241 if ((exchange_type == IsExchangeBlocking::DefaultBlocking)||(exchange_type == IsExchangeBlocking::NonBlockingStart))
252 ptr = addrOnDevice(
sdata_.buffer_base_);
264 assert(nsend + nrecv <=
sdata_.buf_pointers_size_);
265 char ** send_bufs =
sdata_.buf_pointers_;
266 char ** recv_bufs =
sdata_.buf_pointers_ + nsend;
267 for (
int i = 0; i < nsend; i++)
272 for (
int i = 0; i < nrecv; i++)
281 if (exchange_type == IsExchangeBlocking::NonBlockingStart) start_gpu_timer(kernel_name);
287 if ((exchange_type == IsExchangeBlocking::DefaultBlocking)||(exchange_type == IsExchangeBlocking::NonBlockingFinish))
290 if (exchange_type == IsExchangeBlocking::NonBlockingFinish) end_gpu_timer(kernel_name);
292 char * recv_ptr =
sdata_.buffer_base_;
293 for (
int i = 0; i < nsend; i++)
295 for (
int i = 0; i < nrecv; i++)
298 sdata_.buf_pointers_[pe] = recv_ptr;
326 char *ptr =
sdata_.buffer_base_;
332 for (i = 0; i < nsend; i++)
336 char *ptr2 =
sdata_.buf_pointers_[pe];
337 ALIGN_SIZE(ptr2,
sizeof(
double));
340 Cerr <<
"Internal error in Schema_Comm_Vecteurs::check_buffers_full(): send buffer for processor "
341 << pe <<
" is not full" << finl;
348 for (i = 0; i < nsend; i++)
351 for (i = 0; i < nrecv; i++)
355 char *ptr2 =
sdata_.buf_pointers_[pe];
356 ALIGN_SIZE(ptr2,
sizeof(
double));
359 Cerr <<
"Internal error in Schema_Comm_Vecteurs::check_buffers_full(): recv buffer for processor "
360 << pe <<
" has not been read entirely" << finl;
367 Cerr <<
"check_buffers_full: What ?" << finl;
378 assert(byte_size >= 0);
387 char * ptr =
sdata_.buffer_base_;
393 for (i = 0; i < nsend; i++)
396 for (i = 0; i < n; i++)
400 return (
sdata_.buf_pointers_[pe] + byte_size) <= ptr;
: This class describes a group of processors on which
static int check_enabled()
virtual void send_recv_finish() const =0
int nproc() const
Returns the number of processors in the group *this.
virtual void send_recv_start(const ArrOfInt &send_list, const ArrOfInt &send_size, const char *const *const send_buffers, const ArrOfInt &recv_list, const ArrOfInt &recv_size, char *const *const recv_buffers, TypeHint typehint=CHAR) const =0
static const Comm_Group & current_group()
Returns a reference to the current active processor group.
static const Comm_Group & groupe_TRUST()
Returns a reference to the group containing all TRUST processors.
static Sortie & Journal(int message_level=0)
Returns a static Sortie object used as an event journal.
static int nproc()
Returns the number of processors in the current group. See Comm_Group::nproc() and PE_Groups::current...
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
static void barrier()
Synchronizes all processors in the current group (waits until all processors have reached the barrier...
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Static data shared by all Schema_Comm_Vecteur classes, with destructor to free memory at end of execu...
int buffer_base_device_size_
void init(int size, bool bufferOnDevice)
Schema_Comm_Vecteurs_Static_Data()
~Schema_Comm_Vecteurs_Static_Data()
static Schema_Comm_Vecteurs_Static_Data sdata_
static ArrOfDouble tmp_area_double_
int check_next_area(int pe, int byte_size) const
Verifies that there are at least byte_size bytes remaining in the buffer of processor pe.
void end_init()
Once the data to exchange has been declared with add_send/recv_area_..(),.
void begin_init()
Resets buffer sizes.
static ArrOfInt tmp_area_int_
int check_buffers_full() const
Depending on status_, verifies that all buffer pointers point to the end of the buffer allocated for ...
static ArrOfFloat tmp_area_float_
static bool buffer_locked_
void exchange(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")
void begin_comm(bool bufferOnDevice=false)
Starts a new data exchange (buffer sizes must have been initialized with begin_init()....
_SIZE_ size_array() const