47 template<
typename ADTool>
50 MpiTypeDefault<ADTool>,
51 typename ADTool::Type,
52 typename ADTool::ModifiedType,
59 typedef typename ADTool::Type
Type;
105 return adTool->isModifiedBufferRequired();
109 if(
adTool->isModifiedBufferRequired()) {
110 for(
int i = 0; i < elements; ++i) {
111 ADTool::setIntoModifyBuffer(bufMod[bufModOffset + i], buf[bufOffset + i]);
117 if(
adTool->isModifiedBufferRequired()) {
118 for(
int i = 0; i < elements; ++i) {
119 ADTool::getFromModifyBuffer(bufMod[bufModOffset + i], buf[bufOffset + i]);
127 for(
int i = 0; i < elements; ++i) {
128 indices[indexOffset + i] = ADTool::getIndex(buf[bufOffset + i]);
135 for(
int i = 0; i < elements; ++i) {
136 ADTool::registerValue(buf[bufOffset + i], oldPrimals[indexOffset + i], indices[indexOffset + i]);
141 for(
int i = 0; i < elements; ++i) {
142 ADTool::clearIndex(buf[bufOffset + i]);
149 for(
int i = 0; i < elements; ++i) {
150 ADTool::createIndex(buf[bufOffset + i], indices[indexOffset + i]);
157 for(
int pos = 0; pos < elements; ++pos) {
158 primals[primalOffset + pos] = ADTool::getValue(buf[bufOffset + pos]);
163 for(
int j = 1; j < ranks; ++j) {
168 copy(buf, 0, target, 0, count);
172 void copy(
Type* from,
size_t fromOffset,
Type* to,
size_t toOffset,
int count)
const {
173 for(
int i = 0; i < count; ++i) {
174 to[toOffset + i] = from[fromOffset + i];
180 for(
int i = 0; i < elements; ++i) {
181 new(&buf[bufOffset + i])
Type;
186 for(
int i = 0; i < elements; ++i) {
187 buf[bufOffset + i].~Type();
192 buf =
new Type[size];
217 MPI_Datatype modType;
Definition typeInterface.hpp:324
The default implementation of a MPI type that is represented by an AD type.
Definition typeDefault.hpp:54
~MpiTypeDefault()
Definition typeDefault.hpp:84
ADTool::Type Type
Definition typeDefault.hpp:59
void clearIndices(Type *buf, size_t bufOffset, int elements) const
Definition typeDefault.hpp:140
const Tool & getADTool() const
Get the AD tool that handled the AD specifics.
Definition typeDefault.hpp:96
void initializeType(Type *buf, size_t bufOffset, int elements) const
Definition typeDefault.hpp:179
void createTypeBuffer(Type *&buf, size_t size) const
Definition typeDefault.hpp:191
MpiTypeDefault(Tool *adTool, MPI_Datatype type, MPI_Datatype modType)
Definition typeDefault.hpp:71
int computeActiveElements(const int count) const
Get the number of active elements that are contained in count versions of the type.
Definition typeDefault.hpp:100
void deleteModifiedTypeBuffer(ModifiedType *&buf) const
Definition typeDefault.hpp:208
MpiTypeDefault * clone() const
Creates a clone of the mpi type also calling MPI_Type_dub.
Definition typeDefault.hpp:215
void copyIntoModifiedBuffer(const Type *buf, size_t bufOffset, ModifiedType *bufMod, size_t bufModOffset, int elements) const
Definition typeDefault.hpp:108
void createIndices(Type *buf, size_t bufOffset, IndexType *indices, size_t bufModOffset, int elements) const
Definition typeDefault.hpp:146
ADTool::PrimalType PrimalType
Definition typeDefault.hpp:61
void createModifiedTypeBuffer(ModifiedType *&buf, size_t size) const
Definition typeDefault.hpp:195
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:116
void performReduce(Type *buf, Type *target, int count, AMPI_Op op, int ranks) const
Definition typeDefault.hpp:162
void copy(Type *from, size_t fromOffset, Type *to, size_t toOffset, int count) const
Definition typeDefault.hpp:172
ADTool Tool
Definition typeDefault.hpp:65
void deleteTypeBuffer(Type *&buf, size_t size) const
Definition typeDefault.hpp:199
bool isModifiedBufferRequired() const
Tell the functions if the underlying AD tool requires new send/recv buffers or if the original buffer...
Definition typeDefault.hpp:104
void freeType(Type *buf, size_t bufOffset, int elements) const
Definition typeDefault.hpp:185
ADTool::ModifiedType ModifiedType
Definition typeDefault.hpp:60
Tool * adTool
Definition typeDefault.hpp:69
bool isClone
Definition typeDefault.hpp:67
void getValues(const Type *buf, size_t bufOffset, PrimalType *primals, size_t bufModOffset, int elements) const
Definition typeDefault.hpp:154
void registerValue(Type *buf, size_t bufOffset, IndexType *indices, PrimalType *oldPrimals, size_t bufModOffset, int elements) const
Definition typeDefault.hpp:132
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:124
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