MeDiPack  1.3.0
A Message Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
medi::MpiTypeInterface Class Referenceabstract

Wrapper interface for MPI types in communications. More...

#include <typeInterface.hpp>

Inheritance diagram for medi::MpiTypeInterface:

Public Types

typedef void AdjointType
 
typedef void IndexType
 The type of the identifiers for the AD tool.
 
typedef void ModifiedType
 The type of the modified buffer data which is send over the network.
 
typedef void PrimalType
 The type of the floating point values which are handled by the AD tool.
 
typedef void Type
 The type of the user data which is represented by this interface.
 

Public Member Functions

virtual void clearIndices (void *buf, size_t bufOffset, int elements) const =0
 Clear the AD types in the buffer such that they can be overwritten.
 
virtual MpiTypeInterfaceclone () const =0
 Creates a clone of the mpi type also calling MPI_Type_dub.
 
virtual int computeActiveElements (const int count) const =0
 Get the number of active elements that are contained in count versions of the type.
 
virtual void copy (void *from, size_t fromOffset, void *to, size_t toOffset, int count) const =0
 Copy the elements of one buffer into the other.
 
virtual void copyFromModifiedBuffer (void *buf, size_t bufOffset, const void *bufMod, size_t bufModOffset, int elements) const =0
 Copy all data from the modified buffer and perform the special handling for the AD type.
 
virtual void copyIntoModifiedBuffer (const void *buf, size_t bufOffset, void *bufMod, size_t bufModOffset, int elements) const =0
 Copy all data into the modified buffer and perform the special handling for the AD type.
 
virtual void createIndices (void *buf, size_t bufOffset, void *indices, size_t bufModOffset, int elements) const =0
 Create indices for a reciving buffer if necessary.
 
virtual void createModifiedTypeBuffer (void *&buf, size_t size) const =0
 Create a temporary buffer of the modified type that this interface represents.
 
virtual void createTypeBuffer (void *&buf, size_t size) const =0
 Create a temporary buffer of the type that this interface represents.
 
virtual void deleteModifiedTypeBuffer (void *&buf) const =0
 Delete the temporary buffer for the modified types.
 
virtual void deleteTypeBuffer (void *&buf, size_t size) const =0
 Delete the temporary buffer.
 
virtual void freeType (Type *buf, size_t bufOffset, int elements) const =0
 Destroy the types in the buffer.
 
virtual const ADToolInterfacegetADTool () const =0
 Get the AD tool that handled the AD specifics.
 
virtual void getIndices (const void *buf, size_t bufOffset, void *indices, size_t bufModOffset, int elements) const =0
 Get all the AD identifiers from all AD types in the buffer.
 
MPI_Datatype getModifiedMpiType () const
 Return the MPI type for the modified data.
 
MPI_Datatype getMpiType () const
 Return the MPI type for the data that this interface represents.
 
virtual void getValues (const void *buf, size_t bufOffset, void *primals, size_t bufModOffset, int elements) const =0
 Get the primal values from the AD types.
 
virtual void initializeType (Type *buf, size_t bufOffset, int elements) const =0
 Initialize the types in the buffer.
 
virtual bool isModifiedBufferRequired () const =0
 Tell the functions if the underlying AD tool requires new send/recv buffers or if the original buffers can be used.
 
 MpiTypeInterface (MPI_Datatype mpiType, MPI_Datatype modifiedMpiType)
 Wrapper interface for MPI types in communications. See the class description for details.
 
virtual void performReduce (void *buf, void *target, int count, AMPI_Op op, int ranks) const =0
 Perform a local reduce operation.
 
virtual void registerValue (void *buf, size_t bufOffset, void *indices, void *oldPrimals, size_t bufModOffset, int elements) const =0
 Register all the AD values on the new machine.
 
virtual ~MpiTypeInterface ()
 Virtual destructor.
 

Protected Member Functions

void setMpiTypes (MPI_Datatype mpiType, MPI_Datatype modifiedMpiType)
 Helper method for extending classes to set the types after the initial construction.
 

