|
Peano
|
Base class for all enclave tasks. More...
#include <EnclaveTask.h>


Public Types | |
| typedef std::function< void()> | Functor |
Public Member Functions | |
| EnclaveTask (int enclaveTaskTypeId, const ::peano4::datamanagement::CellMarker &marker, double t, double dt, double *__restrict__ inputValues, double *__restrict__ outputValues, int numberOfInputValues, int numberOfResultValues, Functor functor) | |
| Create plain enclave task. | |
| EnclaveTask (const EnclaveTask &other)=delete | |
| EnclaveTask (const EnclaveTask &&other)=delete | |
| virtual | ~EnclaveTask ()=default |
| virtual void | run () override |
| Computes a task and bookmarks the outcome. | |
| void | computeTask () |
| Compute the task. | |
| int | getTaskId () const |
| Return _taskNumber. | |
| Public Member Functions inherited from tarch::multicore::Task | |
| Task (int taskType, int priority) | |
| Construct task. | |
| virtual | ~Task () |
| int | getTaskType () const |
| int | getPriority () const |
| void | setPriority (int priority) |
| Set priority. | |
| virtual bool | canFuse () const |
| virtual void | fuse (const std::vector< Task * > &otherTasks, int targetDevice=Host) |
| Fuse multiple tasks. | |
| virtual std::string | toString () const |
Static Public Member Functions | |
| static int | getNumberOfActiveTasks () |
| static void | releaseTaskNumber (int number) |
| static int | reserveTaskNumber () |
| Reserve a new enclave task number. | |
Protected Attributes | |
| const int | _taskNumber |
| Each task needs a unique number, so we can look up its output. | |
| const ::peano4::datamanagement::CellMarker | _marker |
| const double | _t |
| These are the reconstructed values in the Finite Volume sense and the linear combination in the DG solver. | |
| const double | _dt |
| double *__restrict__ | _inputValues |
| double *__restrict__ | _outputValues |
| int | _numberOfInputValues |
| int | _numberOfResultValues |
| Functor | _functor |
| double | _maxEigenvalue |
| Protected Attributes inherited from tarch::multicore::Task | |
| const int | _taskType |
| int | _priority |
Static Protected Attributes | |
| static tarch::logging::Log | _log |
Static Private Attributes | |
| static tarch::multicore::TaskEnumerator | _enumerator |
Friends | |
| class | EnclaveBookkeeping |
Additional Inherited Members | |
| Static Public Attributes inherited from tarch::multicore::Task | |
| static constexpr int | DefaultPriority = 1024 |
| static constexpr int | Host = -1 |
| static constexpr int | DontFuse = -1 |
Base class for all enclave tasks.
Please study the enclave task in tandem with the EnclaveBookkeeping. Enclave tasks use the bookkeeping to register themselves (obtain a task number). The bookkeeping thus is aware which enclave tasks are outstanding still. Once an enclave task terminates, it registers itself again with the bookkeeping - this time as finished, so anybody can grab the outcome.
Enclave tasks per se are application-generic. They are given an array of values, they are told how big the output data has to be, and they are also given a functor which tells them what to run on the outcome. They don't know anything about the functor's semantics.
Tasks are automatically destroyed when we make their run() method return false. Enclave tasks however are slightly different: They create their outcome array on the heap. This has to be the CPU heap - not a stack, not an accelerator. When they have computed their stuff, they have to hand over this heap (and the responsibility to destroy it) to the bookkeeping and then can be deleted themselves.
Every ExaHyPE solver category defines its own enclave tasks being subclasses of the present, generic type. Enclave tasks are always to be spawned with their task number, so we can efficiently wait for them:
You should try to release the enclave task numbers eventually. Otherwise, you will get huge enclave task maps and an overflow if you are unlucky.
If you enable SmartMPI, then all enclave tasks are SmartMPI tasks, too. I could realise this through multiple inheritance, but I have to know excactly how big the memory footprint behind an enclave task is, so I decided against this. Instead, subclasses of the enclave task do specialise w.r.t. SmartMPI.
Definition at line 79 of file EnclaveTask.h.
| typedef std::function<void()> exahype2::EnclaveTask::Functor |
Definition at line 81 of file EnclaveTask.h.
| exahype2::EnclaveTask::EnclaveTask | ( | int | enclaveTaskTypeId, |
| const ::peano4::datamanagement::CellMarker & | marker, | ||
| double | t, | ||
| double | dt, | ||
| double *__restrict__ | inputValues, | ||
| double *__restrict__ | outputValues, | ||
| int | numberOfInputValues, | ||
| int | numberOfResultValues, | ||
| Functor | functor ) |
Create plain enclave task.
It is best to use the parallel factory mechanism within parallel:
| inputValues | Has to be created on heap via tarch::multicore::allocateMemory(). |
| enclaveTaskTypeId | Unique id for this type. If you use task merging, only tasks of the same type will be merged. |
| outputValues | If you pass in nullptr, then the enclave task will create a new array on the heap for the task output and then move this one over into the bookkeeping from where it eventually will be copied once more into the target data field. |
Definition at line 30 of file EnclaveTask.cpp.
References _dt, _functor, _inputValues, _marker, _maxEigenvalue, _numberOfInputValues, _numberOfResultValues, _outputValues, _t, _taskNumber, assertion1, tarch::multicore::Task::DefaultPriority, exahype2::EnclaveBookkeeping::getInstance(), logTraceIn, logTraceOut, exahype2::EnclaveBookkeeping::registerTask(), reserveTaskNumber(), tarch::multicore::Task::Task(), and tarch::multicore::Task::toString().
Referenced by EnclaveTask(), and EnclaveTask().


|
delete |
|
delete |
|
virtualdefault |
| void exahype2::EnclaveTask::computeTask | ( | ) |
Compute the task.
Typically invoked by run() - though it might also be called directly by smartMPI, e.g. The routine basically forwards the call to the functor stored within the task. Before that, it checks if the task is supposed to allocate the memory for the task outcomes itself. If so, we allocate in the shared GPU memory, as the task might be deployed there.
Definition at line 69 of file EnclaveTask.cpp.
References _functor, _inputValues, _maxEigenvalue, _numberOfResultValues, _outputValues, _taskNumber, tarch::allocateMemory(), assertion, logDebug, and tarch::ManagedSharedAcceleratorDeviceMemory.
Referenced by run().


|
static |
Definition at line 16 of file EnclaveTask.cpp.
References _enumerator.
Referenced by exahype2::EnclaveBookkeeping::dumpStatistics().

| int exahype2::EnclaveTask::getTaskId | ( | ) | const |
Return _taskNumber.
Definition at line 85 of file EnclaveTask.cpp.
References _taskNumber.
Referenced by run().

Definition at line 19 of file EnclaveTask.cpp.
References _enumerator, and logDebug.
Referenced by exahype2::EnclaveBookkeeping::finishedTask(), and exahype2::EnclaveBookkeeping::waitForTaskToTerminateAndReturnResult().

|
static |
Reserve a new enclave task number.
This factory mechanism is implicitly used by the constructor of an enclave task. However, we make it public. Therefore, you can also hijack enclave task numbers. This comes in handy if you want to manually insert predecessor tasks to enclave tasks: You create "your own" enclave task, the enclave task creation will recognise that a task is already associated with a cell, and hence use this one as additional input constraint.
Definition at line 25 of file EnclaveTask.cpp.
References _enumerator.
Referenced by EnclaveTask().

|
overridevirtual |
Computes a task and bookmarks the outcome.
Implements tarch::multicore::Task.
Definition at line 61 of file EnclaveTask.cpp.
References _marker, _maxEigenvalue, _numberOfResultValues, _outputValues, computeTask(), exahype2::EnclaveBookkeeping::finishedTask(), exahype2::EnclaveBookkeeping::getInstance(), getTaskId(), logTraceInWith1Argument, and logTraceOut.

|
friend |
Definition at line 84 of file EnclaveTask.h.
References EnclaveBookkeeping.
Referenced by EnclaveBookkeeping.
|
protected |
Definition at line 101 of file EnclaveTask.h.
Referenced by EnclaveTask().
|
staticprivate |
Definition at line 187 of file EnclaveTask.h.
Referenced by getNumberOfActiveTasks(), releaseTaskNumber(), and reserveTaskNumber().
|
protected |
Definition at line 106 of file EnclaveTask.h.
Referenced by computeTask(), and EnclaveTask().
|
protected |
Definition at line 102 of file EnclaveTask.h.
Referenced by computeTask(), and EnclaveTask().
|
staticprotected |
Definition at line 86 of file EnclaveTask.h.
|
protected |
Definition at line 92 of file EnclaveTask.h.
Referenced by EnclaveTask(), and run().
|
protected |
Definition at line 107 of file EnclaveTask.h.
Referenced by computeTask(), EnclaveTask(), and run().
|
protected |
Definition at line 104 of file EnclaveTask.h.
Referenced by EnclaveTask().
|
protected |
Definition at line 105 of file EnclaveTask.h.
Referenced by computeTask(), EnclaveTask(), and run().
|
protected |
Definition at line 103 of file EnclaveTask.h.
Referenced by computeTask(), EnclaveTask(), and run().
|
protected |
These are the reconstructed values in the Finite Volume sense and the linear combination in the DG solver.
In both cases, the enclave task will free the memory once it has terminated, so the attribute may not be const here.
Definition at line 100 of file EnclaveTask.h.
Referenced by EnclaveTask().
|
protected |
Each task needs a unique number, so we can look up its output.
Definition at line 91 of file EnclaveTask.h.
Referenced by computeTask(), EnclaveTask(), and getTaskId().