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 FaceData {
27 tarch::la::Vector<DIMENSIONS, double>*
faceSize;
74 const tarch::la::Vector<DIMENSIONS, double>& faceCentre_,
75 const tarch::la::Vector<DIMENSIONS, double>& faceSize_,
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
99 template <
typename inType,
typename outType>
102 const tarch::la::Vector<DIMENSIONS, double>& faceCentre_,
103 const tarch::la::Vector<DIMENSIONS, double>& faceSize_,
107 tarch::MemoryLocation memoryLocation_,
110 FaceData(1, memoryLocation_, targetDevice_) {
120 template <
typename inType,
typename outType>
122 FaceData(
int numberOfFaces_, tarch::MemoryLocation memoryLocation_,
int targetDevice_):
123 numberOfFaces(numberOfFaces_),
124 memoryLocation(memoryLocation_),
125 targetDevice(targetDevice_) {
127 QIn = tarch::accelerator::MemoryManager::getInstance().allocate<inType* [2]>(
132 faceCentre = tarch::accelerator::MemoryManager::getInstance().allocate<tarch::la::Vector<DIMENSIONS, double>>(
137 faceSize = tarch::accelerator::MemoryManager::getInstance().allocate<tarch::la::Vector<DIMENSIONS, double>>(
142 t = tarch::accelerator::MemoryManager::getInstance().allocate<
double>(numberOfFaces_, memoryLocation_, targetDevice_);
143 dt = tarch::accelerator::MemoryManager::getInstance().allocate<
double>(
148 id = tarch::accelerator::MemoryManager::getInstance().allocate<
int>(numberOfFaces_, memoryLocation_, targetDevice_);
149 QOut = tarch::accelerator::MemoryManager::getInstance().allocate<outType* [2]>(
165 tarch::accelerator::MemoryManager::getInstance().free(QIn, targetDevice);
166 tarch::accelerator::MemoryManager::getInstance().free(faceCentre, targetDevice);
167 tarch::accelerator::MemoryManager::getInstance().free(faceSize, targetDevice);
168 tarch::accelerator::MemoryManager::getInstance().free(
t, targetDevice);
169 tarch::accelerator::MemoryManager::getInstance().free(
dt, targetDevice);
170 tarch::accelerator::MemoryManager::getInstance().free(QOut, targetDevice);
171 tarch::accelerator::MemoryManager::getInstance().free(
id, targetDevice);
175 std::ostringstream
msg;
177 for (
int i = 0; i < numberOfFaces; i++) {
178 msg <<
"(x=" << faceCentre[i] <<
",h=" << faceSize[i] <<
",t=" <<
t[i] <<
",dt=" <<
dt[i] <<
",id=" <<
id[i] <<
")";
Represents the sides of one face, with 2 sides (left and right) to a face For ADER QIn will contain t...
FaceData & operator=(const FaceData &)=delete
FaceData(inType *QIn_[2], const tarch::la::Vector< DIMENSIONS, double > &faceCentre_, const tarch::la::Vector< DIMENSIONS, double > &faceSize_, double t_, double dt_, outType *QOut_[2], 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.
tarch::la::Vector< DIMENSIONS, double > * faceSize
inType *(* QIn)[2]
QIn may not be const, as some kernels delete it straightaway once the input data has been handled.
const tarch::MemoryLocation memoryLocation
We might want to allocate data on the heap or an accelerator, therefore we save the target device id.
int * id
Id of underlying task.
FaceData(const FaceData ©)=delete
tarch::la::Vector< DIMENSIONS, double > * faceCentre
std::string toString() const
outType *(* QOut)[2]
Out values.
const int numberOfFaces
As we store data as SoA, we have to know how big the actual arrays are.