Detailed Description

Wrapper interface for MPI types in communications.

The interface defines several functions for MeDiPack to decide if a buffer with this type requires special handling for AD. If the represented type is no AD type, then the normal MPI functions are called without touching the buffer.

If the type is an AD type, then the required data for AD is extracted from the buffer such that the forward or reverse mode of AD can be executed. There are two types of operation which the AD tool can use:

The first one does not modify the buffer generated by the user. The buffer is send as it is, only the data for the AD types might be modified such that the receiving site can use the buffer again.

The second operation mode creates a new buffer and all data from the user generated buffer is copied into the new buffer. For each AD type the data is replaced with the required data from the AD tool.

This interface can be implemented to support custom data types from the user. See the implementation of an AD tool or the handling of the constructed data types for details.

Member Typedef Documentation

◆ AdjointType

◆ IndexType

The type of the identifiers for the AD tool.

◆ ModifiedType

The type of the modified buffer data which is send over the network.

The buffer is modified by the AD tool if requested.

◆ PrimalType

The type of the floating point values which are handled by the AD tool.

◆ Type

The type of the user data which is represented by this interface.

Constructor & Destructor Documentation

◆ MpiTypeInterface()

medi::MpiTypeInterface::MpiTypeInterface ( MPI_Datatype mpiType,
MPI_Datatype modifiedMpiType )
inline

Wrapper interface for MPI types in communications. See the class description for details.

Parameters
[in]mpiTypeThe MPI type for the data.
[in]modifiedMpiTypeThe MPI type for the modified data.

◆ ~MpiTypeInterface()

virtual medi::MpiTypeInterface::~MpiTypeInterface ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

◆ clearIndices()

virtual void medi::MpiTypeInterface::clearIndices ( void * buf,
size_t bufOffset,
int elements ) const
pure virtual

Clear the AD types in the buffer such that they can be overwritten.

Parameters
[in]bufThe original buffer provided by the user.
[in]bufOffsetThe offset into the original buffer, as provided by the user.
[in]elementsThe number of elements that should be copied.

Implemented in medi::MpiStructType, medi::MpiTypeBase< Impl, TypeB, ModifiedTypeB, ADToolB >, medi::MpiTypeBase< MpiTypeDefault< ADTool >, ADTool::Type, ADTool::ModifiedType, ADTool >, and medi::MpiTypeBase< MpiTypePassive< T >, T, T, ADToolPassive >.

◆ clone()

virtual MpiTypeInterface * medi::MpiTypeInterface::clone ( ) const
pure virtual

Creates a clone of the mpi type also calling MPI_Type_dub.

Returns
The cloned interface.

Implemented in medi::MpiStructType, medi::MpiTypeDefault< ADTool >, and medi::MpiTypePassive< T >.

◆ computeActiveElements()

virtual int medi::MpiTypeInterface::computeActiveElements ( const int count) const
pure virtual

Get the number of active elements that are contained in count versions of the type.

Parameters
[in]countThe number of times this type is contained in the buffer.
Returns
The number of active elements in the buffer.

Implemented in medi::MpiStructType, medi::MpiTypeDefault< ADTool >, medi::MpiTypeBase< Impl, TypeB, ModifiedTypeB, ADToolB >, medi::MpiTypeBase< MpiTypeDefault< ADTool >, ADTool::Type, ADTool::ModifiedType, ADTool >, medi::MpiTypeBase< MpiTypePassive< T >, T, T, ADToolPassive >, and medi::MpiTypePassive< T >.

◆ copy()

virtual void medi::MpiTypeInterface::copy ( void * from,
size_t fromOffset,
void * to,
size_t toOffset,
int count ) const
pure virtual

Copy the elements of one buffer into the other.

Parameters
[in]fromThe original buffer provided by the user.
[in]fromOffsetThe offset into the original buffer.
[out]toThe target buffer for the data.
[in]toOffsetThe offset for the target buffer.
[in]countThe number of elements that should be copied.

