37#include "../../tools/parallel/parallelToolbox.hpp"
38#include "internalAdjointsInterface.hpp"
51 template<
typename T_Gradient,
typename T_Identifier,
typename T_Tape,
typename T_ParallelToolbox>
68 static std::vector<Gradient> adjoints;
83 return adjoints[(size_t)identifier];
89 return adjoints[(size_t)identifier];
95 return adjoints.data();
101 return adjoints.size();
107 adjoints.resize((
size_t)newSize);
112 for (
Gradient& gradient : adjoints) {
125 adjointsMutex.lockRead();
131 adjointsMutex.unlockRead();
135 template<
typename Gradient,
typename Identifier,
typename Tape,
typename ParallelToolbox>
136 std::vector<
CODI_DD(Gradient,
double)>
137 ThreadSafeGlobalAdjoints<Gradient, Identifier, Tape, ParallelToolbox>::adjoints(1);
139 template<
typename Gradient,
typename Identifier,
typename Tape,
typename ParallelToolbox>
140 typename CODI_DD(ParallelToolbox, CODI_DEFAULT_PARALLEL_TOOLBOX)::ReadWriteMutex
141 ThreadSafeGlobalAdjoints<Gradient, Identifier, Tape, ParallelToolbox>::adjointsMutex;
#define CODI_NO_INLINE
See codi::Config::AvoidedInlines.
Definition config.h:417
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:111
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
Full tape interface that supports all features of CoDiPack.
Definition fullTapeInterface.hpp:82
Abstracts the internal set of adjoint variables provided as part of the tape.
Definition internalAdjointsInterface.hpp:80
Provides global adjoint variables owned by a tape type. Thread-safe for use in parallel taping.
Definition threadSafeGlobalAdjoints.hpp:52
T_Gradient Gradient
See ThreadSafeGlobalAdjoints.
Definition threadSafeGlobalAdjoints.hpp:57
T_Identifier Identifier
Definition threadSafeGlobalAdjoints.hpp:58
Gradient & operator[](Identifier const &identifier)
Reference access to the adjoint variable identified by identifier.
Definition threadSafeGlobalAdjoints.hpp:82
T_ParallelToolbox ParallelToolbox
See ThreadSafeGlobalAdjoints.
Definition threadSafeGlobalAdjoints.hpp:60
void beginUse()
Declare that the adjoints are in use, e.g., during a tape evaluation, and cannot be resized right now...
Definition threadSafeGlobalAdjoints.hpp:124
void zeroAll()
Set all adjoint variables to Gradient().
Definition threadSafeGlobalAdjoints.hpp:111
void endUse()
Declare that the adjoints are no longer occupied.
Definition threadSafeGlobalAdjoints.hpp:130
void swap(ThreadSafeGlobalAdjoints &)
Swap two sets of adjoint variables. Internally, declares usage of the adjoints.
Definition threadSafeGlobalAdjoints.hpp:118
Gradient const & operator[](Identifier const &identifier) const
Constant reference access to the adjoint variable identified by identifier.
Definition threadSafeGlobalAdjoints.hpp:88
typename ParallelToolbox::LockForWrite LockForRealloc
See ParallelToolbox.
Definition threadSafeGlobalAdjoints.hpp:64
Gradient * data()
Pointer to an underlying array implementation.
Definition threadSafeGlobalAdjoints.hpp:93
typename ParallelToolbox::ReadWriteMutex ReadWriteMutex
See ParallelToolbox.
Definition threadSafeGlobalAdjoints.hpp:62
void resize(Identifier const &newSize)
Ensure that identifiers up to newSize can be passed to operator[] without error.
Definition threadSafeGlobalAdjoints.hpp:105
size_t size() const
Returns the number of adjoint variables. Internally, declares usage of the adjoints.
Definition threadSafeGlobalAdjoints.hpp:99
ThreadSafeGlobalAdjoints(size_t initialSize)
Constructor.
Definition threadSafeGlobalAdjoints.hpp:77
typename ParallelToolbox::LockForRead LockForUse
See ParallelToolbox.
Definition threadSafeGlobalAdjoints.hpp:63
T_Tape Tape
See ThreadSafeGlobalAdjoints.
Definition threadSafeGlobalAdjoints.hpp:56