Peano 4
Loading...
Searching...
No Matches
EnclaveTask.cpp
Go to the documentation of this file.
1#include "EnclaveTask.h"
2
3#include "config.h"
9
10
12
13
15
16
18
19
21 _enumerator.releaseNumber(number);
22}
23
24
26 return _enumerator.getNumber();
27}
28
29
31 int enclaveTaskTypeId,
32 const ::peano4::datamanagement::CellMarker& marker,
33 double t,
34 double dt,
35 double* __restrict__ inputValues,
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(nullptr),
47 _numberOfInputValues(numberOfInputValues),
48 _numberOfResultValues(numberOfResultValues),
49 _functor(functor),
50 _maxEigenvalue(-1.0) {
51 logTraceIn("EnclaveTask(...)");
52 logTraceOut("EnclaveTask(...)");
54 enclave_task, OTTER_NULL_TASK, otter_add_to_pool, otter::label::enclave_with_typeid, enclaveTaskTypeId
55 );
56}
57
58
60 logTraceInWith1Argument("run()", getTaskId());
61
63
64 OTTER_TASK_START(enclave_task);
65 computeTask();
66 EnclaveBookkeeping::getInstance().finishedTask(getTaskId(), _numberOfResultValues, _outputValues, _maxEigenvalue);
67 OTTER_TASK_END(enclave_task);
68
69 logTraceOut("run()");
70 return false;
71}
72
73
75 assertion(_outputValues == nullptr);
76 assertion(_numberOfResultValues > 0);
77 assertion(_inputValues != nullptr);
78
79 _outputValues = tarch::allocateMemory<double>(_numberOfResultValues, tarch::MemoryLocation::ManagedSharedAcceleratorDeviceMemory);
80
81 logDebug("computeTask()", "lambda=" << _maxEigenvalue);
82 _functor();
83}
84
85
86int 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:61
static tarch::logging::Log _log
Definition EnclaveTask.h:66
static int getNumberOfActiveTasks()
static int reserveTaskNumber()
virtual bool run() override
Computes a task and bookmarks the outcome.
static tarch::Enumerator _enumerator
void computeTask()
Computes a task without bookmarking the outcome.
static void releaseTaskNumber(int number)
EnclaveTask(int enclaveTaskTypeId, const ::peano4::datamanagement::CellMarker &marker, double t, double dt, double *__restrict__ inputValues, int numberOfInputValues, int numberOfResultValues, Functor functor)
int getTaskId() const
Return _taskNumber.
Simple rank-global enumerator.
Definition Enumerator.h:22
int size() const
Number of numbers handed out so far.
Log Device.
Definition Log.h:516
static const char * enclave_with_typeid
Definition otter.h:108
Have to include this header, as I need access to the SYCL_EXTERNAL keyword.
Definition accelerator.h:17
@ ManagedSharedAcceleratorDeviceMemory
To be used on host only.
#define OTTER_POOL_DECL_POP(...)
Definition otter.h:138
#define OTTER_TASK_END(...)
Definition otter.h:141
#define OTTER_TASK_START(...)
Definition otter.h:140
#define OTTER_DEFINE_TASK(...)
Definition otter.h:133