Implemented in medi::MpiStructType, medi::MpiTypeBase< Impl, TypeB, ModifiedTypeB, ADToolB >, medi::MpiTypeBase< MpiTypeDefault< ADTool >, ADTool::Type, ADTool::ModifiedType, ADTool >, and medi::MpiTypeBase< MpiTypePassive< T >, T, T, ADToolPassive >.

◆ copyFromModifiedBuffer()

virtual void medi::MpiTypeInterface::copyFromModifiedBuffer ( void * buf,
size_t bufOffset,
const void * bufMod,
size_t bufModOffset,
int elements ) const
pure virtual

Copy all data from the modified buffer and perform the special handling for the AD type.

The data for the AD types is modified such that it can be used on the new machine.

Parameters
[in]bufThe original buffer provided by the user.
[in]bufOffsetThe offset into the original buffer, as provided by the user.
[out]bufModThe buffer with the modified data.
[in]bufModOffsetThe linearized displacement for the modified buffer. These displacements are contiunous and do not contain any holes.
[in]elementsThe number of elements that should be copied.

Implemented in medi::MpiStructType, medi::MpiTypeBase< Impl, TypeB, ModifiedTypeB, ADToolB >, medi::MpiTypeBase< MpiTypeDefault< ADTool >, ADTool::Type, ADTool::ModifiedType, ADTool >, and medi::MpiTypeBase< MpiTypePassive< T >, T, T, ADToolPassive >.

◆ copyIntoModifiedBuffer()

virtual void medi::MpiTypeInterface::copyIntoModifiedBuffer ( const void * buf,
size_t bufOffset,
void * bufMod,
size_t bufModOffset,
int elements ) const
pure virtual

Copy all data into the modified buffer and perform the special handling for the AD type.

The data for the AD types is modified such that it can be send over the network.

Parameters
[in]bufThe original buffer provided by the user.
[in]bufOffsetThe offset into the original buffer, as provided by the user.
[out]bufModThe new buffer for the modified data.
[in]bufModOffsetThe linearized displacement for the modified buffer. These displacements are continuous and do not contain any holes.
[in]elementsThe number of elements that should be copied.

Implemented in medi::MpiStructType, medi::MpiTypeBase< Impl, TypeB, ModifiedTypeB, ADToolB >, medi::MpiTypeBase< MpiTypeDefault< ADTool >, ADTool::Type, ADTool::ModifiedType, ADTool >, and medi::MpiTypeBase< MpiTypePassive< T >, T, T, ADToolPassive >.

◆ createIndices()

virtual void medi::MpiTypeInterface::createIndices ( void * buf,
size_t bufOffset,
void * indices,
size_t bufModOffset,
int elements ) const
pure virtual

Create indices for a reciving buffer if necessary.

Parameters
[in]bufThe original buffer provided by the user.
[in]bufOffsetThe offset into the original buffer, as provided by the user.
[out]indicesThe generated buffer for indices. Indices are stored in a linearized fashion.
[in]bufModOffsetThe linearized displacement for the modified buffer. These displacements are continuous and do not contain any holes.
[in]elementsThe number of elements that should be copied.

Implemented in medi::MpiStructType, medi::MpiTypeBase< Impl, TypeB, ModifiedTypeB, ADToolB >, medi::MpiTypeBase< MpiTypeDefault< ADTool >, ADTool::Type, ADTool::ModifiedType, ADTool >, and medi::MpiTypeBase< MpiTypePassive< T >, T, T, ADToolPassive >.

◆ createModifiedTypeBuffer()

virtual void medi::MpiTypeInterface::createModifiedTypeBuffer ( void *& buf,
size_t size ) const
pure virtual

Create a temporary buffer of the modified type that this interface represents.

Parameters
[in,out]bufThe location for the new buffer
[in]sizeThe number of elements for the buffer

Implemented in medi::MpiStructType, medi::MpiTypeBase< Impl, TypeB, ModifiedTypeB, ADToolB >, medi::MpiTypeBase< MpiTypeDefault< ADTool >, ADTool::Type, ADTool::ModifiedType, ADTool >, and medi::MpiTypeBase< MpiTypePassive< T >, T, T, ADToolPassive >.

