CoDiPack  2.2.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
codi::ThreadSafeGlobalAdjoints< T_Gradient, T_Identifier, T_Tape, T_ParallelToolbox > Struct Template Reference

Provides global adjoint variables owned by a tape type. Thread-safe for use in parallel taping. More...

#include <threadSafeGlobalAdjoints.hpp>

Inheritance diagram for codi::ThreadSafeGlobalAdjoints< T_Gradient, T_Identifier, T_Tape, T_ParallelToolbox >:

Public Types

using Gradient = T_Gradient
 See ThreadSafeGlobalAdjoints.
 
using Identifier = T_Identifier
 
using LockForRealloc = typename ParallelToolbox::LockForWrite
 See ParallelToolbox.
 
using LockForUse = typename ParallelToolbox::LockForRead
 See ParallelToolbox.
 
using ParallelToolbox = T_ParallelToolbox
 See ThreadSafeGlobalAdjoints.
 
using ReadWriteMutex = typename ParallelToolbox::ReadWriteMutex
 See ParallelToolbox.
 
using Tape = T_Tape
 See ThreadSafeGlobalAdjoints.
 
- Public Types inherited from codi::InternalAdjointsInterface< T_Gradient, T_Identifier, T_Tape >
using Gradient = T_Gradient
 See InternalAdjointsInterface.
 
using Identifier = T_Identifier
 See InternalAdjointsInterface.
 
using Tape = T_Tape
 See InternalAdjointsInterface.
 

Public Member Functions

void beginUse ()
 Declare that the adjoints are in use, e.g., during a tape evaluation, and cannot be resized right now.


 
Gradientdata ()
 Pointer to an underlying array implementation.
 
void endUse ()
 Declare that the adjoints are no longer occupied.


 
Gradientoperator[] (Identifier const &identifier)
 Reference access to the adjoint variable identified by identifier.


 
Gradient const & operator[] (Identifier const &identifier) const
 Constant reference access to the adjoint variable identified by identifier.


 
void resize (Identifier const &newSize)
 Ensure that identifiers up to newSize can be passed to operator[] without error.
 
size_t size () const
 Returns the number of adjoint variables. Internally, declares usage of the adjoints.
 
void swap (ThreadSafeGlobalAdjoints &)
 Swap two sets of adjoint variables. Internally, declares usage of the adjoints.
 
 ThreadSafeGlobalAdjoints (size_t initialSize)
 Constructor.
 
void zeroAll ()
 Set all adjoint variables to Gradient().
 
- Public Member Functions inherited from codi::InternalAdjointsInterface< T_Gradient, T_Identifier, T_Tape >
void beginUse ()
 Declare that the adjoints are in use, e.g., during a tape evaluation, and cannot be resized right now.
 
Gradientdata ()
 Pointer to an underlying array implementation.
 
void endUse ()
 Declare that the adjoints are no longer occupied.
 
 InternalAdjointsInterface (size_t initialSize)
 
Gradientoperator[] (Identifier const &identifier)
 Reference access to the adjoint variable identified by identifier.
 
Gradient const & operator[] (Identifier const &identifier) const
 Constant reference access to the adjoint variable identified by identifier.
 
void resize (Identifier const &newSize)
 Ensure that identifiers up to newSize can be passed to operator[] without error.
 
size_t size () const
 Returns the number of adjoint variables. Internally, declares usage of the adjoints.
 
template<typename Impl >
void swap (Impl &other)
 Swap two sets of adjoint variables. Internally, declares usage of the adjoints.
 
void zeroAll ()
 Set all adjoint variables to Gradient().
 

Detailed Description

template<typename T_Gradient, typename T_Identifier, typename T_Tape, typename T_ParallelToolbox>
struct codi::ThreadSafeGlobalAdjoints< T_Gradient, T_Identifier, T_Tape, T_ParallelToolbox >

Provides global adjoint variables owned by a tape type. Thread-safe for use in parallel taping.

Template Parameters
T_GradientThe gradient type of a tape, usually chosen as ActiveType::Gradient.
T_IdentifierThe adjoint/tangent identification of a tape, usually chosen as ActiveType::Identifier.
T_TapeThe associated tape type.
T_ParallelToolboxThe parallel toolbox used in the associated tape. See codi::ParallelToolbox.

