Peano 4
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.
Entry waitForTaskToTerminateAndReturnResult (int number)
 Wait for a task result to become available.
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

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
static const std::string LookupMissesIdentifier

Detailed Description

Enclave bookkeeping.

The enclave bookkeeping is basically a big map which stores results of enclave tasks.

Das Ergebnis muss lokal gepuffert werden im bookkeeping. Ich brauche zwei Adapter: einen fuer primaer, einen fuer sekundaer. Sonst rekonstruier ich dei Loesung jedes Mal (ist teuer) Die Adapter muessen alle das gleiche Bookkeeping verwenden -> singleton Ein Task muss sich, sobald er zuende ist, in den Bookkeeping einreihen, d.h. hier gibt es zwei Datenstrukturen: Semaphoren (set) + Tasks (map)

Definition at line 33 of file EnclaveBookkeeping.h.

Constructor & Destructor Documentation

◆ EnclaveBookkeeping()

exahype2::EnclaveBookkeeping::EnclaveBookkeeping ( )

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 29 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 goes

dataHas to be device memory allocated through tarch::multicore::allocateMemory()

Definition at line 113 of file EnclaveBookkeeping.cpp.

References assertionEquals1, tarch::multicore::Lock::free(), tarch::logging::Statistics::getInstance(), tarch::logging::Statistics::inc(), logDebug, 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 ( )

Definition at line 23 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 86 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 )

◆ waitForTaskToTerminateAndReturnResult()

exahype2::EnclaveBookkeeping::Entry exahype2::EnclaveBookkeeping::waitForTaskToTerminateAndReturnResult ( int number)

Wait for a task result to become available.

We check the internal database for the result. If the result is not there yet, we process one task. This processing should be done LIFO, as we assume that traversals produce tasks and the follow-up traversal then consumes the outcome. In the Peano world, two subsequent mesh traversals run through the grid in inverted order, so searching for task outcomes LIFO makes sense. If there are no tasks left in Peano's queues and we still haven't got the result, we yield to give other threads of the runtime the opportunity to do their stuff.

You have the sole ownership of the result which should be deleted later via

void freeMemory(void *data, MemoryLocation location)
@ ManagedSharedAcceleratorDeviceMemory
To be used on host only.

Definition at line 56 of file EnclaveBookkeeping.cpp.

References assertionEquals, tarch::multicore::Lock::free(), tarch::logging::Statistics::getInstance(), tarch::multicore::Core::getInstance(), tarch::logging::Statistics::inc(), tarch::multicore::Lock::lock(), tarch::multicore::processPendingTasks(), exahype2::EnclaveTask::releaseTaskNumber(), and tarch::multicore::Core::yield().

Here is the call graph for this function:

Field Documentation

◆ _finishedTasks

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

Plain map onto ouput array.

See lifecycle discussion of EnclaveTask for details.

Definition at line 53 of file EnclaveBookkeeping.h.

◆ _finishedTasksSemaphore

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

Definition at line 57 of file EnclaveBookkeeping.h.

◆ _log

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

Definition at line 44 of file EnclaveBookkeeping.h.

◆ _tasksThatHaveToBeCancelled

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

Definition at line 55 of file EnclaveBookkeeping.h.

◆ LookupMissesIdentifier

const std::string exahype2::EnclaveBookkeeping::LookupMissesIdentifier

Definition at line 47 of file EnclaveBookkeeping.h.

◆ MemoryAllocationsInLookupTableIdentifier

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

Definition at line 46 of file EnclaveBookkeeping.h.

◆ NoEnclaveTaskNumber

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

Definition at line 61 of file EnclaveBookkeeping.h.

◆ SkeletonTask

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

Skeletons are not really tasks in the traditional sense.

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

Definition at line 66 of file EnclaveBookkeeping.h.

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