◆ createTypeBuffer()

virtual void medi::MpiTypeInterface::createTypeBuffer ( void *& buf,
size_t size ) const
pure virtual

Create a temporary buffer of the type that this interface represents.

Parameters
[in,out]bufThe location for the new buffer
[in]sizeThe number of elements for the buffer

Implemented in medi::MpiStructType, medi::MpiTypeBase< Impl, TypeB, ModifiedTypeB, ADToolB >, medi::MpiTypeBase< MpiTypeDefault< ADTool >, ADTool::Type, ADTool::ModifiedType, ADTool >, and medi::MpiTypeBase< MpiTypePassive< T >, T, T, ADToolPassive >.

◆ deleteModifiedTypeBuffer()

virtual void medi::MpiTypeInterface::deleteModifiedTypeBuffer ( void *& buf) const
pure virtual

◆ deleteTypeBuffer()

virtual void medi::MpiTypeInterface::deleteTypeBuffer ( void *& buf,
size_t size ) const
pure virtual

◆ freeType()

virtual void medi::MpiTypeInterface::freeType ( Type * buf,
size_t bufOffset,
int elements ) const
pure virtual

Destroy the types in the buffer.

Parameters
[in,out]bufThe buffer in which the types are destroyed.
[in]bufOffsetThe offset into the orignal buffer, as provided by the user.
[in]elementsTHe number of elements the shoudl be initialized.

Implemented in medi::MpiStructType, medi::MpiTypeBase< Impl, TypeB, ModifiedTypeB, ADToolB >, medi::MpiTypeBase< MpiTypeDefault< ADTool >, ADTool::Type, ADTool::ModifiedType, ADTool >, and medi::MpiTypeBase< MpiTypePassive< T >, T, T, ADToolPassive >.

◆ getADTool()

virtual const ADToolInterface & medi::MpiTypeInterface::getADTool ( ) const
pure virtual

Get the AD tool that handled the AD specifics.

Returns
The handle to the AD tool

Implemented in medi::MpiStructType, medi::MpiTypeDefault< ADTool >, and medi::MpiTypePassive< T >.

◆ getIndices()

virtual void medi::MpiTypeInterface::getIndices ( const void * buf,
size_t bufOffset,
void * indices,
size_t bufModOffset,
int elements ) const
pure virtual

Get all the AD identifiers from all AD types in the buffer.

Parameters
[in]bufThe original buffer provided by the user.
[in]bufOffsetThe offset into the original buffer, as provided by the user.
[out]indicesThe generated buffer for indices. Indices are stored in a linearized fashion.
[in]bufModOffsetThe linearized displacement for the modified buffer. These displacements are continuous and do not contain any holes.
[in]elementsThe number of elements that should be copied.

Implemented in medi::MpiStructType, medi::MpiTypeBase< Impl, TypeB, ModifiedTypeB, ADToolB >, medi::MpiTypeBase< MpiTypeDefault< ADTool >, ADTool::Type, ADTool::ModifiedType, ADTool >, and medi::MpiTypeBase< MpiTypePassive< T >, T, T, ADToolPassive >.

◆ getModifiedMpiType()

MPI_Datatype medi::MpiTypeInterface::getModifiedMpiType ( ) const
inline

Return the MPI type for the modified data.

Returns
The MPI type for the modified data.

◆ getMpiType()

MPI_Datatype medi::MpiTypeInterface::getMpiType ( ) const
inline

Return the MPI type for the data that this interface represents.

Returns
The MPI type for the data.

◆ getValues()

virtual void medi::MpiTypeInterface::getValues ( const void * buf,
size_t bufOffset,
void * primals,
size_t bufModOffset,
int elements ) const
pure virtual

Get the primal values from the AD types.

Parameters
[in]bufThe original buffer provided by the user.
[in]bufOffsetThe offset into the original buffer, as provided by the user.
[out]primalsThe generated buffer for primal values if the AD tool requires theses. Indices are stored in a linearized fashion.
[in]bufModOffsetThe linearized displacement for the modified buffer. These displacements are continuous and do not contain any holes.
[in]elementsThe number of elements that should be copied.

