source: trunk/ADOL-C/include/adolc/taping.h @ 760

Last change on this file since 760 was 760, checked in by kulshres, 9 months ago

allow changing location management to singleton or block

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

  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1/*----------------------------------------------------------------------------
2 ADOL-C -- Automatic Differentiation by Overloading in C++
3 File:     taping.h
4 Revision: $Id: taping.h 760 2018-09-10 11:02:03Z kulshres $
5 Contents: all C functions directly accessing at least one of the four tapes
6           (operations, locations, constants, value stack)
7
8 Copyright (c) Andrea Walther, Andreas Griewank, Andreas Kowarz,
9               Hristo Mitev, Sebastian Schlenkrich, Jean Utke, Olaf Vogel
10 
11 This file is part of ADOL-C. This software is provided as open source.
12 Any use, reproduction, or distribution of the software constitutes
13 recipient's acceptance of the terms of the accompanying license file.
14 
15----------------------------------------------------------------------------*/
16#if !defined(ADOLC_TAPING_H)
17#define ADOLC_TAPING_H 1
18
19#include <adolc/internal/common.h>
20
21BEGIN_C_DECLS
22
23enum StatEntries {
24    NUM_INDEPENDENTS,                          /* # of independent variables */
25    NUM_DEPENDENTS,                              /* # of dependent variables */
26    NUM_MAX_LIVES,                                /* max # of live variables */
27    TAY_STACK_SIZE,               /* # of values in the taylor (value) stack */
28    OP_BUFFER_SIZE,   /* # of operations per buffer == OBUFSIZE (usrparms.h) */
29    NUM_OPERATIONS,                               /* overall # of operations */
30    OP_FILE_ACCESS,                        /* operations file written or not */
31    NUM_LOCATIONS,                                 /* overall # of locations */
32    LOC_FILE_ACCESS,                        /* locations file written or not */
33    NUM_VALUES,                                       /* overall # of values */
34    VAL_FILE_ACCESS,                           /* values file written or not */
35    LOC_BUFFER_SIZE,   /* # of locations per buffer == LBUFSIZE (usrparms.h) */
36    VAL_BUFFER_SIZE,      /* # of values per buffer == CBUFSIZE (usrparms.h) */
37    TAY_BUFFER_SIZE,     /* # of taylors per buffer <= TBUFSIZE (usrparms.h) */
38    NUM_EQ_PROD,                      /* # of eq_*_prod for sparsity pattern */
39    NO_MIN_MAX,  /* no use of min_op, deferred to abs_op for piecewise stuff */
40    NUM_SWITCHES,                   /* # of abs calls that can switch branch */
41    NUM_PARAM, /* no of parameters (doubles) interchangable without retaping */
42    STAT_SIZE                     /* represents the size of the stats vector */
43};
44
45enum TapeRemovalType {
46    ADOLC_REMOVE_FROM_CORE,
47    ADOLC_REMOVE_COMPLETELY
48};
49
50enum LocationMgrType {
51    ADOLC_LOCATION_BLOCKS,     /* can allocate contiguous location blocks */
52    ADOLC_LOCATION_SINGLETONS  /* only singleton locations, no blocks */
53};
54
55ADOLC_DLL_EXPORT void skip_tracefile_cleanup(short tnum);
56
57/* Returns statistics on the tape "tag". Use enumeration StatEntries for
58 * accessing the individual elements of the vector "tape_stats"! */
59ADOLC_DLL_EXPORT void tapestats(short tag, size_t *tape_stats);
60
61ADOLC_DLL_EXPORT void set_nested_ctx(short tag, char nested);
62
63/* An all-in-one tape stats printing routine */
64ADOLC_DLL_EXPORT void printTapeStats(FILE *stream, short tag);
65
66ADOLC_DLL_EXPORT int removeTape(short tapeID, short type);
67
68ADOLC_DLL_EXPORT void enableBranchSwitchWarnings();
69ADOLC_DLL_EXPORT void disableBranchSwitchWarnings();
70
71ADOLC_DLL_EXPORT void enableMinMaxUsingAbs();
72ADOLC_DLL_EXPORT void disableMinMaxUsingAbs();
73/*
74 * free location block sorting/consolidation upon calls to ensureContiguousLocations
75 * happens when  the ratio between allocated and used locations exceeds gcTriggerRatio or
76 * the allocated locations exceed gcTriggerMaxSize
77 */
78ADOLC_DLL_EXPORT void setStoreManagerType(unsigned char loctypes);
79
80ADOLC_DLL_EXPORT void setStoreManagerControl(double gcTriggerRatio, size_t gcTriggerMaxSize);
81
82END_C_DECLS
83
84/**
85 * Normally, theKeeper would take care of the initialization and finalization
86 * of ADOL-C. However, some compilers do not include the keeper code when
87 * linking. "initADOLC" should be called right after main(...), in this case.
88 * "initADOLC" will not initialize memory, but is only necessary to reference
89 * "theKeeper", such that this static instance is used at least once. :-(
90 */
91ADOLC_DLL_EXPORT void initADOLC();
92
93#if defined(__cplusplus)
94
95/* Initialization for the taping process. Creates buffers for this tape, sets
96 * files names, and calls appropriate setup routines.
97 * This functions return value is different from zero if a tape with with ID
98 * tnum is available only in core. The old tape gets overwritten by the new
99 * one in this case. */
100ADOLC_DLL_EXPORT int trace_on(short tnum, int keepTaylors = 0);
101
102/* special version including buffersize customization
103 *      obs - size of the operation buffer (number of elements)
104 *      lbs - size of the location buffer (number of elements)
105 *      vbs - size of the value buffer (number of elements)
106 *      tbs - size of the taylor buffer (number of elements)
107 * trace_on is the last point in time we want to allow the change of buffer
108 * sizes for a given tape */
109ADOLC_DLL_EXPORT int trace_on(short tnum, int keepTaylors,
110        uint obs, uint lbs, uint vbs, uint tbs, int skipFileCleanup=0);
111
112/* Stop Tracing. Cleans up, and turns off trace_flag. Flag not equal zero
113 * enforces writing of the three main tape files (op+loc+val). */
114ADOLC_DLL_EXPORT void trace_off(int flag = 0);
115
116ADOLC_DLL_EXPORT bool isTaping();
117
118#include <vector>
119ADOLC_DLL_EXPORT void cachedTraceTags(std::vector<short>& result);
120
121#endif
122
123#endif /* ADOLC_TAPING_H */
Note: See TracBrowser for help on using the repository browser.