Peano
Loading...
Searching...
No Matches
EnclaveTask.cpp
Go to the documentation of this file.
1#include "EnclaveTask.h"
2
3#include "config.h"
8
9
11
12
14
15
17
18
20 _enumerator.releaseNumber(number);
21}
22
23
25 return _enumerator.getNumber();
26}
27
28
30 int enclaveTaskTypeId,
31 const ::peano4::datamanagement::CellMarker& marker,
32 double t,
33 double dt,
34 double* __restrict__ inputValues,
35 double* __restrict__ outputValues,
36 int numberOfInputValues,
37 int numberOfResultValues,
38 Functor functor
39):
40 tarch::multicore::Task(enclaveTaskTypeId, tarch::multicore::Task::DefaultPriority),
41 _taskNumber(reserveTaskNumber()),
42 _marker(marker),
43 _t(t),
44 _dt(dt),
45 _inputValues(inputValues),
46 _outputValues(outputValues),
47 _numberOfInputValues(numberOfInputValues),
48 _numberOfResultValues(numberOfResultValues),
49 _functor(functor),
50 _maxEigenvalue(-1.0) {
51 logTraceIn("EnclaveTask(...)");
52 logTraceOut("EnclaveTask(...)");
53}
54
55
57 logTraceInWith1Argument("run()", getTaskId());
58 computeTask();
59 EnclaveBookkeeping::getInstance().finishedTask(getTaskId(), _numberOfResultValues, _outputValues, _maxEigenvalue);
60 logTraceOut("run()");
61}
62
63
65 assertion(_numberOfResultValues > 0);
66 assertion(_inputValues != nullptr);
67
68 if (_outputValues==nullptr) {
69 _outputValues = tarch::allocateMemory<double>(_numberOfResultValues, tarch::MemoryLocation::ManagedSharedAcceleratorDeviceMemory);
70 }
71 else {
72 logDebug( "computeTask()", "enclave task " << _taskNumber << " writes directly into mesh data structure at " << _outputValues << " (uses data from " << _inputValues << ")" );
73 }
74
75 logDebug("computeTask()", "lambda=" << _maxEigenvalue);
76 _functor();
77}
78
79
80int exahype2::EnclaveTask::getTaskId() const { return _taskNumber; }
#define assertion(expr)
#define logDebug(methodName, logMacroMessageStream)
Definition Log.h:50
#define logTraceOut(methodName)
Definition Log.h:379
#define logTraceIn(methodName)
Definition Log.h:369
#define logTraceInWith1Argument(methodName, argument0)
Definition Log.h:370
static EnclaveBookkeeping & getInstance()
void finishedTask(int taskNumber, int numberOfResultValues, double *data, double maxEigenvalue)
Usually called directly by EnclaveTask.
std::function< void()> Functor
Definition EnclaveTask.h:78
virtual void run() override
Computes a task and bookmarks the outcome.
static tarch::logging::Log _log
Definition EnclaveTask.h:83
static int getNumberOfActiveTasks()
static int reserveTaskNumber()
Reserve a new enclave task number.
static tarch::Enumerator _enumerator
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.
void computeTask()
Compute the task.
static void releaseTaskNumber(int number)
int getTaskId() const
Return _taskNumber.
Simple rank-global enumerator.
Definition Enumerator.h:24
int size() const
Number of numbers handed out so far.
Log Device.
Definition Log.h:516
Have to include this header, as I need access to the SYCL_EXTERNAL keyword.
Definition accelerator.h:19
@ ManagedSharedAcceleratorDeviceMemory
To be used on host only.