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) |
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 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 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 |
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.
|
privatedefault |
Definition at line 40 of file EnclaveBookkeeping.cpp.
References exahype2::EnclaveBookkeeping::Entry::data, tarch::freeMemory(), tarch::ManagedSharedAcceleratorDeviceMemory, and exahype2::EnclaveTask::releaseTaskNumber().
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.
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.
data | Has 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().
|
static |
Definition at line 21 of file EnclaveBookkeeping.cpp.
Referenced by exahype2::EnclaveTask::run().
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.
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
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().
|
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.
Definition at line 54 of file EnclaveBookkeeping.cpp.
References assertionEquals, tarch::multicore::Lock::free(), exahype2::EnclaveTask::releaseTaskNumber(), and tarch::multicore::waitForTask().
Plain map onto ouput array.
See lifecycle discussion of EnclaveTask for details.
Definition at line 58 of file EnclaveBookkeeping.h.
|
private |
Definition at line 62 of file EnclaveBookkeeping.h.
|
staticprivate |
Definition at line 50 of file EnclaveBookkeeping.h.
|
private |
Definition at line 60 of file EnclaveBookkeeping.h.
|
staticprivate |
Definition at line 52 of file EnclaveBookkeeping.h.
|
staticconstexpr |
Definition at line 77 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 82 of file EnclaveBookkeeping.h.