Skip to content

Commit 7320d68

Browse files
committed
Compatibility with MeDiPack < 1.4.0.
1 parent bbaedc9 commit 7320d68

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

include/codi/tools/mpi/codiForwardMeDiPackTool.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ namespace codi {
4949

5050
#ifndef DOXYGEN_DISABLE
5151

52+
#define MEDI_1_4_OR_GREATER MEDI_MAJOR_VERSION > 1 || (MEDI_MAJOR_VERSION == 1 && MEDI_MINOR_VERSION >= 4)
53+
5254
template<typename T_Type>
5355
struct CoDiPackForwardTool : public medi::ADToolBase<CoDiPackForwardTool<T_Type>, typename T_Type::Gradient,
5456
typename T_Type::PassiveReal, int> {
@@ -63,7 +65,9 @@ namespace codi {
6365

6466
using Base = medi::ADToolBase<CoDiPackForwardTool, typename Type::Gradient, typename Type::PassiveReal, int>;
6567

68+
#if MEDI_1_4_OR_GREATER
6669
using CallbackFuncTyped = typename Base::CallbackFuncTyped;
70+
#endif
6771

6872
using OpHelper =
6973
medi::OperatorHelper<medi::FunctionHelper<Type, Type, typename Type::PassiveReal, typename Type::Identifier,
@@ -115,21 +119,25 @@ namespace codi {
115119
return opHelper.convertOperator(op);
116120
}
117121

122+
using Base::createPrimalTypeBuffer;
118123
CODI_INLINE_NO_FA void createPrimalTypeBuffer(PrimalType*& buf, size_t size) const {
119124
buf = new PrimalType[size];
120125
}
121126

127+
using Base::createIndexTypeBuffer;
122128
CODI_INLINE_NO_FA void createIndexTypeBuffer(IndexType*& buf, size_t size) const {
123129
buf = new IndexType[size];
124130
}
125131

132+
using Base::deletePrimalTypeBuffer;
126133
CODI_INLINE_NO_FA void deletePrimalTypeBuffer(PrimalType*& buf) const {
127134
if (nullptr != buf) {
128135
delete[] buf;
129136
buf = nullptr;
130137
}
131138
}
132139

140+
using Base::deleteIndexTypeBuffer;
133141
CODI_INLINE_NO_FA void deleteIndexTypeBuffer(IndexType*& buf) const {
134142
if (nullptr != buf) {
135143
delete[] buf;
@@ -155,12 +163,14 @@ namespace codi {
155163
return value.getValue();
156164
}
157165

166+
#if MEDI_1_4_OR_GREATER
158167
using Base::iterateIdentifiers;
159168
void iterateIdentifiers(IndexType* indices, int elements, CallbackFuncTyped func, void* userData) const {
160169
for (int i = 0; i < elements; i += 1) {
161170
func(&indices[i], userData);
162171
}
163172
}
173+
#endif
164174

165175
static CODI_INLINE_NO_FA void setIntoModifyBuffer(ModifiedType& modValue, Type const& value) {
166176
CODI_UNUSED(modValue, value);

include/codi/tools/mpi/codiReverseMeDiPackTool.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ namespace codi {
5454

5555
#ifndef DOXYGEN_DISABLE
5656

57+
#define MEDI_1_4_OR_GREATER MEDI_MAJOR_VERSION > 1 || (MEDI_MAJOR_VERSION == 1 && MEDI_MINOR_VERSION >= 4)
58+
5759
template<typename T_Type>
5860
struct CoDiMeDiAdjointInterfaceWrapper : public medi::AdjointInterface {
5961
public:
@@ -347,16 +349,25 @@ namespace codi {
347349

348350
static void callHandleIterateInputs(Tape* tape, void* h, IterCallback func, void* userData) {
349351
CODI_UNUSED(tape);
350-
352+
#if MEDI_1_4_OR_GREATER
351353
medi::HandleBase* handle = static_cast<medi::HandleBase*>(h);
352354
handle->funcIterateInputIds(handle, (::medi::CallbackFunc)func, userData);
355+
#else
356+
CODI_UNUSED(h, func, userData);
357+
CODI_EXCEPTION("Identifier iteration requires at leas MeDiPack 1.4.0.");
358+
#endif
353359
}
354360

355361
static void callHandleIterateOutputs(Tape* tape, void* h, IterCallback func, void* userData) {
356362
CODI_UNUSED(tape);
357363

364+
#if MEDI_1_4_OR_GREATER
358365
medi::HandleBase* handle = static_cast<medi::HandleBase*>(h);
359366
handle->funcIterateOutputIds(handle, (::medi::CallbackFunc)func, userData);
367+
#else
368+
CODI_UNUSED(h, func, userData);
369+
CODI_EXCEPTION("Identifier iteration requires at leas MeDiPack 1.4.0.");
370+
#endif
360371
}
361372

362373
static Tape& getTape() {

0 commit comments

Comments
 (0)