5 #include "MPI_Object.h"
9 #define tMPIType MPI_Datatype
12 #define tMPIByte MPI_Aint
21 #define tMPICoreId int
24 #define tMPIInteger int
28 #define tMPIBoolean int
31 #define NULL_CORE MPI_PROC_NULL
35 #define tMPIErrorMode MPI_Errhandler
38 #define tMPIComm MPI_Comm
41 #define tMPIView MPI_Datatype
44 #define tMPIStatus MPI_Status
45 #define tMPIRequest MPI_Request
48 #define tMPIOperation MPI_Op
51 #define tMPIIOMode int
54 #define tMPIIOFile MPI_File
57 #define tMPIIOIndex MPI_Offset
78 tBoolean mIsRegistered;
129 inline void registerType() {
130 if (mIsRegistered) unregisterType();
136 inline void unregisterType() {
154 tBoolean ret=(CreateContiguousType<T>(N,mType)==MPI_SUCCESS);
174 const tMPICount& elementSize,
175 const tMPICount& step) {
177 tBoolean ret=(CreateConstantStepType<T>(N,elementSize,step,mType)==MPI_SUCCESS);
192 const tMPICount& elementsNumber,
193 const tMPIByte& stepInOctets,
194 const tMPIType& oldType) {
216 const std::valarray<tMPICount>& elementSizes,
217 const std::valarray<tMPICount>& elementIndices) {
219 tBoolean ret=(CreateVariableStepType<T>(nElements,elementSizes,elementIndices,mType)==MPI_SUCCESS);
237 const std::valarray<tMPICount>& elementSizes,
238 const std::valarray<tMPIByte>& elementOctetIndices,
239 const tMPIType& oldType) {
257 const std::valarray<tMPICount>& elementSizes,
258 const std::valarray<tMPIByte>& elementOctetIndices,
259 const std::valarray<tMPIType>& elementTypes) {
261 tBoolean ret=(
CreateStructType(nElements,elementSizes,elementOctetIndices,elementTypes,mType)==MPI_SUCCESS);
300 switch(typeName[0]) {
320 switch(typeName[5]) {
325 mpiType=MPI_LONG_LONG;
328 mpiType=MPI_LONG_DOUBLE;
333 switch(typeName[9]) {
335 mpiType=MPI_UNSIGNED_CHAR;
338 mpiType=MPI_UNSIGNED_SHORT;
341 mpiType=MPI_UNSIGNED;
344 mpiType=(typeName.length()>14)?MPI_UNSIGNED_LONG_LONG:MPI_UNSIGNED_LONG;
350 "GetVTKType("+typeName+
")",
370 return MPI_Type_contiguous(N,MPI_Type::GetPrimaryType<T>(),&newType);
381 return MPI_Type_contiguous(N,oldType,&newType);
402 const tMPICount& elementSize,
const tMPICount& step,
404 return MPI_Type_vector(nElements,elementSize,step,MPI_Type::GetPrimaryType<T>(),&newType);
417 const tMPICount& elementSize,
const tMPICount& step,
418 const tMPIType& oldType,
420 return MPI_Type_vector(nElements,elementSize,step,oldType,&newType);
435 const tMPICount& elementsNumber,
436 const tMPIByte& stepInOctets,
437 const tMPIType& oldType,
439 return MPI_Type_create_hvector(nElements,elementsNumber,stepInOctets,oldType,&newType);
459 const std::valarray<tMPICount>& elementSizes,
460 const std::valarray<tMPICount>& elementIndices,
462 return MPI_Type_indexed(nElements,
465 MPI_Type::GetPrimaryType<T>(),
483 const std::valarray<tMPICount>& elementSizes,
484 const std::valarray<tMPIByte>& elementOctetIndices,
485 const tMPIType& oldType,
487 return MPI_Type_create_hindexed(nElements,&elementSizes[0],&elementOctetIndices[0],oldType,&newType);
502 const std::valarray<tMPICount>& elementSizes,
503 const std::valarray<tMPIByte>& elementOctetIndices,
504 const std::valarray<tMPIType>& elementTypes,
506 return MPI_Type_create_struct(nElements,&elementSizes[0],&elementOctetIndices[0],&elementTypes[0],&newType);
517 template<
typename T,tUCInt N>
519 const std::array<tInteger,N>& Ns,
520 std::array<MPI_Type,N>& faceTypes) {
526 MPI_Type::GetSize<T>(mpiSizeOfT);
531 faceTypes[0].template createContiguousType<T>(dim);
535 faceTypes[1].template createContiguousType<T>(dim*Ns[0]);
537 faceTypes[0].template createConstantStepType<T>(Ns[1],dim,Ns[0]*dim);
542 faceTypes[2].template createContiguousType<T>(dim*Ns[0]*Ns[1]);
548 MPI_Type::CreateContiguousType<tReal>(Ns[0]*dim,tILine);
550 MPI_Type::CreateConstantStepType<tReal>(Ns[1],dim,Ns[0]*dim,tJLine);
555 faceTypes[1].createConstantOctetStepType(Ns[2],1,dim*Ns[0]*Ns[1]*mpiSizeOfT,tILine);
558 faceTypes[0].createConstantOctetStepType(Ns[2],1,dim*Ns[0]*Ns[1]*mpiSizeOfT,tJLine);
578 inline static tMPIError
Resize(
const tMPIType dataType,
580 const tMPIByte& extent,
581 tMPIType& newDataType) {
582 return MPI_Type_create_resized(dataType,lb,extent,&newDataType);
593 return MPI_Type_commit(&type);
599 return MPI_Type_free(&type);
613 inline static tMPIError
GetSize(
int& mpiSize) {
614 return MPI_Type_size(MPI_Type::GetPrimaryType<T>(),&mpiSize);
621 inline static tMPIError
GetSize(
const tMPIType& mpiType,
int& mpiSize) {
622 return MPI_Type_size(mpiType,&mpiSize);
630 inline static tMPIError
GetExtent(
const tMPIType& mpiType,tMPIByte& start,tMPIByte& mpiSize) {
631 return MPI_Type_get_extent(mpiType,&start,&mpiSize);
640 inline static tMPIError
GetExtent(tMPIByte& start,tMPIByte& mpiSize) {
641 return MPI_Type_get_extent(GetPrimaryType<T>(),&start,&mpiSize);
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:17
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
This class is a base class of E-MicromM core package.
Definition: MPI_Object.h:32
This class is a base class of E-MicromM core package.
Definition: MPI_Type.h:67
static tMPIError CreateContiguousType(const tMPICount &N, const tMPIType &oldType, tMPIType &newType)
create a MPI array type of size N
Definition: MPI_Type.h:380
tBoolean createVariableStepType(const tMPICount &nElements, const std::valarray< tMPICount > &elementSizes, const std::valarray< tMPICount > &elementIndices)
create a variable step data type
Definition: MPI_Type.h:215
static tMPIError Unregister(tMPIType &type)
unregister the type
Definition: MPI_Type.h:598
static tMPIError CreateVariableStepType(const tMPICount &nElements, const std::valarray< tMPICount > &elementSizes, const std::valarray< tMPICount > &elementIndices, tMPIType &newType)
create a variable step data type
Definition: MPI_Type.h:458
static tMPIError CreateContiguousType(const tMPICount &N, tMPIType &newType)
create a MPI array type of size N
Definition: MPI_Type.h:369
tBoolean createConstantStepType(const tMPICount &N, const tMPICount &elementSize, const tMPICount &step)
create a constant step data type
Definition: MPI_Type.h:173
tBoolean createContiguousType(const tMPICount &N)
create a MPI array type of size N
Definition: MPI_Type.h:152
static tMPIError CreateConstantStepType(const tMPICount &nElements, const tMPICount &elementSize, const tMPICount &step, tMPIType &newType)
create a constant step data type
Definition: MPI_Type.h:401
static tMPIError Resize(const tMPIType dataType, const tMPIByte &lb, const tMPIByte &extent, tMPIType &newDataType)
resize the type
Definition: MPI_Type.h:578
static tMPIError GetSize(int &mpiSize)
get the mpi size of a type in octet
Definition: MPI_Type.h:613
static tMPIError GetExtent(tMPIByte &start, tMPIByte &mpiSize)
get the mpi size (in octet) of the element including the alignment
Definition: MPI_Type.h:640
static tMPIError Register(tMPIType &type)
register the type
Definition: MPI_Type.h:592
static tMPIType GetPrimaryType()
get the MPI type of the template type T
Definition: MPI_Type.h:289
static tMPIError CreateStructType(const tMPICount &nElements, const std::valarray< tMPICount > &elementSizes, const std::valarray< tMPIByte > &elementOctetIndices, const std::valarray< tMPIType > &elementTypes, tMPIType &newType)
create a structure type
Definition: MPI_Type.h:501
tBoolean createVariableOctetStepType(const tMPICount &nElements, const std::valarray< tMPICount > &elementSizes, const std::valarray< tMPIByte > &elementOctetIndices, const tMPIType &oldType)
create a variable step data type
Definition: MPI_Type.h:236
const tMPIType & getType() const
get the type
Definition: MPI_Type.h:274
static tMPIError GetSize(const tMPIType &mpiType, int &mpiSize)
get the mpi size of a type in octets
Definition: MPI_Type.h:621
static tMPIError GetExtent(const tMPIType &mpiType, tMPIByte &start, tMPIByte &mpiSize)
get the mpi size (in octet) between the first element (in octet) and the last element of the mpi type...
Definition: MPI_Type.h:630
static tMPIType GetPrimaryType(const tString &typeName)
get the primary MPI type of the template type
Definition: MPI_Type.h:297
static void CreateFaceTypes(const tUCInt &dim, const std::array< tInteger, N > &Ns, std::array< MPI_Type, N > &faceTypes)
create a face types of element element of type T
Definition: MPI_Type.h:518
MPI_Type(void)
create
Definition: MPI_Type.h:86
tBoolean createStructType(const tMPICount &nElements, const std::valarray< tMPICount > &elementSizes, const std::valarray< tMPIByte > &elementOctetIndices, const std::valarray< tMPIType > &elementTypes)
create a structure type
Definition: MPI_Type.h:256
static tMPIError CreateConstantOctetStepType(const tMPICount &nElements, const tMPICount &elementsNumber, const tMPIByte &stepInOctets, const tMPIType &oldType, tMPIType &newType)
create a constant step data type
Definition: MPI_Type.h:434
virtual ~MPI_Type(void)
destroy
Definition: MPI_Type.h:97
virtual tMemSize getContentsMemorySize() const override
return the memory size of the included associations
Definition: MPI_Type.h:119
static tMPIError CreateConstantStepType(const tMPICount &nElements, const tMPICount &elementSize, const tMPICount &step, const tMPIType &oldType, tMPIType &newType)
create a constant step data type
Definition: MPI_Type.h:416
virtual tMemSize getMemorySize() const override
return the memory size of the class
Definition: MPI_Type.h:107
static tMPIError CreateVariableOctetStepType(const tMPICount &nElements, const std::valarray< tMPICount > &elementSizes, const std::valarray< tMPIByte > &elementOctetIndices, const tMPIType &oldType, tMPIType &newType)
create a variable step data type
Definition: MPI_Type.h:482
tBoolean createConstantOctetStepType(const tMPICount &nElements, const tMPICount &elementsNumber, const tMPIByte &stepInOctets, const tMPIType &oldType)
create a constant step data type
Definition: MPI_Type.h:191