Commit 4b74b16f authored by Martin Bauer's avatar Martin Bauer
Browse files

Merge branch 'mpitrait' into 'master'

Don’t call MPI_Type_free after MPI_Finalize

See merge request walberla/walberla!106
parents 818a5074 7934e8f5
......@@ -1839,3 +1839,30 @@ namespace mpi {
};
}
}
//======================================================================================================================
//
// MPI Datatype
//
//======================================================================================================================
namespace walberla {
template< typename T>
struct MPITrait< Matrix3<T> >
{
static inline MPI_Datatype type()
{
// cannot use mpi::Datatype here because its destructor calls MPI_Type_free and static variables are destroyed after the MPI_Finalize
static MPI_Datatype datatype;
static bool initialized = false;
if( ! initialized ) {
MPI_Type_contiguous(9, MPITrait<T>::type(), &datatype );
MPI_Type_commit( &datatype );
initialized = true;
}
return datatype;
}
};
} // namespace walberla
......@@ -1696,13 +1696,13 @@ namespace walberla {
{
static inline MPI_Datatype type()
{
static mpi::Datatype datatype;
// cannot use mpi::Datatype here because its destructor calls MPI_Type_free and static variables are destroyed after the MPI_Finalize
static MPI_Datatype datatype;
static bool initialized = false;
if( ! initialized ) {
MPI_Datatype newDatatype;
MPI_Type_contiguous(2, MPITrait<T>::type(), &newDatatype );
datatype.init( newDatatype );
MPI_Type_contiguous(2, MPITrait<T>::type(), &datatype );
MPI_Type_commit( &datatype );
initialized = true;
}
return datatype;
......
......@@ -1895,13 +1895,13 @@ namespace walberla {
{
static inline MPI_Datatype type()
{
static mpi::Datatype datatype;
// cannot use mpi::Datatype here because its destructor calls MPI_Type_free and static variables are destroyed after the MPI_Finalize
static MPI_Datatype datatype;
static bool initialized = false;
if( ! initialized ) {
MPI_Datatype newDatatype;
MPI_Type_contiguous(3, MPITrait<T>::type(), &newDatatype );
datatype.init( newDatatype );
MPI_Type_contiguous(3, MPITrait<T>::type(), &datatype );
MPI_Type_commit( &datatype );
initialized = true;
}
return datatype;
......
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