source: trunk/ADOL-C/include/adolc/medipacksupport.h @ 762

Last change on this file since 762 was 762, checked in by mbanovic, 7 months ago

Merged branch "medipacksupport" from "git" into "svn"

The following commits were merged:

commit 0d1b5eec2cca8afdeea3cdffa196efb6cfd60a53
Merge: 72d114b 33bfdb5
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Nov 5 10:03:04 2018 +0000

Merge branch 'medipackSupport' into 'medipacksupport'

Medipack support

See merge request adol-c/adol-c!26

commit 33bfdb5a006c782489bfef1b651ca3bdbceefaf2
Merge: ac55eab cf82982
Author: Max Sagebaum <max.sagebaum@…>
Date: Tue Oct 30 11:19:31 2018 +0100

Merge branch 'medipackSupport' into temp

commit ac55eab9dd8cb8c84926ee56456076392a047c1a
Merge: 72d114b caaac60
Author: Max Sagebaum <max.sagebaum@…>
Date: Tue Oct 30 11:14:09 2018 +0100

Merge remote-tracking branch 'origin/master' into temp

commit cf82982421aaa7d83405ffa3d0c9b6ef88251d0c
Merge: 6aeca20 caaac60
Author: Max Sagebaum <max.sagebaum@…>
Date: Tue Oct 30 11:13:25 2018 +0100

Merge remote-tracking branch 'origin/master' into medipackSupport

commit 6aeca205c2448b4bbc915eb76153ebde19448573
Author: Max Sagebaum <max.sagebaum@…>
Date: Tue Oct 23 22:30:28 2018 +0200

Added suport for ZOS, FOS, FOV forward and reverse.

commit caaac60da4c61b370d106c68064d38c42a7cb6e3
Merge: cc2e0b3 70fc288
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Oct 8 08:53:40 2018 +0000

Merge branch 'fix_adtl_hov_refcntr' into 'master'

Fix undefined reference to adtl_hov::refcounter::refcnt

See merge request adol-c/adol-c!24

commit 70fc288b9ab95b16d3179fcf239ee2208ae1a2c4
Author: Jean-Paul Pelteret <jppelteret@…>
Date: Mon Oct 1 20:53:03 2018 +0200

Fix undefined reference to adtl_hov::refcounter::refcnt

commit cc2e0b3154fb6e62580def4501c4cf3f3d8e32ef
Merge: d7400f5 7c7f24b
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Oct 1 12:26:39 2018 +0000

Merge branch 'docu' into 'master'

Refactor tapeless to traceless

See merge request adol-c/adol-c!23

commit ca397962cde23bde80e03924893e09c84d8728bf
Merge: 9cbc432 d7400f5
Author: Max Sagebaum <max.sagebaum@…>
Date: Fri Sep 28 10:07:41 2018 +0200

Merge remote-tracking branch 'origin/master' into medipackSupport

commit 9cbc4324e0d3e19f97ba5c5474121f0189e60f83
Author: Max Sagebaum <max.sagebaum@…>
Date: Thu Sep 27 14:38:30 2018 +0200

Missing MeDiPack? initialization on trace_on.

commit 76c30290365830d2370a354af949f3bf42df3885
Author: Max Sagebaum <max.sagebaum@…>
Date: Thu Sep 27 09:55:42 2018 +0200

Null pointer fix for initialization.

commit 7c7f24b25479870d58ff19d78a6e394ca28ddb58
Author: mflehmig <martin.schroschk@…>
Date: Thu Sep 20 13:16:06 2018 +0200

Refactor tapeless to traceless

As far as I can see, the official wording is traceless forward mode.
Additonally, the latex label and refs changed to 'traceless'.

commit 72d114b7ac42b8ac493030cedd1df8c9746ba5d4
Author: Max Sagebaum <max.sagebaum@…>
Date: Thu Oct 19 09:25:19 2017 +0200

Added support for MeDiPack? library.

Enable it with the configure options:
--enable-medipack --with-medipack=<path to MeDiPack?>

Tutorial on a how to use will follow.

commit b4ca76279d28407f29901d40953d02a0c5c9140e
Author: Max Sagebaum <max.sagebaum@…>
Date: Mon May 7 14:45:13 2018 +0200

Added support for cbrt function.

commit bc7b8ca61865058fac097410fd94a44fba281131
Author: Max Sagebaum <max.sagebaum@…>
Date: Thu Mar 1 10:31:18 2018 +0100

Changes for new interface.

commit cd1e82778c8540221b24559d5097bf6d00597e19
Author: Max Sagebaum <max.sagebaum@…>
Date: Thu Nov 16 14:31:07 2017 +0100

Changes to new MeDiPack? interface for adjoint values.

commit 55bcb0ffd5a9496817bffac0bd2c9489ed8ce992
Author: Max Sagebaum <max.sagebaum@…>
Date: Thu Oct 19 09:25:19 2017 +0200

Added support for MeDiPack? library.

Enable it with the configure options:
--enable-medipack --with-medipack=<path to MeDiPack?>

Tutorial on a how to use will follow.

