source: trunk/ADOL-C/include/adolc/checkpointing.h @ 600

Last change on this file since 600 was 600, checked in by kulshres, 5 years ago

Merge branch 'master' of 'gitclone' into svn

The following commits have been merged:

commit 8d787974fa72e789c4d478a8ec949fcf49949928
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 12 20:20:51 2015 +0100

we have res in the counter, so use res as the index too!!!

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 47fb5bb3416a4ba87f856a615dc015927c39b1d3
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 12 16:41:59 2015 +0100

implement reverse mode for ext_diff_fct_v2

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 693d456e0104684c03378d691e536c7f46aebee7
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu Mar 12 16:41:34 2015 +0100

deallocate memory

since we're allocating it before.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit b8761a69fde8f4884ffae190f9c34fd66cb5b8e4
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 23:40:11 2015 +0100

implement forward mode of ext_diff_v2

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit a7b0357c37c6af72e6ed5e1f01216664a00c79b3
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 20:35:50 2015 +0100

Use the integer parameters in the implementation

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit e73d6ddc43945465b6b98a9b8e3083ea43bcde6e
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 20:32:00 2015 +0100

add handling of integer parameters by default

if the user has no interger parameters they can pass
iArrLen = 0 and iArr= NULL to call_ext_fct, and we take
care of it in the implementation, but the signatures all
have them in it.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 903ebee5f44066169d8a37f37a93100ceeea9696
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 19:57:31 2015 +0100

implement call_ext_fct for ext_diff_fct_v2

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit b7af35c5ad4851c52475282fc48cbed8c18e1cc9
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 17:19:04 2015 +0100

fix typo in filename

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit ed5959bf299b75638ba860490aaecf8ca8f59d08
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 17:18:04 2015 +0100

add a dummy pointer in CpInfos?

otherwise the buffer_temp complains.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit eaee23bf630f9f9c58fb03941d330938ede262ac
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 17:14:44 2015 +0100

add guards for c++

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 6f53952b6d7b00e2f7e83de2e43000f84e2f738b
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 17:13:04 2015 +0100

Add a stub function to make everything compile

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit ec4232d70e86891fb8a2423dcd5382d7b84a6bbe
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 16:50:54 2015 +0100

initial implemenatation for ext_diff_fct_v2

registration and memory allocation done.

remaining: call_ext_fct and forward/reverse implementation

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 1183a77c1cf44c8282632dc329cc6f857963a674
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 16:47:12 2015 +0100

add a null-pointer initialization in buffer_temp.h

because this is checked in edf_zero

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 6849df4942652d2f7b37b6dfcf1c4aac7d9a9099
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 16:43:32 2015 +0100

make populate_dpp() non static, add zeroing of memory

also correct check in edf_zero

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit e10962716558f04f69f0653b183903dadb26ddb9
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Wed Mar 11 16:41:28 2015 +0100

correct dimension information

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit d92f00358f4edc2d0914d88af6e07e59223bd740
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 9 21:48:05 2015 +0100

add header file for the more generic external functions interface

This interface will exist parallel to the previous interface
and might even use some of the existing code.
The main reason for designing this is to lift the limitation
of one contigously allocated adouble input array and one
similar output array. Here we can use several arrays for input
and output.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 10b1e386bb8e561fefb9e1654bf929c42dc107a4
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 9 21:32:28 2015 +0100

relocate comment about memory in ext_diff_fct

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 97ffe06d9a1f60a54ed9e6188c2d73a74a4f9adf
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 9 20:20:08 2015 +0100

Fix ext_diff_fct so that users don't do memory allocation

the memory depends on the size of input and output. so it
can change depending on how many of those there are.
make it dependent on max_m, max_n and do deallocation
and allocation within call_ext_fct

if the maximal size is allocated then smaller sizes will
work automatically.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 9b501e135cc324d93cd6489bedd4adcc572cde8f
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Mar 9 17:41:03 2015 +0100

use the double *dp_x, *dp_y inside edfct during call_ext_fct()

