Commit 733e2ad1 authored by Martin Bauer's avatar Martin Bauer
Browse files

Field data getters used by code generation

parent 8ad4dbd9
......@@ -133,6 +133,9 @@ namespace cuda {
void * data() { return pitchedPtr_.ptr; }
const void * data() const { return pitchedPtr_.ptr; }
T * dataAt(cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f);
const T * dataAt(cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f) const;
protected:
cudaPitchedPtr pitchedPtr_;
uint_t nrOfGhostLayers_;
......
......@@ -67,6 +67,26 @@ GPUField<T>::~GPUField()
cudaFree( pitchedPtr_.ptr );
}
template<typename T>
T * GPUField<T>::dataAt(cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f)
{
auto offset = (x + nrOfGhostLayers_) * xStride() +
(y + nrOfGhostLayers_) * yStride() +
(z + nrOfGhostLayers_) * zStride() +
f * fStride();
return static_cast<T*>(pitchedPtr_.ptr) + offset;
}
template<typename T>
const T * GPUField<T>::dataAt(cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f) const
{
auto offset = (x + nrOfGhostLayers_) * xStride() +
(y + nrOfGhostLayers_) * yStride() +
(z + nrOfGhostLayers_) * zStride() +
f * fStride();
return static_cast<T*>(pitchedPtr_.ptr) + offset;
}
template<typename T>
void GPUField<T>::getGhostRegion(stencil::Direction d, CellInterval & ci,
......
......@@ -291,6 +291,8 @@ namespace field {
//@{
T * data() { return values_; }
const T * data() const { return values_; }
T * dataAt(cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f) { return &get(x,y,z,f); }
const T * dataAt(cell_idx_t x, cell_idx_t y, cell_idx_t z, cell_idx_t f) const { return &get(x,y,z,f); }
T * dataInner() { return valuesWithOffset_; }
const T * dataInner() const { return valuesWithOffset_; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment