Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 95094e4b authored by BRAMAS Berenger's avatar BRAMAS Berenger
Browse files

update mpi packing

parent f60f896f
No related branches found
No related tags found
No related merge requests found
......@@ -101,7 +101,7 @@ public :
FAssertLF(currentIndex < std::numeric_limits<int>::max());
int previousIndex = int(currentIndex);
ClassType value;
FMpi::Assert(MPI_Unpack(array.get(),int(arrayCapacity),&previousIndex,&value,1,FMpi::GetType(value),comm), __LINE__);
FMpi::Assert(MPI_Unpack(array.get(),int(arrayCapacity),&previousIndex,&value,FMpi::GetTypeCount(value),FMpi::GetType(value),comm), __LINE__);
seek(FSize(sizeof(value) + currentIndex));
FAssertLF(previousIndex == currentIndex);
return value;
......@@ -114,7 +114,7 @@ public :
FAssertLF(arrayCapacity < std::numeric_limits<int>::max());
FAssertLF(ind < std::numeric_limits<int>::max());
int previousIndex = int(ind);
FMpi::Assert(MPI_Unpack(array.get(),int(arrayCapacity),&previousIndex,&value,1,FMpi::GetType(value),comm), __LINE__);
FMpi::Assert(MPI_Unpack(array.get(),int(arrayCapacity),&previousIndex,&value,FMpi::GetTypeCount(value),FMpi::GetType(value),comm), __LINE__);
seek(FSize(sizeof(value)+ind));
FAssertLF(previousIndex == currentIndex);
return value;
......@@ -126,7 +126,7 @@ public :
FAssertLF(arrayCapacity < std::numeric_limits<int>::max());
FAssertLF(currentIndex < std::numeric_limits<int>::max());
int previousIndex = int(currentIndex);
FMpi::Assert(MPI_Unpack(array.get(),int(arrayCapacity),&previousIndex,inValue,1,FMpi::GetType(*inValue),comm), __LINE__);
FMpi::Assert(MPI_Unpack(array.get(),int(arrayCapacity),&previousIndex,inValue,FMpi::GetTypeCount(*inValue),FMpi::GetType(*inValue),comm), __LINE__);
seek(FSize(sizeof(ClassType) + currentIndex));
FAssertLF(previousIndex == currentIndex);
}
......@@ -138,7 +138,7 @@ public :
FAssertLF(currentIndex < std::numeric_limits<int>::max());
FAssertLF(inSize < std::numeric_limits<int>::max());
int previousIndex = int(currentIndex);
FMpi::Assert(MPI_Unpack(array.get(),int(arrayCapacity),&previousIndex,inArray,int(inSize),FMpi::GetType(*inArray),comm), __LINE__);
FMpi::Assert(MPI_Unpack(array.get(),int(arrayCapacity),&previousIndex,inArray,int(inSize)*FMpi::GetTypeCount(*inArray),FMpi::GetType(*inArray),comm), __LINE__);
seek(FSize(sizeof(ClassType) * inSize + currentIndex));
FAssertLF(previousIndex == currentIndex);
}
......
......@@ -100,7 +100,7 @@ public:
expandIfNeeded(sizeof(ClassType));
FAssertLF(currentIndex < std::numeric_limits<int>::max());
int intCurrentIndex = int(currentIndex);
FMpi::Assert(MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), int(arrayCapacity), &intCurrentIndex, mpiComm), __LINE__);
FMpi::Assert(MPI_Pack(const_cast<ClassType*>(&object), FMpi::GetTypeCount(object), FMpi::GetType(object), array.get(), int(arrayCapacity), &intCurrentIndex, mpiComm), __LINE__);
currentIndex = intCurrentIndex;
}
......@@ -112,7 +112,7 @@ public:
expandIfNeeded(sizeof(ClassType));
FAssertLF(arrayCapacity < std::numeric_limits<int>::max());
int intCurrentIndex = int(currentIndex);
FMpi::Assert(MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), int(arrayCapacity), &intCurrentIndex, mpiComm), __LINE__);
FMpi::Assert(MPI_Pack(const_cast<ClassType*>(&object), FMpi::GetTypeCount(object), FMpi::GetType(object), array.get(), int(arrayCapacity), &intCurrentIndex, mpiComm), __LINE__);
currentIndex = intCurrentIndex;
}
......@@ -123,7 +123,7 @@ public:
FAssertLF(arrayCapacity < std::numeric_limits<int>::max());
FAssertLF(position < std::numeric_limits<int>::max());
int noConstPosition = int(position);
FMpi::Assert(MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), int(arrayCapacity), &noConstPosition, mpiComm), __LINE__);
FMpi::Assert(MPI_Pack(const_cast<ClassType*>(&object), FMpi::GetTypeCount(object), FMpi::GetType(object), array.get(), int(arrayCapacity), &noConstPosition, mpiComm), __LINE__);
}
/** Write an array
......@@ -135,7 +135,7 @@ public:
FAssertLF(arrayCapacity < std::numeric_limits<int>::max());
FAssertLF(inSize < std::numeric_limits<int>::max());
int intCurrentIndex = int(currentIndex);
FMpi::Assert(MPI_Pack( const_cast<ClassType*>(objects), int(inSize), FMpi::GetType(*objects), array.get(), int(arrayCapacity), &intCurrentIndex, mpiComm), __LINE__);
FMpi::Assert(MPI_Pack( const_cast<ClassType*>(objects), int(inSize)*FMpi::GetTypeCount(*objects), FMpi::GetType(*objects), array.get(), int(arrayCapacity), &intCurrentIndex, mpiComm), __LINE__);
currentIndex = intCurrentIndex;
}
......
......@@ -315,43 +315,67 @@ public:
static MPI_Datatype GetType(const long long&){
return MPI_LONG_LONG;
}
static int GetTypeCount(const long long&){
return 1;
}
/// Get the MPI datatype corresponding to a variable.
static MPI_Datatype GetType(const long int&){
return MPI_LONG;
}
static int GetTypeCount(const long int&){
return 1;
}
/// Get the MPI datatype corresponding to a variable.
static MPI_Datatype GetType(const double&){
return MPI_DOUBLE;
}
static int GetTypeCount(const double&){
return 1;
}
/// Get the MPI datatype corresponding to a variable.
static MPI_Datatype GetType(const float&){
return MPI_FLOAT;
}
static int GetTypeCount(const float&){
return 1;
}
/// Get the MPI datatype corresponding to a variable.
static MPI_Datatype GetType(const int&){
return MPI_INT;
}
static int GetTypeCount(const int&){
return 1;
}
/// Get the MPI datatype corresponding to a variable.
static MPI_Datatype GetType(const char&){
return MPI_CHAR;
}
static int GetTypeCount(const char&){
return 1;
}
/// Get the MPI datatype corresponding to a variable.
static MPI_Datatype GetType(const unsigned char&){
return MPI_UNSIGNED_CHAR;
}
static int GetTypeCount(const unsigned char&){
return 1;
}
/// Get the MPI datatype corresponding to a variable.
template <class FReal>
static MPI_Datatype GetType(const FComplex<FReal>& a){
MPI_Datatype FMpiComplexe;
MPI_Type_contiguous(2, GetType(a.getReal()) , &FMpiComplexe);
return FMpiComplexe;
return GetType(a.getReal());
}
template <class FReal>
static int GetTypeCount(const FComplex<FReal>& a){
return 2;
}
////////////////////////////////////////////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment