Commit 1dd6673e authored by BRAMAS Berenger's avatar BRAMAS Berenger
Browse files

Check the error retured by MPI_Pack in mpi reader writer buffers

parent 43fcf1ff
......@@ -101,7 +101,7 @@ public :
ClassType value;
int previousIndex = currentIndex;
seek(int(sizeof(value) + previousIndex));
MPI_Unpack(array.get(),arrayCapacity,&previousIndex,&value,1,FMpi::GetType(value),comm);
FMpi::Assert(MPI_Unpack(array.get(),arrayCapacity,&previousIndex,&value,1,FMpi::GetType(value),comm), __LINE__);
return value;
}
......@@ -111,7 +111,7 @@ public :
ClassType value;
int previousIndex = ind;
seek(int(sizeof(value)+ind));
MPI_Unpack(array.get(),arrayCapacity,&previousIndex,&value,1,FMpi::GetType(value),comm);
FMpi::Assert(MPI_Unpack(array.get(),arrayCapacity,&previousIndex,&value,1,FMpi::GetType(value),comm), __LINE__);
return value;
}
......@@ -120,7 +120,7 @@ public :
void fillValue(ClassType* const inValue){
int previousIndex = currentIndex;
seek(int(sizeof(ClassType) + previousIndex));
MPI_Unpack(array.get(),arrayCapacity,&previousIndex,inValue,1,FMpi::GetType(*inValue),comm);
FMpi::Assert(MPI_Unpack(array.get(),arrayCapacity,&previousIndex,inValue,1,FMpi::GetType(*inValue),comm), __LINE__);
}
/** Fill one/many value(s) with memcpy */
......@@ -128,7 +128,7 @@ public :
void fillArray(ClassType* const inArray, const int inSize){
int previousIndex = currentIndex;
seek(int(sizeof(ClassType) * inSize + previousIndex));
MPI_Unpack(array.get(),arrayCapacity,&previousIndex,inArray,inSize,FMpi::GetType(*inArray),comm);
FMpi::Assert(MPI_Unpack(array.get(),arrayCapacity,&previousIndex,inArray,inSize,FMpi::GetType(*inArray),comm), __LINE__);
}
/** Same as fillValue */
......
......@@ -98,7 +98,7 @@ public:
template <class ClassType>
void write(const ClassType& object){
expandIfNeeded(sizeof(ClassType));
MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), arrayCapacity, &currentIndex, mpiComm);
FMpi::Assert(MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), arrayCapacity, &currentIndex, mpiComm), __LINE__);
}
/**
......@@ -107,7 +107,7 @@ public:
template <class ClassType>
void write(const ClassType&& object){
expandIfNeeded(sizeof(ClassType));
MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), arrayCapacity, &currentIndex, mpiComm);
FMpi::Assert(MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), arrayCapacity, &currentIndex, mpiComm), __LINE__);
}
/** Write back, position + sizeof(object) has to be < size */
......@@ -115,7 +115,7 @@ public:
void writeAt(const int position, const ClassType& object){
FAssertLF(int(position + sizeof(ClassType)) <= currentIndex)
int noConstPosition = position;
MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), arrayCapacity, &noConstPosition, mpiComm);
FMpi::Assert(MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), arrayCapacity, &noConstPosition, mpiComm), __LINE__);
}
/** Write an array
......@@ -124,7 +124,7 @@ public:
template <class ClassType>
void write(const ClassType* const objects, const int inSize){
expandIfNeeded(sizeof(ClassType) * inSize);
MPI_Pack( const_cast<ClassType*>(objects), inSize, FMpi::GetType(*objects), array.get(), arrayCapacity, &currentIndex, mpiComm);
FMpi::Assert(MPI_Pack( const_cast<ClassType*>(objects), inSize, FMpi::GetType(*objects), array.get(), arrayCapacity, &currentIndex, mpiComm), __LINE__);
}
/** Equivalent to write */
......
......@@ -289,6 +289,10 @@ public:
return MPI_CHAR;
}
static MPI_Datatype GetType(const unsigned char&){
return MPI_UNSIGNED_CHAR;
}
static MPI_Datatype GetType(const FComplex& a){
MPI_Datatype FMpiComplexe;
MPI_Type_contiguous(2, GetType(a.getReal()) , &FMpiComplexe);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment