5 #include "peano4/utils/Globals.h"
6 #include "tarch/accelerator/accelerator.h"
7 #include "tarch/accelerator/MemoryManager.h"
8 #include "tarch/la/Vector.h"
20 template <
typename inType =
double,
typename outType =
double>
struct CellFaceData {
25 inType* (*QIn)[2 * DIMENSIONS];
27 tarch::la::Vector<DIMENSIONS, double>*
cellSize;
60 outType* (*QOut)[2 * DIMENSIONS];
73 inType* QIn_[2 * DIMENSIONS],
74 const tarch::la::Vector<DIMENSIONS, double>& cellCentre_,
75 const tarch::la::Vector<DIMENSIONS, double>& cellSize_,
78 outType* QOut_[2 * DIMENSIONS],
79 tarch::MemoryLocation memoryLocation_ = tarch::MemoryLocation::Heap,
80 int targetDevice_ = tarch::accelerator::Device::DefaultDevice
85 tarch::MemoryLocation memoryLocation_ = tarch::MemoryLocation::Heap,
86 int targetDevice_ = tarch::accelerator::Device::DefaultDevice
98 template <
typename inType,
typename outType>
100 inType* QIn_[2 * DIMENSIONS],
101 const tarch::la::Vector<DIMENSIONS, double>& cellCentre_,
102 const tarch::la::Vector<DIMENSIONS, double>& cellSize_,
105 outType* QOut_[2 * DIMENSIONS],
106 tarch::MemoryLocation memoryLocation_,
119 template <
typename inType,
typename outType>
121 CellFaceData(
int numberOfCells_, tarch::MemoryLocation memoryLocation_,
int targetDevice_):
122 numberOfCells(numberOfCells_),
123 memoryLocation(memoryLocation_),
124 targetDevice(targetDevice_) {
126 QIn =
reinterpret_cast<inType* (*)[2 * DIMENSIONS]
>(tarch::accelerator::MemoryManager::getInstance().allocate<inType*>(
127 2 * DIMENSIONS * numberOfCells_,
131 cellCentre = tarch::accelerator::MemoryManager::getInstance().allocate<tarch::la::Vector<DIMENSIONS, double>>(
136 cellSize = tarch::accelerator::MemoryManager::getInstance().allocate<tarch::la::Vector<DIMENSIONS, double>>(
141 t = tarch::accelerator::MemoryManager::getInstance().allocate<
double>(numberOfCells_, memoryLocation_, targetDevice_);
142 dt = tarch::accelerator::MemoryManager::getInstance().allocate<
double>(
147 id = tarch::accelerator::MemoryManager::getInstance().allocate<
int>(numberOfCells_, memoryLocation_, targetDevice_);
148 QOut =
reinterpret_cast<inType* (*)[2 * DIMENSIONS]
>(tarch::accelerator::MemoryManager::getInstance().allocate<outType*>(
149 2 * DIMENSIONS * numberOfCells_,
164 tarch::accelerator::MemoryManager::getInstance().free(QIn, targetDevice);
165 tarch::accelerator::MemoryManager::getInstance().free(cellCentre, targetDevice);
166 tarch::accelerator::MemoryManager::getInstance().free(
cellSize, targetDevice);
167 tarch::accelerator::MemoryManager::getInstance().free(
t, targetDevice);
168 tarch::accelerator::MemoryManager::getInstance().free(
dt, targetDevice);
169 tarch::accelerator::MemoryManager::getInstance().free(QOut, targetDevice);
170 tarch::accelerator::MemoryManager::getInstance().free(
id, targetDevice);
174 std::ostringstream
msg;
176 for (
int i = 0; i < numberOfCells; i++) {
177 msg <<
"(x=" << cellCentre[i] <<
",h=" <<
cellSize[i] <<
",t=" <<
t[i] <<
",dt=" <<
dt[i] <<
",id=" <<
id[i] <<
")";
const tarch::la::Vector< DIMENSIONS, double > cellSize
Represents the faces of one cell, with a total of 2*Dim faces per cell For ADER QIn will contain the ...
tarch::la::Vector< DIMENSIONS, double > * cellSize
tarch::la::Vector< DIMENSIONS, double > * cellCentre
CellFaceData(inType *QIn_[2 *DIMENSIONS], const tarch::la::Vector< DIMENSIONS, double > &cellCentre_, const tarch::la::Vector< DIMENSIONS, double > &cellSize_, double t_, double dt_, outType *QOut_[2 *DIMENSIONS], tarch::MemoryLocation memoryLocation_=tarch::MemoryLocation::Heap, int targetDevice_=tarch::accelerator::Device::DefaultDevice)
Construct patch data object for one single cell.
const int targetDevice
We might want to allocate data on an accelerator, therefore we save the target device id.
int * id
Id of underlying task.
outType *(* QOut)[2 *DIMENSIONS]
Out values.
const tarch::MemoryLocation memoryLocation
We might want to allocate data on the heap or an accelerator, therefore we save the target device id.
CellFaceData & operator=(const CellFaceData &)=delete
CellFaceData(const CellFaceData ©)=delete
std::string toString() const
inType *(* QIn)[2 *DIMENSIONS]
QIn may not be const, as some kernels delete it straightaway once the input data has been handled.
const int numberOfCells
As we store data as SoA, we have to know how big the actual arrays are.