Commit a8f7a0c0 authored by BRAMAS Berenger's avatar BRAMAS Berenger
Browse files

Ensure that MPI::GET TYPE return the correct datatype and not one from a cast...

Ensure that MPI::GET TYPE return the correct datatype and not one from a cast which will cause MPI segfault
parent 1dd6673e
......@@ -265,38 +265,12 @@ public:
// Mpi Types meta function
////////////////////////////////////////////////////////////
static MPI_Datatype GetType(const long long&){
return MPI_LONG_LONG;
}
static MPI_Datatype GetType(const long int&){
return MPI_LONG;
}
static MPI_Datatype GetType(const double&){
return MPI_DOUBLE;
}
static MPI_Datatype GetType(const float&){
return MPI_FLOAT;
}
template <class TypeClass>
static MPI_Datatype GetType();
static MPI_Datatype GetType(const int&){
return MPI_INT;
}
static MPI_Datatype GetType(const char&){
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);
return FMpiComplexe;
template <class TypeClass>
static MPI_Datatype GetType(const TypeClass&){
return GetType<TypeClass>();
}
////////////////////////////////////////////////////////////
......@@ -354,6 +328,49 @@ private:
};
template <>
MPI_Datatype FMpi::GetType<long long>(const long long&){
return MPI_LONG_LONG;
}
template <>
MPI_Datatype FMpi::GetType<long int>(const long int&){
return MPI_LONG;
}
template <>
MPI_Datatype FMpi::GetType<double>(const double&){
return MPI_DOUBLE;
}
template <>
MPI_Datatype FMpi::GetType<float>(const float&){
return MPI_FLOAT;
}
template <>
MPI_Datatype FMpi::GetType<int>(const int&){
return MPI_INT;
}
template <>
MPI_Datatype FMpi::GetType<char>(const char&){
return MPI_CHAR;
}
template <>
MPI_Datatype FMpi::GetType<unsigned char>(const unsigned char&){
return MPI_UNSIGNED_CHAR;
}
template <>
MPI_Datatype FMpi::GetType<FComplex>(const FComplex& a){
MPI_Datatype FMpiComplexe;
MPI_Type_contiguous(2, GetType(a.getReal()) , &FMpiComplexe);
return FMpiComplexe;
}
#endif //FMPI_HPP
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