Skip to content

Commit 9ac1faa

Browse files
committed
Merge branch 'documentation' into 'derivgrind'
Improve documentation and fix compiler warnings See merge request aehle/valgrind!34
2 parents ae97ba7 + 2cbbcfe commit 9ac1faa

23 files changed

+210
-140
lines changed

.github/workflows/regression.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ jobs:
2121
- name: Configure and build
2222
run: |
2323
./autogen.sh
24-
./configure --prefix=$PWD/install --enable-fortran --enable-python3 --enable-mlframeworks SHADOW_LAYERS_64=16,16,16,16
24+
./configure --prefix=$PWD/install --enable-fortran --enable-python --enable-mlframeworks SHADOW_LAYERS_64=16,16,16,16
2525
make install
2626
- name: Forward-mode regression tests
2727
run: python3 derivgrind/diff_tests/run_tests.py dot* --prefix=$PWD/install 2>&1 | tee forward_log
2828
- name: Upload log of forward-mode regression tests
29-
uses: actions/upload-artifact@v3
29+
uses: actions/upload-artifact@v4
3030
with:
3131
name: forward_log
3232
path: forward_log
3333
retention-days: 7
3434
- name: Reverse-mode regression tests
3535
run: python3 derivgrind/diff_tests/run_tests.py bar* --prefix=$PWD/install 2>&1 | tee reverse_log
3636
- name: Upload log of reverse-mode regression tests
37-
uses: actions/upload-artifact@v3
37+
uses: actions/upload-artifact@v4
3838
with:
3939
name: reverse_log
4040
path: reverse_log

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ It has been implemented in the [Valgrind](https://valgrind.org/)
88
framework for building dynamic analysis tools.
99

1010
For more information beyond this [README.md](README.md), you may have a look at our papers:
11-
- M. Aehle, J. Blühdorn, M. Sagebaum, N. R. Gauger: *Forward-Mode Automatic Differentiation of Compiled Programs*. [arXiv:2209.01895](https://arxiv.org/abs/2209.01895), 2022.
11+
- M. Aehle, J. Blühdorn, M. Sagebaum, N. R. Gauger: *Forward-Mode Automatic Differentiation of Compiled Programs*. [ACM Transactions on Mathematical Software](https://doi.org/10.1145/3716309), 2025.
1212
- M. Aehle, J. Blühdorn, M. Sagebaum, N. R. Gauger: *Reverse-Mode Automatic Differentiation of Compiled Programs*. [arXiv:2212.13760](https://arxiv.org/abs/2212.13760), 2022.
1313

1414
## Building Derivgrind
@@ -19,11 +19,10 @@ this file to reproducibly obtain an environment that contains all dependencies.
1919
Clone this repository with `git clone --recursive`, and run the following commands in the root directory:
2020
```bash
2121
./autogen.sh
22-
./configure --prefix=$PWD/install --enable-python --enable-fortran
22+
./configure --prefix=$PWD/install
2323
make install
2424
```
25-
The flags `--enable-python` and `--enable-fortran` enable wrappers for client request (see below), which
26-
are necessary to run all unit tests successfully. For many applications, you may however leave them out.
25+
You may supply arguments `--enable-python --enable-fortran` to the `./configure` call to build client request wrappers for Python and Fortran. These wrappers allow to declare AD inputs and outputs from Python and Fortran code, and are required to run Derivgrind's testcases for these languages. Building these wrappers requires Python C extension headers (e.g. `python3-dev`) and a Fortran compiler (e.g. `f77`), respectively, to be installed on your system.
2726

2827
## Running Testcases
2928

@@ -34,7 +33,7 @@ python3 run_tests.py dot_amd64_gcc_double_addition
3433
The names of the unit tests are composed of an AD mode, architecture, language/compiler, floating-point type and
3534
arithmetic formula. You may use `*` as a wildcard to run several tests at once. You may specify the
3635
Derivgrind installation directory with `--prefix=path`. Specify a directory with `--tempdir=path` if
37-
you want to inspect the temporary files created by Derivgrind and the test system.
36+
you want to inspect the temporary files created by Derivgrind and the test system. Derivgrind must have been configured with `--enable-python` and `--enable-fortran` to run the Python and Fortran tests.
3837

3938
## Differentiating a Simple C++ Program in Forward Mode
4039
Compile a simple C++ "client" program from
@@ -141,7 +140,7 @@ Placing the directory on a ramdisk like `/dev/shm/` might speed the recording up
141140
in manifold ways. For example, a bitwise logical "and" can be used to set the
142141
sign bit to zero, and thereby compute the absolute value. Derivgrind recognizes only
143142
the most important of these constructs. More details can be found in our
144-
[forward-mode paper](https://arxiv.org/abs/2209.01895). Generally, avoid direct manipulation
143+
[forward-mode paper](https://doi.org/10.1145/3716309). Generally, avoid direct manipulation
145144
of a floating-point number's binary representation in your program, and avoid the
146145
differentiation of highly optimized numerical libraries.
147146
- While Valgrind supports many more platforms, only X86/Linux and AMD64/Linux

derivgrind/bar/dg_bar.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ V256* dg_bar_shadow_mem_buffer;
5858

5959
#define dg_rounding_mode IRExpr_Const(IRConst_U32(0))
6060

61-
/* --- Define ExpressionHandling. --- */
62-
// some functions are not static because the trick-instrumention also needs them
61+
/* --- Define tape-recording ExpressionHandling. --- */
62+
/* See dg_expressionhandling.h for documentation of dg_bar_wrtmp, dg_bar_rdtmp etc. */
63+
64+
/* some functions are not declared static because the trick-instrumention reuses them */
6365

6466
void dg_bar_wrtmp(DiffEnv* diffenv, IRTemp temp, void* expr){
6567
IRStmt* spLo = IRStmt_WrTmp(temp+diffenv->tmp_offset, ((IRExpr**)expr)[0]);
@@ -106,15 +108,15 @@ void* dg_bar_geti(DiffEnv* diffenv, Int offset, IRType type, IRRegArray* descr,
106108
* \param addr Address for memory location whose shadow should be written to.
107109
* \param size Number of bytes per layer to be copied.
108110
*/
109-
void dg_bar_x86g_amd64g_dirtyhelper_store(Addr addr, ULong size){
111+
static void dg_bar_x86g_amd64g_dirtyhelper_store(Addr addr, ULong size){
110112
dg_bar_shadowSet((void*)addr,dg_bar_shadow_mem_buffer,dg_bar_shadow_mem_buffer+1,size);
111113
}
112114

113115
/*! Dirty call to copy shadow data from shadow memory into buffer.
114116
* \param addr Address for memory location whose shadow should be read from.
115117
* \param size Number of bytes per layer to be copied.
116118
*/
117-
void dg_bar_x86g_amd64g_dirtyhelper_load(Addr addr, ULong size){
119+
static void dg_bar_x86g_amd64g_dirtyhelper_load(Addr addr, ULong size){
118120
dg_bar_shadowGet((void*)addr,dg_bar_shadow_mem_buffer,dg_bar_shadow_mem_buffer+1,size);
119121
}
120122

@@ -166,11 +168,11 @@ void* dg_bar_load(DiffEnv* diffenv, IRExpr* addr, IRType type){
166168
* It just writes the lower 4 bytes of the index to the beginning
167169
* of the 80-bit blocks in the lower layer of shadow memory.
168170
*/
169-
void dg_bar_x86g_amd64g_dirtyhelper_storeF80le_Lo ( Addr addrU, ULong i64 )
171+
static void dg_bar_x86g_amd64g_dirtyhelper_storeF80le_Lo ( Addr addrU, ULong i64 )
170172
{
171173
dg_bar_shadowSet((void*)addrU,(void*)&i64,NULL,4);
172174
}
173-
void dg_bar_x86g_amd64g_dirtyhelper_storeF80le_Hi ( Addr addrU, ULong i64 )
175+
static void dg_bar_x86g_amd64g_dirtyhelper_storeF80le_Hi ( Addr addrU, ULong i64 )
174176
{
175177
dg_bar_shadowSet((void*)addrU,NULL,(void*)&i64,4);
176178
}
@@ -180,20 +182,20 @@ void dg_bar_x86g_amd64g_dirtyhelper_storeF80le_Hi ( Addr addrU, ULong i64 )
180182
* It just reads the lower 4 bytes of the index from the beginning
181183
* of the 80-bit blocks in the lower layer of shadow memory.
182184
*/
183-
ULong dg_bar_x86g_amd64g_dirtyhelper_loadF80le_Lo ( Addr addrU )
185+
static ULong dg_bar_x86g_amd64g_dirtyhelper_loadF80le_Lo ( Addr addrU )
184186
{
185187
ULong i64_Lo, i64_Hi;
186188
dg_bar_shadowGet((void*)addrU, (void*)&i64_Lo, (void*)&i64_Hi, 4);
187189
return i64_Lo;
188190
}
189-
ULong dg_bar_x86g_amd64g_dirtyhelper_loadF80le_Hi ( Addr addrU )
191+
static ULong dg_bar_x86g_amd64g_dirtyhelper_loadF80le_Hi ( Addr addrU )
190192
{
191193
ULong i64_Lo, i64_Hi;
192194
dg_bar_shadowGet((void*)addrU, (void*)&i64_Lo, (void*)&i64_Hi, 4);
193195
return i64_Hi;
194196
}
195197

196-
void dg_bar_dirty_storeF80le(DiffEnv* diffenv, IRExpr* addr, void* expr){
198+
static void dg_bar_dirty_storeF80le(DiffEnv* diffenv, IRExpr* addr, void* expr){
197199
IRDirty* ddLo = unsafeIRDirty_0_N(
198200
0, "dg_bar_x86g_amd64g_dirtyhelper_storeF80le_Lo",
199201
&dg_bar_x86g_amd64g_dirtyhelper_storeF80le_Lo,
@@ -206,7 +208,7 @@ void dg_bar_dirty_storeF80le(DiffEnv* diffenv, IRExpr* addr, void* expr){
206208
addStmtToIRSB(diffenv->sb_out, IRStmt_Dirty(ddHi));
207209
}
208210

209-
void dg_bar_dirty_loadF80le(DiffEnv* diffenv, IRExpr* addr, IRTemp temp){
211+
static void dg_bar_dirty_loadF80le(DiffEnv* diffenv, IRExpr* addr, IRTemp temp){
210212
IRDirty* ddLo = unsafeIRDirty_1_N(
211213
temp+diffenv->tmp_offset,
212214
0, "dg_bar_x86g_amd64g_dirtyhelper_loadF80le_Lo",
@@ -268,7 +270,7 @@ void* dg_bar_ite(DiffEnv* diffenv, IRExpr* cond, void* dtrue, void* dfalse){
268270
return (void*)mkIRExprVec_2(exLo,exHi);
269271
}
270272

271-
ULong dg_bar_writeToTape_call(ULong index1Lo, ULong index1Hi, ULong index2Lo, ULong index2Hi, ULong diff1, ULong diff2){
273+
static ULong dg_bar_writeToTape_call(ULong index1Lo, ULong index1Hi, ULong index2Lo, ULong index2Hi, ULong diff1, ULong diff2){
272274
// assemble 8-byte indices from 4-byte beginnings in both shadow layers
273275
UInt index1[2], index2[2];
274276
index1[0] = *(UInt*)&index1Lo;
@@ -279,7 +281,7 @@ ULong dg_bar_writeToTape_call(ULong index1Lo, ULong index1Hi, ULong index2Lo, UL
279281
return returnindex;
280282
}
281283

282-
void dg_bar_writeToTape_value_call(ULong value, ULong index){
284+
static void dg_bar_writeToTape_value_call(ULong value, ULong index){
283285
if(index!=0){
284286
valuesAddStatement(*(double*)&value);
285287
}
@@ -302,7 +304,7 @@ void dg_bar_writeToTape_value_call(ULong value, ULong index){
302304
* new index assigned to the result.
303305
*
304306
*/
305-
IRExpr** dg_bar_writeToTape(DiffEnv* diffenv, IRExpr* index1Lo, IRExpr* index1Hi, IRExpr* index2Lo, IRExpr* index2Hi, IRExpr* diff1, IRExpr* diff2, IRExpr* value){
307+
static IRExpr** dg_bar_writeToTape(DiffEnv* diffenv, IRExpr* index1Lo, IRExpr* index1Hi, IRExpr* index2Lo, IRExpr* index2Hi, IRExpr* diff1, IRExpr* diff2, IRExpr* value){
306308
IRTemp returnindex = newIRTemp(diffenv->sb_out->tyenv,Ity_I64);
307309
IRDirty* dd = unsafeIRDirty_1_N(
308310
returnindex,
@@ -328,7 +330,7 @@ IRExpr** dg_bar_writeToTape(DiffEnv* diffenv, IRExpr* index1Lo, IRExpr* index1Hi
328330
return mkIRExprVec_2(exLo,exHi);
329331
}
330332

331-
void* dg_bar_operation(DiffEnv* diffenv, IROp op,
333+
static void* dg_bar_operation(DiffEnv* diffenv, IROp op,
332334
IRExpr* arg1, IRExpr* arg2, IRExpr* arg3, IRExpr* arg4,
333335
void* i1, void* i2, void* i3, void* i4){
334336
IRExpr *i1Lo=NULL, *i1Hi=NULL, *i2Lo=NULL, *i2Hi=NULL, *i3Lo=NULL, *i3Hi=NULL, *i4Lo=NULL, *i4Hi=NULL;
@@ -358,7 +360,7 @@ void* dg_bar_operation(DiffEnv* diffenv, IROp op,
358360
}
359361
}
360362

361-
void* dg_bar_ccall(DiffEnv* diffenv, IRCallee* cee, IRType retty, IRExpr** args, void** modified_args){
363+
static void* dg_bar_ccall(DiffEnv* diffenv, IRCallee* cee, IRType retty, IRExpr** args, void** modified_args){
362364
return NULL;
363365
}
364366

derivgrind/bar/dg_bar.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,19 @@ void dg_bar_initialize(void);
5353
*/
5454
void dg_bar_finalize(void);
5555

56-
// Declarations of the tool functions are required by the bit-trick-finding instrumentation.
57-
#ifdef DG_BAR_H_INCLUDE_TOOL_FUNCTIONS
58-
static void dg_bar_wrtmp(DiffEnv* diffenv, IRTemp temp, void* expr);
59-
static void* dg_bar_rdtmp(DiffEnv* diffenv, IRTemp temp);
60-
static void dg_bar_puti(DiffEnv* diffenv, Int offset, void* expr, IRRegArray* descr, IRExpr* ix);
61-
static void* dg_bar_geti(DiffEnv* diffenv, Int offset, IRType type, IRRegArray* descr, IRExpr* ix);
62-
static void dg_bar_store(DiffEnv* diffenv, IRExpr* addr, void* expr, IRExpr* guard);
63-
static void* dg_bar_load(DiffEnv* diffenv, IRExpr* addr, IRType type);
64-
static void* dg_bar_constant(DiffEnv* diffenv, IRConstTag type);
65-
static void* dg_bar_default_(DiffEnv* diffenv, IRType type);
66-
static IRExpr* dg_bar_compare(DiffEnv* diffenv, void* arg1, void* arg2);
67-
static void* dg_bar_ite(DiffEnv* diffenv, IRExpr* cond, void* dtrue, void* dfalse);
68-
extern V256* dg_bar_shadow_mem_buffer;
69-
#endif
56+
// some tool functions are reused by the bit-trick-finding instrumentation, thus declared here
57+
void dg_bar_wrtmp(DiffEnv* diffenv, IRTemp temp, void* expr);
58+
void* dg_bar_rdtmp(DiffEnv* diffenv, IRTemp temp);
59+
void dg_bar_puti(DiffEnv* diffenv, Int offset, void* expr, IRRegArray* descr, IRExpr* ix);
60+
void* dg_bar_geti(DiffEnv* diffenv, Int offset, IRType type, IRRegArray* descr, IRExpr* ix);
61+
void dg_bar_store(DiffEnv* diffenv, IRExpr* addr, void* expr, IRExpr* guard);
62+
void* dg_bar_load(DiffEnv* diffenv, IRExpr* addr, IRType type);
63+
void* dg_bar_constant(DiffEnv* diffenv, IRConstTag type);
64+
void* dg_bar_default_(DiffEnv* diffenv, IRType type);
65+
IRExpr* dg_bar_compare(DiffEnv* diffenv, void* arg1, void* arg2);
66+
void* dg_bar_ite(DiffEnv* diffenv, IRExpr* cond, void* dtrue, void* dfalse);
67+
extern V256* dg_bar_shadow_mem_buffer;
68+
7069

7170

7271
#endif // DG_BAR_H

derivgrind/bar/dg_bar_shadow.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "externals/flexible-shadow/flexible-shadow-valgrindstdlib.hpp"
3434
#include <pub_tool_libcbase.h>
3535
#include "dg_utils.h"
36+
#include "dg_bar_shadow.h"
3637

3738
#ifndef SHADOW_LAYERS_32
3839
#define SHADOW_LAYERS_32 18,14
@@ -48,8 +49,11 @@
4849
#endif
4950

5051
struct ShadowLeafBar {
52+
#pragma GCC diagnostic push
53+
#pragma GCC diagnostic ignored "-Wunused-value" // see dg_dot_shadow.cpp
5154
UChar data_Lo[1ul<<(SHADOW_LAYERS)];
5255
UChar data_Hi[1ul<<(SHADOW_LAYERS)];
56+
#pragma GCC diagnostic pop
5357
static ShadowLeafBar distinguished;
5458
};
5559
ShadowLeafBar ShadowLeafBar::distinguished;
@@ -58,7 +62,7 @@ using ShadowMapTypeBar = ShadowMap<Addr,ShadowLeafBar,ValgrindStandardLibraryInt
5862

5963
ShadowMapTypeBar* sm_bar2;
6064

61-
extern "C" void dg_bar_shadowGet(void* sm_address, void* real_address_Lo, void* real_address_Hi, int size){
65+
extern "C" void dg_bar_shadowGet(void* sm_address, void* real_address_Lo, void* real_address_Hi, unsigned int size){
6266
ShadowLeafBar* leaf = sm_bar2->leaf_for_read((Addr)sm_address);
6367
Addr contiguousSize = sm_bar2->contiguousElements((Addr)sm_address);
6468
ULong index = sm_bar2->index((Addr)sm_address);
@@ -80,7 +84,7 @@ extern "C" void dg_bar_shadowGet(void* sm_address, void* real_address_Lo, void*
8084
}
8185
}
8286

83-
extern "C" void dg_bar_shadowSet(void* sm_address, void* real_address_Lo, void* real_address_Hi, int size){
87+
extern "C" void dg_bar_shadowSet(void* sm_address, void* real_address_Lo, void* real_address_Hi, unsigned int size){
8488
ShadowLeafBar* leaf = sm_bar2->leaf_for_write((Addr)sm_address);
8589
Addr contiguousSize = sm_bar2->contiguousElements((Addr)sm_address);
8690
ULong index = sm_bar2->index((Addr)sm_address);
@@ -103,10 +107,13 @@ extern "C" void dg_bar_shadowSet(void* sm_address, void* real_address_Lo, void*
103107
}
104108

105109
extern "C" void dg_bar_shadowInit(){
110+
#pragma GCC diagnostic push
111+
#pragma GCC diagnostic ignored "-Wunused-value"
106112
for(Addr i=0; i<(1ul<<(SHADOW_LAYERS)); i++){
107113
ShadowLeafBar::distinguished.data_Lo[i] = 0;
108114
ShadowLeafBar::distinguished.data_Hi[i] = 0;
109115
}
116+
#pragma GCC diagnostic pop
110117
sm_bar2 = (ShadowMapTypeBar*)VG_(malloc)("Space for primary map",sizeof(ShadowMapTypeBar));
111118
ShadowMapTypeBar::constructAt(sm_bar2);
112119
}

derivgrind/bar/dg_bar_shadow.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ extern "C" {
3737
#endif
3838

3939
/*! */
40-
void dg_bar_shadowGet(void* sm_address, void* real_address_Lo, void* real_address_Hi, int size);
41-
void dg_bar_shadowSet(void* sm_address, void* real_address, void* real_address_Hi, int size);
40+
void dg_bar_shadowGet(void* sm_address, void* real_address_Lo, void* real_address_Hi, unsigned int size);
41+
void dg_bar_shadowSet(void* sm_address, void* real_address, void* real_address_Hi, unsigned int size);
4242
void dg_bar_shadowInit(void);
4343
void dg_bar_shadowFini(void);
4444

derivgrind/derivgrind-recording.h

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,36 @@
5252
* input and output variables in the client code.
5353
*/
5454

55-
static unsigned long long dg_indextmp, dg_indextmp2;
56-
static double dg_valtmp;
57-
static unsigned long long const dg_zero = 0;
58-
static double const dg_one = 1.;
59-
static unsigned long long const dg_ones = 0xfffffffffffffffful;
55+
#ifdef __GNUC__
56+
#define DG_UNUSED __attribute__((unused))
57+
#else
58+
#define DG_UNUSED
59+
#endif
60+
61+
DG_UNUSED static unsigned long long* dg_indextmp(void){
62+
static unsigned long long indextmp = 0;
63+
return &indextmp;
64+
}
65+
DG_UNUSED static unsigned long long* dg_indextmp2(void){
66+
static unsigned long long indextmp2 = 0;
67+
return &indextmp2;
68+
}
69+
DG_UNUSED static double* dg_valtmp(void){
70+
static double valtmp = 0.;
71+
return &valtmp;
72+
}
73+
DG_UNUSED static unsigned long long const* dg_zero(void){
74+
static unsigned long long const zero = 0;
75+
return &zero;
76+
}
77+
DG_UNUSED static double const* dg_one(void){
78+
static double const one = 1.;
79+
return &one;
80+
}
81+
DG_UNUSED static unsigned long long const* dg_ones(void){
82+
static unsigned long long const ones = 0xfffffffffffffffful;
83+
return &ones;
84+
}
6085

6186
/*! Mark variable as AD input and assign new 8-byte index to it.
6287
*
@@ -67,11 +92,11 @@ static unsigned long long const dg_ones = 0xfffffffffffffffful;
6792
* to print the index from your client code. Or use the DG_INPUTF macro to
6893
* write it directly into a file.
6994
*/
70-
#define DG_INPUT(var) (dg_valtmp=(double)(var),DG_NEW_INDEX_NOACTIVITYANALYSIS(&dg_zero,&dg_zero,&dg_zero,&dg_zero,&dg_indextmp,&dg_valtmp), DG_SET_INDEX(&var,&dg_indextmp), dg_indextmp)
95+
#define DG_INPUT(var) (*dg_valtmp()=(double)(var),DG_NEW_INDEX_NOACTIVITYANALYSIS(dg_zero(),dg_zero(),dg_zero(),dg_zero(),dg_indextmp(),dg_valtmp()), DG_SET_INDEX(&var,dg_indextmp()), *dg_indextmp())
7196

7297
/*! Mark variable as AD input, assign new 8-byte index, and dump the index into a file.
7398
*/
74-
#define DG_INPUTF(var) { dg_indextmp2 = DG_INPUT(var); DG_INDEX_TO_FILE(DG_INDEXFILE_INPUT, &dg_indextmp2); }
99+
#define DG_INPUTF(var) { *dg_indextmp2() = DG_INPUT(var); DG_INDEX_TO_FILE(DG_INDEXFILE_INPUT, dg_indextmp2()); }
75100

76101
/*! Mark variable as AD output and retrieve its 8-byte index.
77102
*
@@ -82,14 +107,14 @@ static unsigned long long const dg_ones = 0xfffffffffffffffful;
82107
* to print the index from your client code. Or use the DG_OUTPUTF macro to
83108
* write it directly into a file.
84109
*/
85-
#define DG_OUTPUT(var) (dg_valtmp=(double)(var),DG_GET_INDEX(&var,&dg_indextmp2), DG_NEW_INDEX_NOACTIVITYANALYSIS(&dg_indextmp2,&dg_zero,&dg_one,&dg_zero,&dg_indextmp,&dg_valtmp), dg_indextmp)
110+
#define DG_OUTPUT(var) (*dg_valtmp()=(double)(var),DG_GET_INDEX(&var,dg_indextmp2()), DG_NEW_INDEX_NOACTIVITYANALYSIS(dg_indextmp2(),dg_zero(),dg_one(),dg_zero(),dg_indextmp(),dg_valtmp()), *dg_indextmp())
86111

87112
/*! Mark variable as AD output, retrieve its 8-byte index, and dump the index into a file.
88113
*/
89-
#define DG_OUTPUTF(var) { dg_indextmp2 = DG_OUTPUT(var); DG_INDEX_TO_FILE(DG_INDEXFILE_OUTPUT, &dg_indextmp2); }
114+
#define DG_OUTPUTF(var) { *dg_indextmp2() = DG_OUTPUT(var); DG_INDEX_TO_FILE(DG_INDEXFILE_OUTPUT, dg_indextmp2()); }
90115

91116
/*! Mark variable as active floating-point number for the bit-trick finder.
92117
*/
93-
#define DG_MARK_FLOAT(var) {DG_SET_FLAGS(&var, &dg_ones, (void*)0, sizeof(var));}
118+
#define DG_MARK_FLOAT(var) {DG_SET_FLAGS(&var, dg_ones(), (void*)0, sizeof(var));}
94119

95120
#endif

0 commit comments

Comments
 (0)