Skip to content
Snippets Groups Projects
Commit a36ede17 authored by Markus Blatt's avatar Markus Blatt
Browse files

Make Generic_MPI_Datatype deprecated in favor of MPI_Datatype.

[[Imported from SVN: r6269]]
parent d501004f
No related branches found
No related tags found
No related merge requests found
......@@ -13,10 +13,12 @@
#include <algorithm>
#include <functional>
#include "deprecated.hh"
#include "exceptions.hh"
#include "collectivecommunication.hh"
#include "binaryfunctions.hh"
#include "shared_ptr.hh"
#include "mpitraits.hh"
#if HAVE_MPI
// MPI header
......@@ -24,6 +26,7 @@
namespace Dune
{
//=======================================================
// use singleton pattern and template specialization to
// generate MPI data types
......@@ -35,7 +38,7 @@ namespace Dune
class Generic_MPI_Datatype
{
public:
static MPI_Datatype get ()
static MPI_Datatype get() DUNE_DEPRECATED
{
if (!type)
{
......@@ -59,7 +62,7 @@ namespace Dune
template<> \
class Generic_MPI_Datatype<p>{ \
public: \
static inline MPI_Datatype get(){ \
static inline MPI_Datatype get() DUNE_DEPRECATED { \
return m; \
} \
}
......@@ -79,7 +82,6 @@ namespace Dune
#undef ComposeMPITraits
//=======================================================
// use singleton pattern and template specialization to
// generate MPI operations
......@@ -295,15 +297,15 @@ namespace Dune
template<typename T>
int broadcast (T* inout, int len, int root) const
{
return MPI_Bcast(inout,len,Generic_MPI_Datatype<T>::get(),root,communicator);
return MPI_Bcast(inout,len,MPITraits<T>::getType(),root,communicator);
}
//! @copydoc CollectiveCommunication::gather()
template<typename T>
int gather (T* in, T* out, int len, int root) const // note out must have space for P*len elements
{
return MPI_Gather(in,len,Generic_MPI_Datatype<T>::get(),
out,len,Generic_MPI_Datatype<T>::get(),
return MPI_Gather(in,len,MPITraits<T>::getType(),
out,len,MPITraits<T>::getType(),
root,communicator);
}
......@@ -325,7 +327,7 @@ namespace Dune
template<typename BinaryFunction, typename Type>
int allreduce(Type* in, Type* out, int len) const
{
return MPI_Allreduce(in, out, len, Generic_MPI_Datatype<Type>::get(),
return MPI_Allreduce(in, out, len, MPITraits<Type>::getType(),
Generic_MPI_Op<Type, BinaryFunction>::get(),communicator);
}
......
......@@ -19,6 +19,8 @@ namespace Dune
* @brief Traits classes for mapping types onto MPI_Datatype.
* @author Markus Blatt
*/
#if HAVE_MPI
/**
* @brief A traits class describing the mapping of types onto MPI_Datatypes.
*
......@@ -30,7 +32,25 @@ namespace Dune
*/
template<typename T>
struct MPITraits
{};
{
private:
MPITraits(){}
MPITraits(const MPITraits&){}
static MPI_Datatype datatype;
static MPI_Datatype vectortype;
public:
static inline MPI_Datatype getType()
{
if(datatype==MPI_DATATYPE_NULL) {
MPI_Type_contiguous(sizeof(T),MPI_BYTE,&datatype);
MPI_Type_commit(&datatype);
}
return datatype;
}
};
template<class T>
MPI_Datatype MPITraits<T>::datatype = MPI_DATATYPE_NULL;
#ifndef DOXYGEN
#if HAVE_MPI
......@@ -169,7 +189,7 @@ namespace Dune
MPI_Datatype MPITraits<std::pair<T1,T2> >::type=MPI_DATATYPE_NULL;
#endif
#endif
#endif
/** @} */
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment