Peano
Loading...
Searching...
No Matches
exahype2::EnclaveBookkeeping Class Reference

Enclave bookkeeping. More...

#include <EnclaveBookkeeping.h>

Collaboration diagram for exahype2::EnclaveBookkeeping:

Data Structures

struct  Entry

Public Member Functions

void dumpStatistics ()
 For debugging only.
void waitForTaskToTerminateAndCopyResultOver (int number, double *destination, double &maxEigenvalue, const tarch::la::Vector< Dimensions, double > &x, const tarch::la::Vector< Dimensions, double > &h)
 Wait for a task and copy outcome into destination.
void waitForTaskAndDiscardResult (int number, const tarch::la::Vector< Dimensions, double > &x, const tarch::la::Vector< Dimensions, double > &h)
 Wait for a task and copy outcome into destination.
void finishedTask (int taskNumber, int numberOfResultValues, double *data, double maxEigenvalue, const tarch::la::Vector< Dimensions, double > &x, const tarch::la::Vector< Dimensions, double > &h)
 Usually called directly by EnclaveTask.
void registerTask (int taskNumber, const ::peano4::datamanagement::CellMarker &marker)
 This one is only there for debugging purposes.

Static Public Member Functions

static EnclaveBookkeepinggetInstance ()

Static Public Attributes

static constexpr int NoEnclaveTaskNumber = -1
static constexpr int SkeletonTask = -2
 Skeletons are not really tasks in the traditional sense.

Private Types

using FinishedTaskMap = std::unordered_map<int, Entry >

Private Member Functions

 EnclaveBookkeeping ()=default
 EnclaveBookkeeping (const EnclaveBookkeeping &)=delete
Entry waitForTaskToTerminateAndReturnResult (int number, const tarch::la::Vector< Dimensions, double > &x, const tarch::la::Vector< Dimensions, double > &h)
 Wait for a task result to become available.

Private Attributes

FinishedTaskMap _finishedTasks
 Plain map onto ouput array.
std::set< int_tasksThatHaveToBeCancelled
tarch::multicore::BooleanSemaphore _finishedTasksSemaphore

Static Private Attributes

static tarch::logging::Log _log
static const std::string MemoryAllocationsInLookupTableIdentifier

Detailed Description

Enclave bookkeeping.

The enclave bookkeeping is basically a big map which stores results of enclave tasks. Most of the documentation around enclave tasks can be found in exahype2::EnclaveTask.

The bookkeeping can be used in two ways by the underlying enclave task object: The enclave tasks can allocate data for their results on the heap, hand that heap object over to the bookkeeping, and the bookkeeping then hands out the results to the actual solver by copying it into the right place in the mesh and subsequently freeing the tasks's output.

Alternatively, we can work directly on the heap, i.e. the mesh tells us where the result should end up. In our tests, it is not always clear which variant is faster. Which is kind of a surprise. Likely it has to do with memory/cache issues.

Definition at line 42 of file EnclaveBookkeeping.h.

Member Typedef Documentation

◆ FinishedTaskMap

using exahype2::EnclaveBookkeeping::FinishedTaskMap = std::unordered_map<int, Entry >
private

Definition at line 63 of file EnclaveBookkeeping.h.

Constructor & Destructor Documentation

◆ EnclaveBookkeeping() [1/2]

exahype2::EnclaveBookkeeping::EnclaveBookkeeping ( )
privatedefault

Referenced by EnclaveBookkeeping(), and getInstance().

Here is the caller graph for this function:

◆ EnclaveBookkeeping() [2/2]

exahype2::EnclaveBookkeeping::EnclaveBookkeeping ( const EnclaveBookkeeping & )
privatedelete

References EnclaveBookkeeping().

Here is the call graph for this function:

Member Function Documentation

◆ dumpStatistics()

void exahype2::EnclaveBookkeeping::dumpStatistics ( )

For debugging only.

This routine is not thread-safe.

Definition at line 28 of file EnclaveBookkeeping.cpp.

References _finishedTasks, _finishedTasksSemaphore, exahype2::EnclaveTask::getNumberOfActiveTasks(), and logInfo.

Here is the call graph for this function:

◆ finishedTask()

void exahype2::EnclaveBookkeeping::finishedTask ( int taskNumber,
int numberOfResultValues,
double * data,
double maxEigenvalue,
const tarch::la::Vector< Dimensions, double > & x,
const tarch::la::Vector< Dimensions, double > & h )

Usually called directly by EnclaveTask.

Once this routine is called, the ownership of data passes over into the enclave bookkeeping. Basically, the enclave bookkeepting stores the passed pointer into a map and returns.

There is one exception to this: If we use optimistic time stepping, then we might run into a situation where a task overwrites a previous result. At the moment, this variant yields a warning, but in any case, the old data is first released, before we store the new pointer.

Parameters
dataHas to be device memory allocated through tarch::multicore::allocateMemory()
xThis marker is only there for debug reasons. In release mode, we ignore it.
hThis marker is only there for debug reasons. In release mode, we ignore it.

Definition at line 123 of file EnclaveBookkeeping.cpp.

References _finishedTasks, _finishedTasksSemaphore, _tasksThatHaveToBeCancelled, assertion3, assertionEquals1, assertionEquals3, tarch::multicore::Lock::free(), tarch::logging::Statistics::getInstance(), tarch::logging::Statistics::inc(), logDebug, MemoryAllocationsInLookupTableIdentifier, exahype2::EnclaveTask::releaseTaskNumber(), toString(), and tarch::triggerNonCriticalAssertion().

Referenced by exahype2::EnclaveTask::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInstance()

exahype2::EnclaveBookkeeping & exahype2::EnclaveBookkeeping::getInstance ( )
static

Definition at line 22 of file EnclaveBookkeeping.cpp.

References EnclaveBookkeeping().

Referenced by exahype2::EnclaveTask::EnclaveTask(), and exahype2::EnclaveTask::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerTask()

void exahype2::EnclaveBookkeeping::registerTask ( int taskNumber,
const ::peano4::datamanagement::CellMarker & marker )

This one is only there for debugging purposes.

The routine is called by the constructor of EnclaveTask to notify the bookkeepting that a new task has been created with a certain task number for a particular cell.

Definition at line 170 of file EnclaveBookkeeping.cpp.

References _finishedTasksSemaphore, assertion2, and tarch::triggerNonCriticalAssertion().

Referenced by exahype2::EnclaveTask::EnclaveTask().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ waitForTaskAndDiscardResult()

void exahype2::EnclaveBookkeeping::waitForTaskAndDiscardResult ( int number,
const tarch::la::Vector< Dimensions, double > & x,
const tarch::la::Vector< Dimensions, double > & h )

Wait for a task and copy outcome into destination.

Parameters
xThis marker is only there for debug reasons. In release mode, we ignore it.
hThis marker is only there for debug reasons. In release mode, we ignore it.

Definition at line 82 of file EnclaveBookkeeping.cpp.

References exahype2::EnclaveBookkeeping::Entry::data, tarch::freeMemory(), logTraceInWith1Argument, logTraceOut, tarch::ManagedSharedAcceleratorDeviceMemory, and waitForTaskToTerminateAndReturnResult().

Here is the call graph for this function:

◆ waitForTaskToTerminateAndCopyResultOver()

void exahype2::EnclaveBookkeeping::waitForTaskToTerminateAndCopyResultOver ( int number,
double * destination,
double & maxEigenvalue,
const tarch::la::Vector< Dimensions, double > & x,
const tarch::la::Vector< Dimensions, double > & h )

Wait for a task and copy outcome into destination.

We use waitForTaskToTerminateAndReturnResult() to obtain a handle to the task outcome. Once we get it, we have to check what to do next:

If an enclave task had been given the memory location where to dump the result directly, we simply return. In this case, the task outcome pointer and destination point to the same address.

If the task had allocated its own output data area on the heap, we copy the content from there into destination and then delete the task's memory location via