File size: 4.5 KB
Line 
1/*----------------------------------------------------------------------------
2 ADOL-C -- Automatic Differentiation by Overloading in C++
3 File:     ampisupportAdolc.cpp
4 Revision: $Id$
5
6 Copyright (c) Jean Utke
7
8 This file is part of ADOL-C. This software is provided as open source.
9 Any use, reproduction, or distribution of the software constitutes
10 recipient's acceptance of the terms of the accompanying license file.
11
12----------------------------------------------------------------------------*/
13
14#if !defined(ADOLC_MEDISUPPORTADOLC_H)
15#define ADOLC_MEDISUPPORTADOLC_H 1
16
17#include "adouble.h"
18
19#include <medi/medi.hpp>
20#include <medi/adjointInterface.hpp>
21#include <medi/adToolImplCommon.hpp>
22#include <medi/ampi/types/indexTypeHelper.hpp>
23
24void mediAddHandle(medi::HandleBase* h);
25void mediInitStatic();
26void mediFinalizeStatic();
27
28struct AdolcTool final : public medi::ADToolImplCommon<AdolcTool, true, true, double, double, double, int> {
29  typedef adouble Type;
30  typedef void AdjointType;
31  typedef double ModifiedType;
32  typedef double PrimalType;
33  typedef int IndexType;
34
35  static MPI_Datatype MpiType;
36  static MPI_Datatype ModifiedMpiType;
37  static MPI_Datatype PrimalMpiType;
38  static MPI_Datatype AdjointMpiType;
39
40  typedef medi::MpiTypeDefault<AdolcTool> MediType;
41  static MediType* MPI_TYPE;
42  static medi::AMPI_Datatype MPI_INT_TYPE;
43
44  static medi::OperatorHelper<medi::FunctionHelper<adouble, double, double, int, double, AdolcTool>> operatorHelper;
45
46  static void initTypes() {
47    // create the mpi type for ADOL-c
48    MPI_Type_contiguous(sizeof(adouble), MPI_BYTE, &MpiType);
49    MPI_Type_commit(&MpiType);
50
51    ModifiedMpiType = MPI_DOUBLE;
52    PrimalMpiType = MPI_DOUBLE;
53    AdjointMpiType = MPI_DOUBLE;
54  }
55
56  static void init() {
57    initTypes();
58
59    MPI_TYPE = new MediType();
60
61    operatorHelper.init(MPI_TYPE);
62    MPI_INT_TYPE = operatorHelper.MPI_INT_TYPE;
63
64
65    mediInitStatic();
66  }
67
68  static void finalizeTypes() {
69  }
70
71  static void finalize() {
72
73    mediFinalizeStatic();
74
75    operatorHelper.finalize();
76
77    if(nullptr != MPI_TYPE) {
78      delete MPI_TYPE;
79      MPI_TYPE = nullptr;
80    }
81
82    finalizeTypes();
83  }
84
85  AdolcTool(MPI_Datatype primalMpiType, MPI_Datatype adjointMpiType) :
86    medi::ADToolImplCommon<AdolcTool, true, true, double, double, double, int>(primalMpiType, adjointMpiType) {}
87
88
89  inline bool isActiveType() const {
90    return true;
91  }
92
93  inline  bool isHandleRequired() const {
94    return isTaping();
95  }
96
97  inline bool isOldPrimalsRequired() const {
98    return true;
99  }
100
101  inline void startAssembly(medi::HandleBase* h) const {
102    MEDI_UNUSED(h);
103
104  }
105
106  inline void addToolAction(medi::HandleBase* h) const {
107    if(NULL != h) {
108      mediAddHandle(h);
109    }
110  }
111
112  inline void stopAssembly(medi::HandleBase* h) const {
113    MEDI_UNUSED(h);
114  }
115
116  medi::AMPI_Op convertOperator(medi::AMPI_Op op) const {
117    return operatorHelper.convertOperator(op);
118  }
119
120
121  inline void createPrimalTypeBuffer(PrimalType* &buf, size_t size) const {
122    buf = new PrimalType[size];
123  }
124
125  inline void createIndexTypeBuffer(IndexType* &buf, size_t size) const {
126    buf = new IndexType[size];
127  }
128
129  inline void deletePrimalTypeBuffer(PrimalType* &buf) const {
130    if(NULL != buf) {
131      delete [] buf;
132      buf = NULL;
133    }
134  }
135
136  inline void deleteIndexTypeBuffer(IndexType* &buf) const {
137    if(NULL != buf) {
138      delete [] buf;
139      buf = NULL;
140    }
141  }
142
143  static inline int getIndex(const Type& value) {
144    return value.loc();
145  }
146
147  static inline void clearIndex(Type& value) {
148    // do nothing
149  }
150
151  static inline PrimalType getValue(const Type& value) {
152    return value.value();
153  }
154
155  static inline void setIntoModifyBuffer(ModifiedType& modValue, const Type& value) {
156    modValue = value.value();
157  }
158
159  static inline void getFromModifyBuffer(const ModifiedType& modValue, Type& value) {
160    value.setValue(modValue);
161  }
162
163  static void createIndex(Type& value, IndexType& index) {
164    MEDI_UNUSED(value);
165    MEDI_UNUSED(index);
166
167    // do nothing indices are created in registerValue
168  }
169
170  static inline void registerValue(Type& value, PrimalType& oldPrimal, IndexType& index) {
171    MEDI_UNUSED(oldPrimal);
172    // do nothing value should have an index
173
174    index = value.loc();
175  }
176
177  static PrimalType getPrimalFromMod(const ModifiedType& modValue) {
178    return modValue;
179  }
180
181  static void setPrimalToMod(ModifiedType& modValue, const PrimalType& value) {
182    modValue = value;
183  }
184
185  static void modifyDependency(ModifiedType& inval, ModifiedType& inoutval) {
186    MEDI_UNUSED(inval);
187    MEDI_UNUSED(inoutval);
188
189    // no dependency tracking possible
190  }
191};
192
193#endif
Note: See TracBrowser for help on using the repository browser.