MeDiPack  1.3.0
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-2024 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/codi).
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
43 ADToolImplCommon(MPI_Datatype primalMpiType, MPI_Datatype adjointMpiType) :
44 ADToolBase<Impl, AdjointType, PrimalType, IndexType>(primalMpiType, adjointMpiType) {}
45
46 inline bool isActiveType() const {
47 return true;
48 }
49
50 inline bool isModifiedBufferRequired() const {
51 return modifiedBuffer;
52 }
53
54 inline bool isOldPrimalsRequired() const {
55 return restorePrimal;
56 }
57
58 inline void createPrimalTypeBuffer(PrimalType* &buf, size_t size) const {
59 buf = new PrimalType[size];
60 }
61
62 inline void createIndexTypeBuffer(IndexType* &buf, size_t size) const {
63 buf = new IndexType[size];
64 }
65
66 inline void deletePrimalTypeBuffer(PrimalType* &buf) const {
67 if(NULL != buf) {
68 delete [] buf;
69 buf = NULL;
70 }
71 }
72
73 inline void deleteIndexTypeBuffer(IndexType* &buf) const {
74 if(NULL != buf) {
75 delete [] buf;
76 buf = NULL;
77 }
78 }
79 };
80}
Definition adToolInterface.h:294
Definition adToolImplCommon.hpp:40
ADToolImplCommon(MPI_Datatype primalMpiType, MPI_Datatype adjointMpiType)
Definition adToolImplCommon.hpp:43
void deleteIndexTypeBuffer(IndexType *&buf) const
Delete the array of the index variables.
Definition adToolImplCommon.hpp:73
bool isModifiedBufferRequired() const
Indicates if the AD tool needs to modify the buffer in order to send the correct data.
Definition adToolImplCommon.hpp:50
void createIndexTypeBuffer(IndexType *&buf, size_t size) const
Create an array for the index variables.
Definition adToolImplCommon.hpp:62
void deletePrimalTypeBuffer(PrimalType *&buf) const
Delete the array of the passive variables.
Definition adToolImplCommon.hpp:66
bool isOldPrimalsRequired() const
Indicates if MeDiPack needs store the overwritten primal values for the AD tool.
Definition adToolImplCommon.hpp:54
void createPrimalTypeBuffer(PrimalType *&buf, size_t size) const
Create an array for the passive variables.
Definition adToolImplCommon.hpp:58
bool isActiveType() const
If this AD interface represents an AD type.
Definition adToolImplCommon.hpp:46
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
void AdjointType
The data type that is used for the adjoint variables.
Definition adToolInterface.h:62
Global namespace for MeDiPack - Message Differentiation Package.
Definition adjointInterface.hpp:37