37#include <medi/adToolInterface.h>
38#include <medi/ampi/ampiMisc.h>
40#include <medi/ampi/typeDefault.hpp>
41#include <medi/ampi/types/indexTypeHelper.hpp>
44#include "../../expressions/lhsExpressionInterface.hpp"
50#ifndef DOXYGEN_DISABLE
52 template<
typename T_Type>
53 struct CoDiPackForwardTool :
public medi::ADToolBase<CoDiPackForwardTool<T_Type>, typename T_Type::Gradient,
54 typename T_Type::PassiveReal, int> {
57 using Type =
CODI_DD(T_Type, CODI_DEFAULT_LHS_EXPRESSION);
59 using PrimalType =
typename Type::Real;
60 using AdjointType = void;
61 using ModifiedType = Type;
62 using IndexType = int;
64 using Base = medi::ADToolBase<CoDiPackForwardTool, typename Type::Gradient, typename Type::PassiveReal, int>;
67 medi::OperatorHelper<medi::FunctionHelper<Type, Type,
typename Type::PassiveReal,
typename Type::Identifier,
68 typename Type::Gradient, CoDiPackForwardTool<Type> > >;
75 CoDiPackForwardTool(MPI_Datatype primalMpiType, MPI_Datatype adjointMpiType)
76 : Base(primalMpiType, adjointMpiType), opHelper() {
80 ~CoDiPackForwardTool() {
112 medi::AMPI_Op convertOperator(medi::AMPI_Op op)
const {
113 return opHelper.convertOperator(op);
116 CODI_INLINE_NO_FA void createPrimalTypeBuffer(PrimalType*& buf,
size_t size)
const {
117 buf =
new PrimalType[size];
120 CODI_INLINE_NO_FA void createIndexTypeBuffer(IndexType*& buf,
size_t size)
const {
121 buf =
new IndexType[size];
125 if (
nullptr != buf) {
132 if (
nullptr != buf) {
139 return value.getIdentifier();
144 value.getIdentifier() = 0;
153 return value.getValue();
156 static CODI_INLINE_NO_FA void setIntoModifyBuffer(ModifiedType& modValue, Type
const& value) {
160 static CODI_INLINE_NO_FA void getFromModifyBuffer(ModifiedType
const& modValue, Type& value) {
164 static CODI_INLINE_NO_FA void registerValue(Type& value, PrimalType& oldValue,
int& index) {
168 static PrimalType getPrimalFromMod(ModifiedType
const& modValue) {
169 return modValue.value();
172 static void setPrimalToMod(ModifiedType& modValue, PrimalType
const& value) {
173 modValue.value() = value;
176 static void modifyDependency(ModifiedType& inval, ModifiedType& inoutval) {
#define CODI_INLINE_NO_FA
See codi::Config::ForcedInlines.
Definition config.h:459
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
DataExtraction< Type >::Real getValue(Type const &v)
Extract the primal values from a type of aggregated active types.
Definition realTraits.hpp:210
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
void CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:46