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)
 Wait for a task and copy outcome into destination.
 
void waitForTaskAndDiscardResult (int number)
 Wait for a task and copy outcome into destination.
 
void cancelTask (int number)
 
void finishedTask (int taskNumber, int numberOfResultValues, double *data, double maxEigenvalue)
 Usually called directly by EnclaveTask.
 

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 Member Functions

 EnclaveBookkeeping ()=default
 
Entry waitForTaskToTerminateAndReturnResult (int number)
 Wait for a task result to become available.
 

Private Attributes

std::unordered_map< int, Entry_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 39 of file EnclaveBookkeeping.h.

Constructor & Destructor Documentation

◆ EnclaveBookkeeping()

exahype2::EnclaveBookkeeping::EnclaveBookkeeping ( )
privatedefault

Member Function Documentation

◆ cancelTask()

void exahype2::EnclaveBookkeeping::cancelTask ( int number)

◆ dumpStatistics()

void exahype2::EnclaveBookkeeping::dumpStatistics ( )

For debugging only.

This routine is not thread-safe.

Definition at line 27 of file EnclaveBookkeeping.cpp.

References 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 )

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()

Definition at line 102 of file EnclaveBookkeeping.cpp.

References assertionEquals1, tarch::multicore::Lock::free(), tarch::logging::Statistics::getInstance(), tarch::logging::Statistics::inc(), logDebug, logWarning, and exahype2::EnclaveTask::releaseTaskNumber().

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 21 of file EnclaveBookkeeping.cpp.

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

Here is the caller graph for this function:

◆ waitForTaskAndDiscardResult()

void exahype2::EnclaveBookkeeping::waitForTaskAndDiscardResult ( int number)

Wait for a task and copy outcome into destination.

Definition at line 69 of file EnclaveBookkeeping.cpp.

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

Here is the call graph for this function:

◆ waitForTaskToTerminateAndCopyResultOver()

void exahype2::EnclaveBookkeeping::waitForTaskToTerminateAndCopyResultOver ( int number,
double * destination,
double & maxEigenvalue )

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 at line 79 of file EnclaveBookkeeping.cpp.

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

Here is the call graph for this function:

◆ waitForTaskToTerminateAndReturnResult()

exahype2::EnclaveBookkeeping::Entry exahype2::EnclaveBookkeeping::waitForTaskToTerminateAndReturnResult ( int number)
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.

Returns
Entry with all meta data plus a pointer to the actual task result.

Definition at line 54 of file EnclaveBookkeeping.cpp.

References assertionEquals, tarch::multicore::Lock::free(), exahype2::EnclaveTask::releaseTaskNumber(), and tarch::multicore::waitForTask().

Here is the call graph for this function:

Field Documentation

◆ _finishedTasks

std::unordered_map<int, Entry > exahype2::EnclaveBookkeeping::_finishedTasks
private

Plain map onto ouput array.

See lifecycle discussion of EnclaveTask for details.

Definition at line 58 of file EnclaveBookkeeping.h.

◆ _finishedTasksSemaphore

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

Definition at line 62 of file EnclaveBookkeeping.h.

◆ _log

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

Definition at line 50 of file EnclaveBookkeeping.h.

◆ _tasksThatHaveToBeCancelled

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

Definition at line 60 of file EnclaveBookkeeping.h.

◆ MemoryAllocationsInLookupTableIdentifier

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

Definition at line 52 of file EnclaveBookkeeping.h.

◆ NoEnclaveTaskNumber

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

Definition at line 77 of file EnclaveBookkeeping.h.

◆ SkeletonTask

constexpr 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 82 of file EnclaveBookkeeping.h.


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