MeDiPack  1.3.3
A Message Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
adToolImplCommon.hpp
Go to the documentation of this file.
1/*
2 * MeDiPack, a Message Differentiation Package
3 *
4 * Copyright (C) 2015-2025 Chair for Scientific Computing (SciComp), University of Kaiserslautern-Landau
5 * Homepage: http://scicomp.rptu.de
6 * Contact: Prof. Nicolas R. Gauger (codi@scicomp.uni-kl.de)
7 *
8 * Lead developers: Max Sagebaum (SciComp, University of Kaiserslautern-Landau)
9 *
10 * This file is part of MeDiPack (http://scicomp.rptu.de/software/medi).
11 *
12 * MeDiPack is free software: you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation, either
15 * version 3 of the License, or (at your option) any later version.
16 *
17 * MeDiPack is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * See the GNU Lesser General Public License for more details.
22 * You should have received a copy of the GNU
23 * Lesser General Public License along with MeDiPack.
24 * If not, see <http://www.gnu.org/licenses/>.
25 *
26 * Authors: Max Sagebaum, Tim Albring (SciComp, University of Kaiserslautern-Landau)
27 */
28
29#pragma once
30
31#include "typeDefinitions.h"
32#include "adToolInterface.h"
33
37namespace medi {
38
39 template <typename Impl, bool restorePrimal, bool modifiedBuffer, typename Type, typename AdjointType, typename PrimalType, typename IndexType>
40 class ADToolImplCommon : public ADToolBase<Impl, AdjointType, PrimalType, IndexType> {
41 public:
42
44
45 ADToolImplCommon(MPI_Datatype primalMpiType, MPI_Datatype adjointMpiType) :
46 Base(primalMpiType, adjointMpiType) {}
47
48 inline bool isActiveType() const {
49 return true;
50 }
51
52 inline bool isModifiedBufferRequired() const {
53 return modifiedBuffer;
54 }
55
56 inline bool isOldPrimalsRequired() const {
57 return restorePrimal;
58 }
59
60 inline void createPrimalTypeBuffer(PrimalType* &buf, size_t size) const {
61 buf = new PrimalType[size];
62 }
63
65 inline void createIndexTypeBuffer(IndexType* &buf, size_t size) const {
66 buf = new IndexType[size];
67 }
68
69 inline void deletePrimalTypeBuffer(PrimalType* &buf) const {
70 if(NULL != buf) {
71 delete [] buf;
72 buf = NULL;
73 }
74 }
75
77 inline void deleteIndexTypeBuffer(IndexType* &buf) const {
78 if(NULL != buf) {
79 delete [] buf;
80 buf = NULL;
81 }
82 }
83 };
84}
ADToolBase(MPI_Datatype primalMpiType, MPI_Datatype adjointMpiType)
Definition adToolInterface.h:302
void deleteIndexTypeBuffer(void *&buf) const
Definition adToolInterface.h:317
void createIndexTypeBuffer(void *&buf, size_t size) const
Definition adToolInterface.h:309
ADToolImplCommon(MPI_Datatype primalMpiType, MPI_Datatype adjointMpiType)
Definition adToolImplCommon.hpp:45
void deleteIndexTypeBuffer(IndexType *&buf) const
Delete the array of the index variables.
Definition adToolImplCommon.hpp:77
bool isModifiedBufferRequired() const
Indicates if the AD tool needs to modify the buffer in order to send the correct data.
Definition adToolImplCommon.hpp:52
void createIndexTypeBuffer(IndexType *&buf, size_t size) const
Create an array for the index variables.
Definition adToolImplCommon.hpp:65
void deletePrimalTypeBuffer(PrimalType *&buf) const
Delete the array of the passive variables.
Definition adToolImplCommon.hpp:69
ADToolBase< Impl, AdjointType, PrimalType, IndexType > Base
Definition adToolImplCommon.hpp:43
bool isOldPrimalsRequired() const
Indicates if MeDiPack needs store the overwritten primal values for the AD tool.
Definition adToolImplCommon.hpp:56
void createPrimalTypeBuffer(PrimalType *&buf, size_t size) const
Create an array for the passive variables.
Definition adToolImplCommon.hpp:60
bool isActiveType() const
If this AD interface represents an AD type.
Definition adToolImplCommon.hpp:48
void PrimalType
The data type used for the floating point data.
Definition adToolInterface.h:67
void IndexType
The data type from the AD tool for the identification of AD variables.
Definition adToolInterface.h:72
Global namespace for MeDiPack - Message Differentiation Package.
Definition adjointInterface.hpp:37