Member Typedef Documentation

◆ Identifier

template<typename T_Gradient , typename T_Identifier , typename T_Tape , typename T_ParallelToolbox >
using codi::ThreadSafeGlobalAdjoints< T_Gradient, T_Identifier, T_Tape, T_ParallelToolbox >::Identifier = T_Identifier

Member Function Documentation

◆ beginUse()

template<typename T_Gradient , typename T_Identifier , typename T_Tape , typename T_ParallelToolbox >
void codi::ThreadSafeGlobalAdjoints< T_Gradient, T_Identifier, T_Tape, T_ParallelToolbox >::beginUse ( )
inline

Declare that the adjoints are in use, e.g., during a tape evaluation, and cannot be resized right now.



Implementation: Sets an internal lock.

◆ data()

template<typename T_Gradient , typename T_Identifier , typename T_Tape , typename T_ParallelToolbox >
Gradient * codi::ThreadSafeGlobalAdjoints< T_Gradient, T_Identifier, T_Tape, T_ParallelToolbox >::data ( )
inline

Pointer to an underlying array implementation.

◆ endUse()

template<typename T_Gradient , typename T_Identifier , typename T_Tape , typename T_ParallelToolbox >
void codi::ThreadSafeGlobalAdjoints< T_Gradient, T_Identifier, T_Tape, T_ParallelToolbox >::endUse ( )
inline

Declare that the adjoints are no longer occupied.



Implementation: Unsets an internal lock.

◆ operator[]() [1/2]

template<typename T_Gradient , typename T_Identifier , typename T_Tape , typename T_ParallelToolbox >
Gradient & codi::ThreadSafeGlobalAdjoints< T_Gradient, T_Identifier, T_Tape, T_ParallelToolbox >::operator[] ( Identifier const &  identifier)
inline

Reference access to the adjoint variable identified by identifier.



Implementation: No locking is performed, beginUse and endUse have to be used accordingly.

◆ operator[]() [2/2]

template<typename T_Gradient , typename T_Identifier , typename T_Tape , typename T_ParallelToolbox >
Gradient const & codi::ThreadSafeGlobalAdjoints< T_Gradient, T_Identifier, T_Tape, T_ParallelToolbox >::operator[] ( Identifier const &  identifier) const
inline

Constant reference access to the adjoint variable identified by identifier.



Implementation: No locking is performed, beginUse and endUse have to be used accordingly.

◆ resize()

template<typename T_Gradient , typename T_Identifier , typename T_Tape , typename T_ParallelToolbox >
void codi::ThreadSafeGlobalAdjoints< T_Gradient, T_Identifier, T_Tape, T_ParallelToolbox >::resize ( Identifier const &  newSize)
inline

Ensure that identifiers up to newSize can be passed to operator[] without error.

◆ size()

template<typename T_Gradient , typename T_Identifier , typename T_Tape , typename T_ParallelToolbox >
size_t codi::ThreadSafeGlobalAdjoints< T_Gradient, T_Identifier, T_Tape, T_ParallelToolbox >::size ( ) const
inline

Returns the number of adjoint variables. Internally, declares usage of the adjoints.

◆ swap()

template<typename T_Gradient , typename T_Identifier , typename T_Tape , typename T_ParallelToolbox >
void codi::ThreadSafeGlobalAdjoints< T_Gradient, T_Identifier, T_Tape, T_ParallelToolbox >::swap ( ThreadSafeGlobalAdjoints< T_Gradient, T_Identifier, T_Tape, T_ParallelToolbox > &  )
inline

Swap two sets of adjoint variables. Internally, declares usage of the adjoints.

◆ zeroAll()

template<typename T_Gradient , typename T_Identifier , typename T_Tape , typename T_ParallelToolbox >
void codi::ThreadSafeGlobalAdjoints< T_Gradient, T_Identifier, T_Tape, T_ParallelToolbox >::zeroAll ( )
inline

Set all adjoint variables to Gradient().


The documentation for this struct was generated from the following file: