54 <<
"PstreamGlobals out of sync with UPstream data. Problem."
57 else if (index == MPICommunicators_.size())
61 MPICommunicators_.emplace_back(MPI_COMM_NULL);
66 pendingMPIFree_[index] =
false;
78 PstreamGlobals::DataTypeCountLookupTable::max_size()
79 == (int(UPstream::dataTypes::DataTypes_end)+1),
80 "Data count lookup table size != number of dataTypes enumerations"
84 PstreamGlobals::DataTypeLookupTable::max_size()
85 == (int(UPstream::dataTypes::DataTypes_end)+1),
86 "Lookup table size != number of dataTypes enumerations"
92 #define defineType(Idx, BaseType) \
94 dataTypesCount_[int(UPstream::dataTypes::Idx)] = 1; \
95 MPIdataTypes_[int(UPstream::dataTypes::Idx)] = BaseType; \
108 defineType(type_long_double, MPI_LONG_DOUBLE);
113 #undef defineUserType
114 #define defineUserType(Idx, Count, BaseType, Name) \
116 dataTypesCount_[int(UPstream::dataTypes::Idx)] = Count; \
117 auto& dt = MPIdataTypes_[int(UPstream::dataTypes::Idx)]; \
118 MPI_Type_contiguous(Count, BaseType, &dt); \
119 MPI_Type_set_name(dt, Name); \
120 MPI_Type_commit(&dt); \
131 #undef defineUserType
147 for (; first != last; ++first)
149 if (MPI_DATATYPE_NULL != *first)
151 MPI_Type_free(&(*first));
170 for (; (first != last); ++first)
172 if (MPI_DATATYPE_NULL == *first)
188 (MPI_SUCCESS != MPI_Comm_rank(MPI_COMM_WORLD, &rank))
195 const auto print = [&](
auto firstIndex,
auto lastIndex)
199 PstreamGlobals::MPIdataTypes_.begin() +
int(firstIndex)
203 PstreamGlobals::MPIdataTypes_.begin() +
int(lastIndex)
206 for (; (first != last); ++first)
210 << PstreamGlobals::dataType_name(*first) <<
'\n';
216 std::cerr <<
"enumerated data types:\n";
219 UPstream::dataTypes::Basic_begin,
220 UPstream::dataTypes::Basic_end
226 std::cerr <<
"enumerated user-defined data types:\n";
238 if (MPI_DATATYPE_NULL == datatype)
240 return std::string(
"(null)");
243 char buf[MPI_MAX_OBJECT_NAME];
246 if (MPI_SUCCESS == MPI_Type_get_name(datatype, buf, &len))
250 return std::string(buf, len);
254 return std::string(
"(anon)");
258 return std::string(
"???");
270 "Lookup table size != number of opCodes enumerations"
275 #define defineCode(Idx, CodeType) \
276 MPIopCodes_[int(UPstream::opCodes::Idx)] = CodeType;
310 auto first = MPIopCodes_.
begin();
313 MPIopCodes_.
begin() +
int(UPstream::opCodes::OpCodes_end)
316 for (; (first != last); ++first)
318 if (MPI_OP_NULL == *first)
#define defineType(Idx, BaseType)
#define defineCode(Idx, CodeType)
#define defineUserType(Idx, Count, BaseType, Name)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
T & emplace_back(Args &&... args)
Construct an element at the end of the list, return reference to the new list element.
static constexpr unsigned max_size() noexcept
iterator begin() noexcept
Return an iterator to begin traversing the FixedList.
@ OpCodes_end
(internal use) end marker [all types]
@ Basic_end
(internal use) end marker [basic types]
@ DataTypes_end
(internal use) end marker [all types]
@ User_begin
(internal use) begin marker [user types]
@ User_end
(internal use) end marker [user types]
@ Basic_begin
(internal use) begin marker [basic/all types]
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Ostream & print(Ostream &os, UIntType value, char off='0', char on='1')
Print 0/1 bits in the (unsigned) integral type.
DynamicList< MPI_Request > outstandingRequests_
Outstanding non-blocking operations.
DataTypeCountLookupTable dataTypesCount_
Fundamental count for each valid UPstream::dataTypes entry Indexed by UPstream::dataTypes enum.
std::string dataType_name(MPI_Datatype datatype)
Return MPI internal name for specified MPI_Datatype.
bool checkOpCodes()
Debugging only: check if op code mappings are non-null.
DynamicList< bool > pendingMPIFree_
OpCodesLookupTable MPIopCodes_
MPI operation types, indexed by UPstream::opCodes enum.
DynamicList< MPI_Comm > MPICommunicators_
void initOpCodes()
Create mapping into MPIopCodes_.
void printDataTypes(bool all=false)
Debugging only: print data type names (all or just user-defined).
Foam::FixedList< MPI_Op, 13 > OpCodesLookupTable
void deinitOpCodes()
Free any user-defined op codes.
void deinitDataTypes()
Free any user data types.
Foam::FixedList< MPI_Datatype, 17 > DataTypeLookupTable
Foam::FixedList< int, 17 > DataTypeCountLookupTable
void initDataTypes()
Create mapping into MPIdataTypes_ and define user data types.
bool checkDataTypes()
Debugging only: check if data type mappings are non-null.
void initCommunicator(const label index)
Initialize bookkeeping for MPI communicator index.
DataTypeLookupTable MPIdataTypes_
MPI data types corresponding to fundamental and OpenFOAM types. Indexed by UPstream::dataTypes enum.
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FOAM_UNLIKELY(cond)