47 template<
typename ADTool>
50 MpiTypeDefault<ADTool>,
51 typename ADTool::Type,
52 typename ADTool::ModifiedType,
59 typedef typename ADTool::Type
Type;
107 return adTool->isModifiedBufferRequired();
111 if(
adTool->isModifiedBufferRequired()) {
112 for(
int i = 0; i < elements; ++i) {
113 ADTool::setIntoModifyBuffer(bufMod[bufModOffset + i], buf[bufOffset + i]);
119 if(
adTool->isModifiedBufferRequired()) {
120 for(
int i = 0; i < elements; ++i) {
121 ADTool::getFromModifyBuffer(bufMod[bufModOffset + i], buf[bufOffset + i]);
129 for(
int i = 0; i < elements; ++i) {
130 indices[indexOffset + i] = ADTool::getIndex(buf[bufOffset + i]);
137 for(
int i = 0; i < elements; ++i) {
138 ADTool::registerValue(buf[bufOffset + i], oldPrimals[indexOffset + i], indices[indexOffset + i]);
143 for(
int i = 0; i < elements; ++i) {
144 ADTool::clearIndex(buf[bufOffset + i]);
151 for(
int i = 0; i < elements; ++i) {
152 ADTool::createIndex(buf[bufOffset + i], indices[indexOffset + i]);
159 for(
int pos = 0; pos < elements; ++pos) {
160 primals[primalOffset + pos] = ADTool::getValue(buf[bufOffset + pos]);
165 for(
int j = 1; j < ranks; ++j) {
170 copy(buf, 0, target, 0, count);
175 void copy(
Type* from,
size_t fromOffset,
Type* to,
size_t toOffset,
int count)
const {
176 for(
int i = 0; i < count; ++i) {
177 to[toOffset + i] = from[fromOffset + i];
183 for(
int i = 0; i < elements; ++i) {
184 new(&buf[bufOffset + i])
Type;
189 for(
int i = 0; i < elements; ++i) {
190 buf[bufOffset + i].~Type();
195 buf =
new Type[size];
220 MPI_Datatype modType;
void copy(void *from, size_t fromOffset, void *to, size_t toOffset, int count) const
Definition typeInterface.hpp:369
MpiTypeBase(MPI_Datatype mpiType, MPI_Datatype modifiedMpiType)
Definition typeInterface.hpp:330
~MpiTypeDefault()
Definition typeDefault.hpp:86
ADTool::Type Type
Definition typeDefault.hpp:59
void clearIndices(Type *buf, size_t bufOffset, int elements) const
Definition typeDefault.hpp:142
const Tool & getADTool() const
Get the AD tool that handled the AD specifics.
Definition typeDefault.hpp:98
void initializeType(Type *buf, size_t bufOffset, int elements) const
Definition typeDefault.hpp:182
void createTypeBuffer(Type *&buf, size_t size) const
Definition typeDefault.hpp:194
MpiTypeDefault(Tool *adTool, MPI_Datatype type, MPI_Datatype modType)
Definition typeDefault.hpp:73
int computeActiveElements(const int count) const
Get the number of active elements that are contained in count versions of the type.
Definition typeDefault.hpp:102
void deleteModifiedTypeBuffer(ModifiedType *&buf) const
Definition typeDefault.hpp:211
MpiTypeDefault * clone() const
Creates a clone of the mpi type also calling MPI_Type_dub.
Definition typeDefault.hpp:218
void copyIntoModifiedBuffer(const Type *buf, size_t bufOffset, ModifiedType *bufMod, size_t bufModOffset, int elements) const
Definition typeDefault.hpp:110
MpiTypeBase< MpiTypeDefault< ADTool >, Type, ModifiedType, Tool > Base
Definition typeDefault.hpp:67
void createIndices(Type *buf, size_t bufOffset, IndexType *indices, size_t bufModOffset, int elements) const
Definition typeDefault.hpp:148
ADTool::PrimalType PrimalType
Definition typeDefault.hpp:61
void createModifiedTypeBuffer(ModifiedType *&buf, size_t size) const
Definition typeDefault.hpp:198
ADTool::IndexType IndexType
Definition typeDefault.hpp:63
void copyFromModifiedBuffer(Type *buf, size_t bufOffset, const ModifiedType *bufMod, size_t bufModOffset, int elements) const
Definition typeDefault.hpp:118
void performReduce(Type *buf, Type *target, int count, AMPI_Op op, int ranks) const
Definition typeDefault.hpp:164
void copy(Type *from, size_t fromOffset, Type *to, size_t toOffset, int count) const
Definition typeDefault.hpp:175
ADTool Tool
Definition typeDefault.hpp:65
void deleteTypeBuffer(Type *&buf, size_t size) const
Definition typeDefault.hpp:202
bool isModifiedBufferRequired() const
Tell the functions if the underlying AD tool requires new send/recv buffers or if the original buffer...
Definition typeDefault.hpp:106
void freeType(Type *buf, size_t bufOffset, int elements) const
Definition typeDefault.hpp:188
ADTool::ModifiedType ModifiedType
Definition typeDefault.hpp:60
Tool * adTool
Definition typeDefault.hpp:71
bool isClone
Definition typeDefault.hpp:69
void getValues(const Type *buf, size_t bufOffset, PrimalType *primals, size_t bufModOffset, int elements) const
Definition typeDefault.hpp:156
void registerValue(Type *buf, size_t bufOffset, IndexType *indices, PrimalType *oldPrimals, size_t bufModOffset, int elements) const
Definition typeDefault.hpp:134
ADTool::AdjointType AdjointType
Definition typeDefault.hpp:62
void getIndices(const Type *buf, size_t bufOffset, IndexType *indices, size_t bufModOffset, int elements) const
Definition typeDefault.hpp:126
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
#define INTERFACE_DEF(interface, name,...)
Definition macros.h:116
#define MEDI_UNUSED(name)
Definition macros.h:108
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
MPI_Op primalFunction
The mpi operator for the unmodified AD types. The AD tool needs to record all operations that are eva...
Definition op.hpp:69