|
Peano
|
Enclave bookkeeping. More...
#include <EnclaveBookkeeping.h>

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 EnclaveBookkeeping & | getInstance () |
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 |
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.
|
private |
Definition at line 63 of file EnclaveBookkeeping.h.
|
privatedefault |
|
privatedelete |
| 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.

| 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.
| data | Has to be device memory allocated through tarch::multicore::allocateMemory() |
| x | This marker is only there for debug reasons. In release mode, we ignore it. |
| h | This 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().


|
static |
Definition at line 22 of file EnclaveBookkeeping.cpp.
References EnclaveBookkeeping().
Referenced by exahype2::EnclaveTask::EnclaveTask(), and exahype2::EnclaveTask::run().


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


| 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.
| x | This marker is only there for debug reasons. In release mode, we ignore it. |
| h | This 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().

| 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
| x | This marker is only there for debug reasons. In release mode, we ignore it. |
| h | This 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().

|
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.
All the validation steps are realised through non-critical
| x | This marker is only there for debug reasons. In release mode, we ignore it. |
| h | This 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().


|
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().
|
private |
Definition at line 80 of file EnclaveBookkeeping.h.
Referenced by dumpStatistics(), finishedTask(), registerTask(), and waitForTaskToTerminateAndReturnResult().
|
staticprivate |
Definition at line 59 of file EnclaveBookkeeping.h.
|
private |
Definition at line 78 of file EnclaveBookkeeping.h.
Referenced by finishedTask().
|
staticprivate |
Definition at line 61 of file EnclaveBookkeeping.h.
Referenced by finishedTask().
|
staticconstexpr |
Definition at line 115 of file EnclaveBookkeeping.h.
|
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.