this removes the need for the user to allocate two more arrays,
which can be avoided, because edfct structures contain lots of memory
anyway

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/*----------------------------------------------------------------------------
2 ADOL-C -- Automatic Differentiation by Overloading in C++
3 File:     checkpointing.h
4 Revision: $Id: checkpointing.h 600 2015-03-12 21:28:32Z kulshres $
5 Contents: Provides all checkointing interfaces.
6 
7 Copyright (c) Andreas Kowarz
8 
9 This file is part of ADOL-C. This software is provided as open source.
10 Any use, reproduction, or distribution of the software constitutes
11 recipient's acceptance of the terms of the accompanying license file.
12 
13----------------------------------------------------------------------------*/
14
15#if !defined(ADOLC_CHECKPOINTING_H)
16#define ADOLC_CHECKPOINTING_H 1
17
18#include <adolc/internal/common.h>
19#include <adolc/adouble.h>
20
21#if defined(__cplusplus)
22/****************************************************************************/
23/*                                                          This is all C++ */
24
25typedef int (*ADOLC_TimeStepFuncion) (int n, adouble *x);
26typedef int (*ADOLC_TimeStepFuncion_double) (int n, double *x);
27typedef void *(*ADOLC_saveFct) ();
28typedef void (*ADOLC_restoreFct) (void *);
29
30typedef struct CpInfos {
31    ADOLC_TimeStepFuncion function;
32    ADOLC_TimeStepFuncion_double function_double;
33    ADOLC_saveFct saveNonAdoubles;
34    ADOLC_restoreFct restoreNonAdoubles;
35    int steps;
36    int checkpoints;
37    int tapeNumber;      /* tape number to be used for checkpointing */
38    int retaping;  /* != 0 forces retaping before every reverse step */
39
40    int n;          /* number of variables in input and output (n=m) */
41    adouble *adp_x;                       /* input of the first step */
42    adouble *adp_y; /* output of the last step; will be set by ADOLC */
43
44    /* these are internal checkpointing variables => do not use */
45    int check;
46    int capo;
47    int fine;
48    int info;
49    int currentCP;
50    double *dp_internal_for;
51    double *dp_internal_rev;
52    double **dpp_internal_rev;
53    locint index;                            /* please do not change */
54    char modeForward;
55    char modeReverse;
56    char *allmem; /* this is dummy to get externfcts and checkpointing both use buffer_temp without a problem */
57}
58CpInfos;
59
60ADOLC_DLL_EXPORT
61CpInfos *reg_timestep_fct(ADOLC_TimeStepFuncion timeStepFunction);
62
63ADOLC_DLL_EXPORT int checkpointing (CpInfos *cpInfos);
64
65/* if tape with one program and use the tapes with another programm call this
66 * function within the latter                                               */
67ADOLC_DLL_EXPORT void reinit_checkpointing();
68
69class CP_Context {
70public:
71    inline CP_Context(ADOLC_TimeStepFuncion tsf);
72    inline ~CP_Context() {}
73
74    inline void setDoubleFct(ADOLC_TimeStepFuncion_double tsf);
75    inline void setSaveFct(ADOLC_saveFct sf);
76    inline void setRestoreFct(ADOLC_restoreFct rf);
77    inline void setNumberOfSteps(int number);
78    inline void setNumberOfCheckpoints(int number);
79    inline void setTapeNumber(int tapeNumber);
80    inline void setDimensionXY(int n);
81    inline void setInput(adouble *x);
82    inline void setOutput(adouble *y);
83    inline void setAlwaysRetaping(bool state);
84
85    inline int checkpointing();
86
87private:
88    inline CP_Context() {}
89
90    CpInfos *cpInfos;
91};
92
93CP_Context::CP_Context(ADOLC_TimeStepFuncion tsf) {
94    cpInfos = reg_timestep_fct(tsf);
95}
96
97void CP_Context::setDoubleFct(ADOLC_TimeStepFuncion_double tsf) {
98    cpInfos->function_double = tsf;
99}
100
101void CP_Context::setSaveFct(ADOLC_saveFct sf) {
102    cpInfos->saveNonAdoubles = sf;
103}
104
105void CP_Context::setRestoreFct(ADOLC_restoreFct rf) {
106    cpInfos->restoreNonAdoubles = rf;
107}
108
109void CP_Context::setNumberOfSteps(int number) {
110    cpInfos->steps = number;
111}
112
113void CP_Context::setNumberOfCheckpoints(int number) {
114    cpInfos->checkpoints = number;
115}
116
117void CP_Context::setTapeNumber(int tapeNumber) {
118    cpInfos->tapeNumber = tapeNumber;
119}
120
121void CP_Context::setDimensionXY(int n) {
122    cpInfos->n = n;
123}
124
125void CP_Context::setInput(adouble *x) {
126    cpInfos->adp_x = x;
127}
128
129void CP_Context::setOutput(adouble *y) {
130    cpInfos->adp_y = y;
131}
132
133void CP_Context::setAlwaysRetaping(bool state) {
134    if (state) cpInfos->retaping = 1;
135    else cpInfos->retaping = 0;
136}
137
138int CP_Context::checkpointing() {
139    return ::checkpointing(cpInfos);
140}
141
142#endif /* CPLUSPLUS */
143
144/****************************************************************************/
145#endif /* ADOLC_CHECKPOINTING_H */
146
Note: See TracBrowser for help on using the repository browser.