TMB Documentation  v1.9.11
List of all members
TMBad::omp_shared_ptr< T > Struct Template Reference

Manage shared operator data across multiple threads. More...

#include <checkpoint.hpp>

Detailed Description

template<class T>
struct TMBad::omp_shared_ptr< T >

Manage shared operator data across multiple threads.

An operator that shares a resource using the normal std::shared_ptr can be made thread safe by simply replacing 'shared_ptr' by 'omp_shared_ptr'. Thread safety is guarantied in the following two situations:

  1. Parallel taping: The thread that constructs an operator is the same thread that uses the operator. Thread safety (and memory locality) in this case is already guarantied by the normal std::shared.
  2. Automatic parallelization: The tape is constructed using a single thread, then split and copied to the individual worker threads. Thread safety (and memory locality) in this case requires omp_shared_ptr.

Each instance has an extra pointer to a 'book-keeping' structure, essentially doubling its size compared to the normal shared_ptr. Operator copy is still a fairly quick operation involving essentially two reference counter increments.

The resource sharing has the following properties:

Definition at line 95 of file checkpoint.hpp.


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