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 bool | 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 bool | fuse (const std::list< Task * > &otherTasks, int targetDevice=Host) |
Fuse multiple tasks. | |
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::Enumerator | _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:
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 76 of file EnclaveTask.h.
typedef std::function<void()> exahype2::EnclaveTask::Functor |
Definition at line 78 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 29 of file EnclaveTask.cpp.
References logTraceIn, and logTraceOut.
|
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 65 of file EnclaveTask.cpp.
References assertion, logDebug, and tarch::ManagedSharedAcceleratorDeviceMemory.
|
static |
Definition at line 16 of file EnclaveTask.cpp.
References _enumerator, and tarch::Enumerator::size().
Referenced by exahype2::EnclaveBookkeeping::dumpStatistics().
int exahype2::EnclaveTask::getTaskId | ( | ) | const |
Return _taskNumber.
Definition at line 81 of file EnclaveTask.cpp.
Definition at line 19 of file EnclaveTask.cpp.
Referenced by exahype2::EnclaveBookkeeping::cancelTask(), 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 24 of file EnclaveTask.cpp.
|
overridevirtual |
Computes a task and bookmarks the outcome.
Implements tarch::multicore::Task.
Definition at line 56 of file EnclaveTask.cpp.
References exahype2::EnclaveBookkeeping::finishedTask(), exahype2::EnclaveBookkeeping::getInstance(), logTraceInWith1Argument, and logTraceOut.
|
friend |
Definition at line 81 of file EnclaveTask.h.
|
protected |
Definition at line 98 of file EnclaveTask.h.
|
staticprivate |
Definition at line 184 of file EnclaveTask.h.
Referenced by getNumberOfActiveTasks().
|
protected |
Definition at line 103 of file EnclaveTask.h.
Referenced by peano4.visualisation.filters.Calculator.Calculator::render().
|
protected |
Definition at line 99 of file EnclaveTask.h.
|
staticprotected |
Definition at line 83 of file EnclaveTask.h.
|
protected |
Definition at line 89 of file EnclaveTask.h.
|
protected |
Definition at line 104 of file EnclaveTask.h.
|
protected |
Definition at line 101 of file EnclaveTask.h.
|
protected |
Definition at line 102 of file EnclaveTask.h.
|
protected |
Definition at line 100 of file EnclaveTask.h.
|
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 97 of file EnclaveTask.h.
|
protected |
Each task needs a unique number, so we can look up its output.
Definition at line 88 of file EnclaveTask.h.