#include <adolc/adolcexport.h>
#include <cassert>
#include <memory>
#include <vector>
Go to the source code of this file.
◆ createNewTape()
Creates a new tape and returns its ID.
Allocates a process-wide unique tape ID and inserts the new tape into the global registry. If the calling thread has no current tape, the newly created tape becomes that thread's current tape.
- Returns
- The ID of the new created tape.
◆ currentTape()
Returns a reference to the current ValueTape.
The current tape is used for creating new tape_locations, free locations, storing traced operations, etc...
- Returns
- Reference to the current ValueTape.
- Note
- Asserts if the current tape pointer is null.
◆ currentTapePtr()
Returns a thread-local reference to the pointer to the current ValueTape.
This pointer is specific to the thread and denotes the current tape. The current tape is used for creating new tape_locations, free locations, storing traced operations, etc...
- Returns
- Reference to the thread-local ValueTape pointer.
◆ currentTapeStack()
Returns a thread-local stack holding pointers to ValueTape instances.
This stack is modified in trace_on and trace_off. In trace_on the pointer of a possible previous current tape is pushed onto the stack. Then, the tape to be used is set to be the currentTape. Inside trace_off the pointer of the old tape is popped from the stack, and set as current tape again. This allows the nesting of trace_on ... trace_off calls.
- Returns
- Reference to the thread-local stack of tape pointers.
◆ findTape()
Returns a reference to a ValueTape by tapeId, or throws an error if not found.
This is a convenience wrapper around findTapePtr that dereferences the pointer.
- Parameters
-
| tapeId | The ID of the tape to retrieve. |
- Returns
- Reference to the corresponding ValueTape.
- Exceptions
-
◆ findTapePtr()
Returns a pointer to a ValueTape by tape ID, or throws an error if not found.
Performs a synchronized lookup in the process-wide tape registry. If no matching tape is found, an ADOLCError is thrown.
- Parameters
-
| tapeId | The ID of the tape to locate. |
- Returns
- Pointer to the corresponding ValueTape.
- Exceptions
-
◆ findTapePtr_()
Attempts to find a ValueTape pointer by tapeId without triggering an error.
- Parameters
-
| tapeId | The ID of the tape to search for. |
- Returns
- Pointer to the matching ValueTape if found, or nullptr otherwise.
◆ setCurrentTape() [1/2]
| ADOLC_API void setCurrentTape |
( |
short |
tapeId | ) |
|
Sets the current tape pointer to the pointer of the tape with the specified ID.
- Parameters
-
| tapeId | The ID of the tape to set as current. |
- Exceptions
-
◆ setCurrentTape() [2/2]
Sets the current tape pointer to the given tape.
- Parameters
-
| tape | The tape to set as the current one |
◆ tapeBuffer()
Returns the process-wide vector that owns all ValueTape instances.
Tape creation and lookup synchronize access to this registry internally. Pointers to contained tapes remain stable because the vector stores owning pointers and tapes are not removed.
- Returns
- Reference to the process-wide vector ValueTape pointers.