Implemented in medi::MpiStructType, medi::MpiTypeBase< Impl, TypeB, ModifiedTypeB, ADToolB >, medi::MpiTypeBase< MpiTypeDefault< ADTool >, ADTool::Type, ADTool::ModifiedType, ADTool >, and medi::MpiTypeBase< MpiTypePassive< T >, T, T, ADToolPassive >.

◆ initializeType()

virtual void medi::MpiTypeInterface::initializeType ( Type * buf,
size_t bufOffset,
int elements ) const
pure virtual

Initialize the types in the buffer.

Parameters
[in,out]bufThe buffer in which the types are created.
[in]bufOffsetThe offset into the orignal buffer, as provided by the user.
[in]elementsTHe number of elements the shoudl be initialized.

Implemented in medi::MpiStructType, medi::MpiTypeBase< Impl, TypeB, ModifiedTypeB, ADToolB >, medi::MpiTypeBase< MpiTypeDefault< ADTool >, ADTool::Type, ADTool::ModifiedType, ADTool >, and medi::MpiTypeBase< MpiTypePassive< T >, T, T, ADToolPassive >.

◆ isModifiedBufferRequired()

virtual bool medi::MpiTypeInterface::isModifiedBufferRequired ( ) const
pure virtual

Tell the functions if the underlying AD tool requires new send/recv buffers or if the original buffers can be used.

Returns
true if new send/recv buffers are required.

Implemented in medi::MpiStructType, medi::MpiTypeDefault< ADTool >, and medi::MpiTypePassive< T >.

◆ performReduce()

virtual void medi::MpiTypeInterface::performReduce ( void * buf,
void * target,
int count,
AMPI_Op op,
int ranks ) const
pure virtual

Perform a local reduce operation.

Parameters
[in]bufThe original buffer provided by the user.
[out]targetThe target buffer provided by the user.
[in]countThe number of elements per rank.
[in]opThe operator for the reduction.
[in]ranksThe number of ranks in the communication.

Implemented in medi::MpiStructType, medi::MpiTypeBase< Impl, TypeB, ModifiedTypeB, ADToolB >, medi::MpiTypeBase< MpiTypeDefault< ADTool >, ADTool::Type, ADTool::ModifiedType, ADTool >, and medi::MpiTypeBase< MpiTypePassive< T >, T, T, ADToolPassive >.

◆ registerValue()

virtual void medi::MpiTypeInterface::registerValue ( void * buf,
size_t bufOffset,
void * indices,
void * oldPrimals,
size_t bufModOffset,
int elements ) const
pure virtual

Register all the AD values on the new machine.

Parameters
[in]bufThe original buffer provided by the user.
[in]bufOffsetThe offset into the original buffer, as provided by the user.
[out]indicesThe generated buffer for indices. Indices are stored in a linearized fashion.
[out]oldPrimalsThe generated buffer for primal values if the AD tool requires theses. Indices are stored in a linearized fashion.
[in]bufModOffsetThe linearized displacement for the modified buffer. These displacements are continuous and do not contain any holes.
[in]elementsThe number of elements that should be copied.

Implemented in medi::MpiStructType, medi::MpiTypeBase< Impl, TypeB, ModifiedTypeB, ADToolB >, medi::MpiTypeBase< MpiTypeDefault< ADTool >, ADTool::Type, ADTool::ModifiedType, ADTool >, and medi::MpiTypeBase< MpiTypePassive< T >, T, T, ADToolPassive >.

◆ setMpiTypes()

void medi::MpiTypeInterface::setMpiTypes ( MPI_Datatype mpiType,
MPI_Datatype modifiedMpiType )
inlineprotected

Helper method for extending classes to set the types after the initial construction.

Parameters
[in]mpiTypeThe MPI type for the data.
[in]modifiedMpiTypeThe MPI type for the modified data.

The documentation for this class was generated from the following file: