Wrapper interface for MPI types in communications. More...
#include <typeInterface.hpp>
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 MpiTypeInterface * | clone () 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 ADToolInterface & | getADTool () 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. | |
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.
typedef void medi::MpiTypeInterface::AdjointType |
typedef void medi::MpiTypeInterface::IndexType |
The type of the identifiers for the AD tool.
typedef void medi::MpiTypeInterface::ModifiedType |
The type of the modified buffer data which is send over the network.
The buffer is modified by the AD tool if requested.
typedef void medi::MpiTypeInterface::PrimalType |
The type of the floating point values which are handled by the AD tool.
typedef void medi::MpiTypeInterface::Type |
The type of the user data which is represented by this interface.
|
inline |
Wrapper interface for MPI types in communications. See the class description for details.
[in] | mpiType | The MPI type for the data. |
[in] | modifiedMpiType | The MPI type for the modified data. |
|
inlinevirtual |
Virtual destructor.
|
pure virtual |
Clear the AD types in the buffer such that they can be overwritten.
[in] | buf | The original buffer provided by the user. |
[in] | bufOffset | The offset into the original buffer, as provided by the user. |
[in] | elements | The 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 >.
|
pure virtual |
Creates a clone of the mpi type also calling MPI_Type_dub.
Implemented in medi::MpiStructType, medi::MpiTypeDefault< ADTool >, and medi::MpiTypePassive< T >.
|
pure virtual |
Get the number of active elements that are contained in count versions of the type.
[in] | count | The number of times this type is contained 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 >.
|
pure virtual |
Copy the elements of one buffer into the other.
[in] | from | The original buffer provided by the user. |
[in] | fromOffset | The offset into the original buffer. |
[out] | to | The target buffer for the data. |
[in] | toOffset | The offset for the target buffer. |
[in] | count | The 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 >.
|
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.
[in] | buf | The original buffer provided by the user. |
[in] | bufOffset | The offset into the original buffer, as provided by the user. |
[out] | bufMod | The buffer with the modified data. |
[in] | bufModOffset | The linearized displacement for the modified buffer. These displacements are contiunous and do not contain any holes. |
[in] | elements | The 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 >.
|
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.
[in] | buf | The original buffer provided by the user. |
[in] | bufOffset | The offset into the original buffer, as provided by the user. |
[out] | bufMod | The new buffer for the modified data. |
[in] | bufModOffset | The linearized displacement for the modified buffer. These displacements are continuous and do not contain any holes. |
[in] | elements | The 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 >.
|
pure virtual |
Create indices for a reciving buffer if necessary.
[in] | buf | The original buffer provided by the user. |
[in] | bufOffset | The offset into the original buffer, as provided by the user. |
[out] | indices | The generated buffer for indices. Indices are stored in a linearized fashion. |
[in] | bufModOffset | The linearized displacement for the modified buffer. These displacements are continuous and do not contain any holes. |
[in] | elements | The 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 >.
|
pure virtual |
Create a temporary buffer of the modified type that this interface represents.
[in,out] | buf | The location for the new buffer |
[in] | size | The 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 >.
|
pure virtual |
Create a temporary buffer of the type that this interface represents.
[in,out] | buf | The location for the new buffer |
[in] | size | The 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 >.
|
pure virtual |
Delete the temporary buffer for the modified types.
[in,out] | buf | The location 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 >.
|
pure virtual |
Delete the temporary buffer.
[in,out] | buf | The location for the buffer |
[in] | size | The size of the temporary 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 >.
|
pure virtual |
Destroy the types in the buffer.
[in,out] | buf | The buffer in which the types are destroyed. |
[in] | bufOffset | The offset into the orignal buffer, as provided by the user. |
[in] | elements | THe 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 >.
|
pure virtual |
Get the AD tool that handled the AD specifics.
Implemented in medi::MpiStructType, medi::MpiTypeDefault< ADTool >, and medi::MpiTypePassive< T >.
|
pure virtual |
Get all the AD identifiers from all AD types in the buffer.
[in] | buf | The original buffer provided by the user. |
[in] | bufOffset | The offset into the original buffer, as provided by the user. |
[out] | indices | The generated buffer for indices. Indices are stored in a linearized fashion. |
[in] | bufModOffset | The linearized displacement for the modified buffer. These displacements are continuous and do not contain any holes. |
[in] | elements | The 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 >.
|
inline |
Return the MPI type for the modified data.
|
inline |
Return the MPI type for the data that this interface represents.
|
pure virtual |
Get the primal values from the AD types.
[in] | buf | The original buffer provided by the user. |
[in] | bufOffset | The offset into the original buffer, as provided by the user. |
[out] | primals | The generated buffer for primal values if the AD tool requires theses. Indices are stored in a linearized fashion. |
[in] | bufModOffset | The linearized displacement for the modified buffer. These displacements are continuous and do not contain any holes. |
[in] | elements | The 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 >.
|
pure virtual |
Initialize the types in the buffer.
[in,out] | buf | The buffer in which the types are created. |
[in] | bufOffset | The offset into the orignal buffer, as provided by the user. |
[in] | elements | THe 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 >.
|
pure virtual |
Tell the functions if the underlying AD tool requires new send/recv buffers or if the original buffers can be used.
Implemented in medi::MpiStructType, medi::MpiTypeDefault< ADTool >, and medi::MpiTypePassive< T >.
|
pure virtual |
Perform a local reduce operation.
[in] | buf | The original buffer provided by the user. |
[out] | target | The target buffer provided by the user. |
[in] | count | The number of elements per rank. |
[in] | op | The operator for the reduction. |
[in] | ranks | The 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 >.
|
pure virtual |
Register all the AD values on the new machine.
[in] | buf | The original buffer provided by the user. |
[in] | bufOffset | The offset into the original buffer, as provided by the user. |
[out] | indices | The generated buffer for indices. Indices are stored in a linearized fashion. |
[out] | oldPrimals | The generated buffer for primal values if the AD tool requires theses. Indices are stored in a linearized fashion. |
[in] | bufModOffset | The linearized displacement for the modified buffer. These displacements are continuous and do not contain any holes. |
[in] | elements | The 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 >.
|
inlineprotected |
Helper method for extending classes to set the types after the initial construction.
[in] | mpiType | The MPI type for the data. |
[in] | modifiedMpiType | The MPI type for the modified data. |