void freeMemory(void *data, MemoryLocation location, int device=accelerator::Device::HostDevice)
Free memory.
@ ManagedSharedAcceleratorDeviceMemory
To be used on host only.
Definition accelerator.h:73
Parameters
xThis marker is only there for debug reasons. In release mode, we ignore it.
hThis marker is only there for debug reasons. In release mode, we ignore it.

Definition at line 96 of file EnclaveBookkeeping.cpp.

References exahype2::EnclaveBookkeeping::Entry::data, tarch::freeMemory(), logDebug, logTraceInWith1Argument, logTraceOutWith2Arguments, tarch::ManagedSharedAcceleratorDeviceMemory, exahype2::EnclaveBookkeeping::Entry::maxEigenvalue, exahype2::EnclaveBookkeeping::Entry::numberOfResultValues, exahype2::EnclaveBookkeeping::Entry::toString(), and waitForTaskToTerminateAndReturnResult().

Here is the call graph for this function:

◆ waitForTaskToTerminateAndReturnResult()

exahype2::EnclaveBookkeeping::Entry exahype2::EnclaveBookkeeping::waitForTaskToTerminateAndReturnResult ( int number,
const tarch::la::Vector< Dimensions, double > & x,
const tarch::la::Vector< Dimensions, double > & h )
private

Wait for a task result to become available.

We wait for the task to terminate, and then return the meta object which describes the task properties. It is up to the calling routine to decide what to do with the result. We might either return the data or throw it away.

The routine assumes that a task has dropped its results due to finishedTask() already. To ensure this really happens, we call tarch::multicore::waitForTask() at the start of the routine's body.

Validation

All the validation steps are realised through non-critical

Returns
Entry with all meta data plus a pointer to the actual task result.
Parameters
xThis marker is only there for debug reasons. In release mode, we ignore it.
hThis marker is only there for debug reasons. In release mode, we ignore it.

Definition at line 42 of file EnclaveBookkeeping.cpp.

References _finishedTasks, _finishedTasksSemaphore, assertion3, assertionEquals1, assertionEquals3, tarch::multicore::Lock::free(), logDebug, exahype2::EnclaveTask::releaseTaskNumber(), toString(), tarch::triggerNonCriticalAssertion(), and tarch::multicore::waitForTask().

Referenced by waitForTaskAndDiscardResult(), and waitForTaskToTerminateAndCopyResultOver().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ _finishedTasks

FinishedTaskMap exahype2::EnclaveBookkeeping::_finishedTasks
private

Plain map onto ouput array.

See lifecycle discussion of EnclaveTask for details.

Definition at line 69 of file EnclaveBookkeeping.h.

Referenced by dumpStatistics(), finishedTask(), and waitForTaskToTerminateAndReturnResult().

◆ _finishedTasksSemaphore

tarch::multicore::BooleanSemaphore exahype2::EnclaveBookkeeping::_finishedTasksSemaphore
private

◆ _log

tarch::logging::Log exahype2::EnclaveBookkeeping::_log
staticprivate

Definition at line 59 of file EnclaveBookkeeping.h.

◆ _tasksThatHaveToBeCancelled

std::set<int> exahype2::EnclaveBookkeeping::_tasksThatHaveToBeCancelled
private

Definition at line 78 of file EnclaveBookkeeping.h.

Referenced by finishedTask().

◆ MemoryAllocationsInLookupTableIdentifier

const std::string exahype2::EnclaveBookkeeping::MemoryAllocationsInLookupTableIdentifier
staticprivate

Definition at line 61 of file EnclaveBookkeeping.h.

Referenced by finishedTask().

◆ NoEnclaveTaskNumber

int exahype2::EnclaveBookkeeping::NoEnclaveTaskNumber = -1
staticconstexpr

Definition at line 115 of file EnclaveBookkeeping.h.

◆ SkeletonTask

int exahype2::EnclaveBookkeeping::SkeletonTask = -2
staticconstexpr

Skeletons are not really tasks in the traditional sense.

But we can see them as tasks which are immediately ran.

Definition at line 120 of file EnclaveBookkeeping.h.


The documentation for this class was generated from the following files: