67 MPI_Datatype modifiedMpiType;
102 modifiedMpiType(modifiedMpiType) {}
116 void setMpiTypes(MPI_Datatype mpiType, MPI_Datatype modifiedMpiType) {
117 this->mpiType = mpiType;
118 this->modifiedMpiType = modifiedMpiType;
136 return modifiedMpiType;
171 virtual void copyIntoModifiedBuffer(
const void* buf,
size_t bufOffset,
void* bufMod,
size_t bufModOffset,
int elements)
const = 0;
183 virtual void copyFromModifiedBuffer(
void* buf,
size_t bufOffset,
const void* bufMod,
size_t bufModOffset,
int elements)
const = 0;
194 virtual void getIndices(
const void* buf,
size_t bufOffset,
void* indices,
size_t bufModOffset,
int elements)
const = 0;
206 virtual void registerValue(
void* buf,
size_t bufOffset,
void* indices,
void* oldPrimals,
size_t bufModOffset,
int elements)
const = 0;
215 virtual void clearIndices(
void* buf,
size_t bufOffset,
int elements)
const = 0;
226 virtual void createIndices(
void* buf,
size_t bufOffset,
void* indices,
size_t bufModOffset,
int elements)
const = 0;
237 virtual void getValues(
const void* buf,
size_t bufOffset,
void* primals,
size_t bufModOffset,
int elements)
const = 0;
259 virtual void copy(
void* from,
size_t fromOffset,
void* to,
size_t toOffset,
int count)
const = 0;
277 virtual void freeType(
Type* buf,
size_t bufOffset,
int elements)
const = 0;
323 template <
typename Impl,
typename TypeB,
typename ModifiedTypeB,
typename ADToolB>
334 return cast().computeActiveElements(count);
338 cast().copyIntoModifiedBuffer(castBuffer<TypeB>(buf), bufOffset, castBuffer<ModifiedTypeB>(bufMod), bufModOffset, elements);
342 cast().copyFromModifiedBuffer(castBuffer<TypeB>(buf), bufOffset, castBuffer<ModifiedTypeB>(bufMod), bufModOffset, elements);
345 void getIndices(
const void* buf,
size_t bufOffset,
void* indices,
size_t bufModOffset,
int elements)
const {
346 cast().getIndices(castBuffer<TypeB>(buf), bufOffset, castBuffer<IndexTypeB>(indices), bufModOffset, elements);
349 void registerValue(
void* buf,
size_t bufOffset,
void* indices,
void* oldPrimals,
size_t bufModOffset,
int elements)
const {
350 cast().registerValue(castBuffer<TypeB>(buf), bufOffset, castBuffer<IndexTypeB>(indices), castBuffer<PrimalTypeB>(oldPrimals), bufModOffset, elements);
354 cast().clearIndices(castBuffer<TypeB>(buf), bufOffset, elements);
357 void createIndices(
void* buf,
size_t bufOffset,
void* indices,
size_t bufModOffset,
int elements)
const {
358 cast().createIndices(castBuffer<TypeB>(buf), bufOffset, castBuffer<IndexTypeB>(indices), bufModOffset, elements);
361 void getValues(
const void* buf,
size_t bufOffset,
void* primals,
size_t bufModOffset,
int elements)
const {
362 cast().getValues(castBuffer<TypeB>(buf), bufOffset, castBuffer<PrimalTypeB>(primals), bufModOffset, elements);
366 cast().performReduce(castBuffer<TypeB>(buf), castBuffer<TypeB>(target), count, op, ranks);
369 void copy(
void* from,
size_t fromOffset,
void* to,
size_t toOffset,
int count)
const {
370 cast().copy(castBuffer<TypeB>(from), fromOffset, castBuffer<TypeB>(to), toOffset, count);
374 cast().initializeType(castBuffer<TypeB>(buf), bufOffset, elements);
377 void freeType(
void* buf,
size_t bufOffset,
int elements)
const {
378 cast().freeType(castBuffer<TypeB>(buf), bufOffset, elements);
382 cast().createTypeBuffer(castBuffer<TypeB>(buf), size);
386 cast().createModifiedTypeBuffer(castBuffer<ModifiedTypeB>(buf), size);
390 cast().deleteTypeBuffer(castBuffer<TypeB>(buf), size);
394 cast().deleteModifiedTypeBuffer(castBuffer<ModifiedTypeB>(buf));
399 inline Impl& cast() {
400 return *
reinterpret_cast<Impl*
>(
this);
403 inline const Impl& cast()
const {
404 return *
reinterpret_cast<const Impl*
>(
this);
407 template <
typename T>
408 inline T*& castBuffer(
void*& buf)
const {
409 return reinterpret_cast<T*&
>(buf);
412 template <
typename T>
413 inline const T*& castBuffer(
const void* &buf)
const {
414 return reinterpret_cast<const T*&
>(buf);
Definition typeInterface.hpp:324
void copyIntoModifiedBuffer(const void *buf, size_t bufOffset, void *bufMod, size_t bufModOffset, int elements) const
Copy all data into the modified buffer and perform the special handling for the AD type.
Definition typeInterface.hpp:337
void copy(void *from, size_t fromOffset, void *to, size_t toOffset, int count) const
Copy the elements of one buffer into the other.
Definition typeInterface.hpp:369
void getIndices(const void *buf, size_t bufOffset, void *indices, size_t bufModOffset, int elements) const
Get all the AD identifiers from all AD types in the buffer.
Definition typeInterface.hpp:345
ADToolB::IndexType IndexTypeB
Definition typeInterface.hpp:328
int computeActiveElements(const int count) const
Get the number of active elements that are contained in count versions of the type.
Definition typeInterface.hpp:333
void deleteTypeBuffer(void *&buf, size_t size) const
Delete the temporary buffer.
Definition typeInterface.hpp:389
void createModifiedTypeBuffer(void *&buf, size_t size) const
Create a temporary buffer of the modified type that this interface represents.
Definition typeInterface.hpp:385
void clearIndices(void *buf, size_t bufOffset, int elements) const
Clear the AD types in the buffer such that they can be overwritten.
Definition typeInterface.hpp:353
void createTypeBuffer(void *&buf, size_t size) const
Create a temporary buffer of the type that this interface represents.
Definition typeInterface.hpp:381
void initializeType(void *buf, size_t bufOffset, int elements) const
Initialize the types in the buffer.
Definition typeInterface.hpp:373
void deleteModifiedTypeBuffer(void *&buf) const
Delete the temporary buffer for the modified types.
Definition typeInterface.hpp:393
void createIndices(void *buf, size_t bufOffset, void *indices, size_t bufModOffset, int elements) const
Create indices for a reciving buffer if necessary.
Definition typeInterface.hpp:357
void getValues(const void *buf, size_t bufOffset, void *primals, size_t bufModOffset, int elements) const
Get the primal values from the AD types.
Definition typeInterface.hpp:361
void performReduce(void *buf, void *target, int count, AMPI_Op op, int ranks) const
Perform a local reduce operation.
Definition typeInterface.hpp:365
MpiTypeBase(MPI_Datatype mpiType, MPI_Datatype modifiedMpiType)
Definition typeInterface.hpp:330
void registerValue(void *buf, size_t bufOffset, void *indices, void *oldPrimals, size_t bufModOffset, int elements) const
Register all the AD values on the new machine.
Definition typeInterface.hpp:349
void copyFromModifiedBuffer(void *buf, size_t bufOffset, const void *bufMod, size_t bufModOffset, int elements) const
Copy all data from the modified buffer and perform the special handling for the AD type.
Definition typeInterface.hpp:341
ADToolB::PrimalType PrimalTypeB
Definition typeInterface.hpp:327
void freeType(void *buf, size_t bufOffset, int elements) const
Destroy the types in the buffer.
Definition typeInterface.hpp:377
Wrapper interface for MPI types in communications.
Definition typeInterface.hpp:63
void AdjointType
Definition typeInterface.hpp:93
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.
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 freeType(Type *buf, size_t bufOffset, int elements) const =0
Destroy the types in the buffer.
void ModifiedType
The type of the modified buffer data which is send over the network.
Definition typeInterface.hpp:80
void Type
The type of the user data which is represented by this interface.
Definition typeInterface.hpp:73
void PrimalType
The type of the floating point values which are handled by the AD tool.
Definition typeInterface.hpp:85
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 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 bool isModifiedBufferRequired() const =0
Tell the functions if the underlying AD tool requires new send/recv buffers or if the original buffer...
MPI_Datatype getMpiType() const
Return the MPI type for the data that this interface represents.
Definition typeInterface.hpp:127
MPI_Datatype getModifiedMpiType() const
Return the MPI type for the modified data.
Definition typeInterface.hpp:135
virtual void performReduce(void *buf, void *target, int count, AMPI_Op op, int ranks) const =0
Perform a local reduce operation.
virtual const ADToolInterface & getADTool() const =0
Get the AD tool that handled the AD specifics.
virtual MpiTypeInterface * clone() const =0
Creates a clone of the mpi type also calling MPI_Type_dub.
virtual ~MpiTypeInterface()
Virtual destructor.
Definition typeInterface.hpp:107
virtual void deleteTypeBuffer(void *&buf, size_t size) const =0
Delete the temporary buffer.
virtual void createTypeBuffer(void *&buf, size_t size) const =0
Create a temporary buffer of the type that this interface represents.
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.
void setMpiTypes(MPI_Datatype mpiType, MPI_Datatype modifiedMpiType)
Helper method for extending classes to set the types after the initial construction.
Definition typeInterface.hpp:116
void IndexType
The type of the identifiers for the AD tool.
Definition typeInterface.hpp:90
virtual void initializeType(Type *buf, size_t bufOffset, int elements) const =0
Initialize the types in the buffer.
virtual void createModifiedTypeBuffer(void *&buf, size_t size) const =0
Create a temporary buffer of the modified type that this interface represents.
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 int computeActiveElements(const int count) const =0
Get the number of active elements that are contained in count versions of the type.
MpiTypeInterface(MPI_Datatype mpiType, MPI_Datatype modifiedMpiType)
Wrapper interface for MPI types in communications. See the class description for details.
Definition typeInterface.hpp:100
virtual void deleteModifiedTypeBuffer(void *&buf) const =0
Delete the temporary buffer for the modified types.
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 clearIndices(void *buf, size_t bufOffset, int elements) const =0
Clear the AD types in the buffer such that they can be overwritten.
Global namespace for MeDiPack - Message Differentiation Package.
Definition adjointInterface.hpp:37
Structure for the special handling of the MPI_Op structure.
Definition op.hpp:50