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 #define MEDI_1_4_OR_GREATER MEDI_MAJOR_VERSION > 1 || (MEDI_MAJOR_VERSION == 1 && MEDI_MINOR_VERSION >= 4)
54 template<
typename T_Type>
55 struct CoDiPackForwardTool :
public medi::ADToolBase<CoDiPackForwardTool<T_Type>, typename T_Type::Gradient,
56 typename T_Type::PassiveReal, int> {
59 using Type =
CODI_DD(T_Type, CODI_DEFAULT_LHS_EXPRESSION);
61 using PrimalType =
typename Type::Real;
62 using AdjointType = void;
63 using ModifiedType = Type;
64 using IndexType = int;
66 using Base = medi::ADToolBase<CoDiPackForwardTool, typename Type::Gradient, typename Type::PassiveReal, int>;
68 #if MEDI_1_4_OR_GREATER
69 using CallbackFuncTyped =
typename Base::CallbackFuncTyped;
73 medi::OperatorHelper<medi::FunctionHelper<Type, Type,
typename Type::PassiveReal,
typename Type::Identifier,
74 typename Type::Gradient, CoDiPackForwardTool<Type> > >;
81 CoDiPackForwardTool(MPI_Datatype primalMpiType, MPI_Datatype adjointMpiType)
82 : Base(primalMpiType, adjointMpiType), opHelper() {
86 ~CoDiPackForwardTool() {
118 medi::AMPI_Op convertOperator(medi::AMPI_Op op)
const {
119 return opHelper.convertOperator(op);
122 using Base::createPrimalTypeBuffer;
123 CODI_INLINE_NO_FA void createPrimalTypeBuffer(PrimalType*& buf,
size_t size)
const {
124 buf =
new PrimalType[size];
127 using Base::createIndexTypeBuffer;
128 CODI_INLINE_NO_FA void createIndexTypeBuffer(IndexType*& buf,
size_t size)
const {
129 buf =
new IndexType[size];
132 using Base::deletePrimalTypeBuffer;
134 if (
nullptr != buf) {
140 using Base::deleteIndexTypeBuffer;
142 if (
nullptr != buf) {
149 return value.getIdentifier();
154 value.getIdentifier() = 0;
163 return value.getValue();
166 #if MEDI_1_4_OR_GREATER
167 using Base::iterateIdentifiers;
168 void iterateIdentifiers(IndexType* indices,
int elements, CallbackFuncTyped func,
void* userData)
const {
169 for (
int i = 0; i < elements; i += 1) {
170 func(&indices[i], userData);
175 static CODI_INLINE_NO_FA void setIntoModifyBuffer(ModifiedType& modValue, Type
const& value) {
179 static CODI_INLINE_NO_FA void getFromModifyBuffer(ModifiedType
const& modValue, Type& value) {
183 static CODI_INLINE_NO_FA void registerValue(Type& value, PrimalType& oldValue,
int& index) {
187 static PrimalType getPrimalFromMod(ModifiedType
const& modValue) {
188 return modValue.value();
191 static void setPrimalToMod(ModifiedType& modValue, PrimalType
const& value) {
192 modValue.value() = value;
195 static void modifyDependency(ModifiedType& inval, ModifiedType& inoutval) {
#define CODI_INLINE_NO_FA
See codi::Config::ForcedInlines.
Definition config.h:471
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:97
inlinetypename DataExtraction< Type >::Real getValue(Type const &v)
Extract an aggregate of primal values from an aggregate of active types.
Definition realTraits.hpp:381
CoDiPack - Code Differentiation Package.
Definition codi.hpp:98
inlinevoid CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:55