28 #define TIMPI_LOG_SCOPE(f,c) 61 _communicator(MPI_COMM_SELF),
69 _max_tag(std::numeric_limits<int>::max()),
75 _communicator(MPI_COMM_SELF),
83 _max_tag(std::numeric_limits<int>::max()),
102 (MPI_Comm_split(this->
get(), color, key, &newcomm));
116 (MPI_Comm_split_type(this->
get(), split_type, key, i, &newcomm));
119 target.
_I_duped_it = (split_type != MPI_UNDEFINED);
127 target.
assign(this->
get());
132 target.assign(this->
get());
145 #ifdef TIMPI_HAVE_MPI 163 #ifdef TIMPI_HAVE_MPI 188 #ifdef TIMPI_HAVE_MPI 195 timpi_assert_greater (i, 0);
196 _size = cast_int<processor_id_type>(i);
201 timpi_assert_greater_equal (i, 0);
202 _rank = cast_int<processor_id_type>(i);
206 timpi_call_mpi(MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_TAG_UB, &maxTag, &flag));
214 _max_tag = std::numeric_limits<int>::max();
224 #ifdef TIMPI_HAVE_MPI 227 if (this->
size() > 1)
229 TIMPI_LOG_SCOPE(
"barrier()",
"Communicator");
230 timpi_call_mpi(MPI_Barrier (this->
get()));
237 #ifdef TIMPI_HAVE_MPI 240 if (this->
size() > 1)
242 TIMPI_LOG_SCOPE(
"nonblocking_barrier()",
"Communicator");
243 timpi_call_mpi(MPI_Ibarrier (this->
get(), req.
get()));
259 timpi_assert_equal_to(
_next_tag, maxval);
286 TIMPI_LOG_SCOPE(
"probe()",
"Communicator");
288 #ifndef TIMPI_HAVE_MPI 289 timpi_not_implemented();
290 ignore(src_processor_id, tag);
295 timpi_assert(src_processor_id < this->
size() ||
299 (MPI_Probe (
int(src_processor_id), tag.
value(), this->
get(), &stat));
307 const unsigned char rnew = r;
308 return this->
verify(rnew);
316 const unsigned char rnew = *r;
320 const unsigned char * rptr =
nullptr;
327 if (this->
size() > 1)
331 std::vector<short int> temp; temp.reserve(r.size());
332 for (std::size_t i=0; i != r.size(); ++i)
333 temp.push_back(r[i]);
334 return this->
verify(temp);
342 if (this->
size() > 1)
344 std::size_t rsize = r ? r->size() : 0;
345 std::size_t * psize = r ? &rsize :
nullptr;
354 std::vector<short int> temp (rsize);
358 for (std::size_t i=0; i != rsize; ++i)
359 temp.push_back((*r)[i]);
362 std::vector<short int> * ptemp = r ? &temp:
nullptr;
372 if (this->
size() > 1)
374 TIMPI_LOG_SCOPE(
"min(bool)",
"Communicator");
376 unsigned int temp = r;
378 (MPI_Allreduce (MPI_IN_PLACE, &temp, 1,
379 StandardType<unsigned int>(),
380 OpFunction<unsigned int>::min(),
388 unsigned int & min_id)
const 390 if (this->
size() > 1)
392 TIMPI_LOG_SCOPE(
"minloc(bool)",
"Communicator");
394 DataPlusInt<int> data_in;
397 data_in.rank = this->
rank();
398 DataPlusInt<int> data_out = data_in;
401 (MPI_Allreduce (&data_in, &data_out, 1,
402 dataplusint_type_acquire<int>().first,
403 OpFunction<int>::min_location(), this->
get()));
405 min_id = data_out.rank;
408 min_id = this->
rank();
414 if (this->
size() > 1)
416 TIMPI_LOG_SCOPE(
"max(bool)",
"Communicator");
418 unsigned int temp = r;
420 (MPI_Allreduce (MPI_IN_PLACE, &temp, 1,
421 StandardType<unsigned int>(),
422 OpFunction<unsigned int>::max(),
430 unsigned int & max_id)
const 432 if (this->
size() > 1)
434 TIMPI_LOG_SCOPE(
"maxloc(bool)",
"Communicator");
436 DataPlusInt<int> data_in;
439 data_in.rank = this->
rank();
440 DataPlusInt<int> data_out = data_in;
443 (MPI_Allreduce (&data_in, &data_out, 1,
444 dataplusint_type_acquire<int>().first,
445 OpFunction<int>::max_location(),
448 max_id = data_out.rank;
451 max_id = this->
rank();
458 if (st ==
"sendreceive")
460 else if (st ==
"alltoall")
462 else if (st !=
"nbx")
463 timpi_error_msg(
"Unrecognized TIMPI sync type " << st);
void send_mode(const SendMode sm)
Explicitly sets the SendMode type used for send operations.
communicator _communicator
void sync_type(const SyncType st)
Explicitly sets the SyncType used for sync operations.
MPI_Info info
Info object used by some MPI-3 methods.
std::map< int, unsigned int > used_tag_values
void minloc(T &r, unsigned int &min_id) const
Take a local variable and replace it with the minimum of it's values on all processors, returning the minimum rank of a processor which originally held the minimum value.
MessageTag get_unique_tag(int tagvalue=MessageTag::invalid_tag) const
Get a tag that is unique to this Communicator.
void barrier() const
Pause execution until all processors reach a certain point.
processor_id_type rank() const
SyncType sync_type() const
Gets the user-requested SyncType.
void clear()
Free and reset this communicator.
void assign(const communicator &comm)
Utility function for setting our member variables from an MPI communicator.
void ignore(const Args &...)
const unsigned int any_source
Processor id meaning "Accept from any source".
Encapsulates the MPI_Comm object.
processor_id_type size() const
static const int invalid_tag
Invalid tag, to allow for default construction.
Encapsulates the MPI tag integers.
void min(const T &r, T &o, Request &req) const
Non-blocking minimum of the local value r into o with the request req.
status probe(const unsigned int src_processor_id, const MessageTag &tag=any_tag) const
Blocking message probe.
void split(int color, int key, Communicator &target) const
Communicator & operator=(const Communicator &)=delete
SyncType
What algorithm to use for parallel synchronization?
void maxloc(T &r, unsigned int &max_id) const
Take a local variable and replace it with the maximum of it's values on all processors, returning the minimum rank of a processor which originally held the maximum value.
timpi_pure bool semiverify(const T *r) const
Check whether a local pointer points to the same value on all processors where it is not null...
void split_by_type(int split_type, int key, info i, Communicator &target) const
Encapsulates the MPI_Request.
timpi_pure bool verify(const T &r) const
Check whether a local variable has the same value on all processors, returning true if it does or fal...
void max(const T &r, T &o, Request &req) const
Non-blocking maximum of the local value r into o with the request req.
DIE A HORRIBLE DEATH HERE typedef MPI_Comm communicator
Communicator object for talking with subsets of processors.
Communicator()
Default Constructor.
void dereference_unique_tag(int tagvalue) const
Dereference an already-acquired tag, and see if we can re-release it.
SendMode send_mode() const
Gets the user-requested SendMode.
void reference_unique_tag(int tagvalue) const
Reference an already-acquired tag, so that we know it will be dereferenced multiple times before we c...
void duplicate(const Communicator &comm)
void nonblocking_barrier(Request &req) const
Start a barrier that doesn't block.