ADOL-C: Automatic Differentiation in C/C++ 2.7.3
Loading...
Searching...
No Matches
taperegistry.h
Go to the documentation of this file.
1#ifndef ADOLC_TAPE_REGISTRY_H
2#define ADOLC_TAPE_REGISTRY_H
3
4#include <adolc/adolcexport.h>
5#include <cassert>
6#include <memory>
7#include <vector>
8
9// forward declaration to use as pointer
10class ValueTape;
11
20 ValueTape *prev{nullptr};
21 ValueTape *current{nullptr};
22};
23
33ADOLC_API std::vector<std::unique_ptr<ValueTape>> &tapeBuffer();
34
46inline std::vector<RecordingFrame> &currentTapeStack() {
47 thread_local std::vector<RecordingFrame> cTStack{RecordingFrame{}};
48 return cTStack;
49}
58
73
88
100 thread_local ValueTape *currTapePtr = nullptr;
101 return currTapePtr;
102}
114 assert(currentTapePtr() && "Current Tape is nullptr!");
115 return *currentTapePtr();
116}
117
123inline void setCurrentTape(ValueTape *tape) noexcept {
124 currentTapePtr() = tape;
125}
135ADOLC_API void setCurrentTape(short tapeId);
147
148#endif // ADOLC_TAPE_REGISTRY_H
#define ADOLC_API
Definition adolcexport.h:16
Owns one recorded function and the state required to evaluate it.
Definition valuetape.h:79
One entry in the thread-local stack of nested recordings.
Definition taperegistry.h:19
ValueTape * prev
Definition taperegistry.h:20
ValueTape * current
Definition taperegistry.h:21
ADOLC_API ValueTape * findTapePtr_(short tapeId)
Attempts to find a ValueTape pointer by tapeId without triggering an error.
ValueTape & currentTape()
Returns a reference to the current ValueTape.
Definition taperegistry.h:113
ADOLC_API ValueTape & findTape(short tapeId)
Returns a reference to a ValueTape by tapeId, or throws an error if not found.
ADOLC_API ValueTape *& currentTapePtr()
Returns a thread-local reference to the pointer to the current ValueTape.
Definition taperegistry.h:99
ADOLC_API ValueTape * findTapePtr(short tapeId)
Returns a pointer to a ValueTape by tape ID, or throws an error if not found.
ADOLC_API short createNewTape()
Creates a new tape and returns its ID.
void setCurrentTape(ValueTape *tape) noexcept
Sets the current tape pointer to the given tape.
Definition taperegistry.h:123
std::vector< RecordingFrame > & currentTapeStack()
Returns a thread-local stack holding pointers to ValueTape instances.
Definition taperegistry.h:46
ADOLC_API std::vector< std::unique_ptr< ValueTape > > & tapeBuffer()
Returns the process-wide vector that owns all ValueTape instances.