StencilStream v3.0.0
SYCL-based Stencil Simulation Framework Targeting FPGAs
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Attributes | List of all members
stencil::cpu::Grid< Cell > Class Template Reference

A grid class for the CPU backend. More...

#include <Grid.hpp>

Classes

class  GridAccessor
 An accessor for the grid. More...
 

Public Member Functions

 Grid (uindex_t c, uindex_t r)
 Create a new, uninitialized grid with the given dimensions.
 
 Grid (sycl::range< 2 > range)
 Create a new, uninitialized grid with the given dimensions.
 
 Grid (sycl::buffer< Cell, 2 > other_buffer)
 Create a new grid with the same size and contents as the given SYCL buffer.
 
 Grid (Grid const &other_grid)
 Create a new reference to the given grid.
 
void copy_from_buffer (sycl::buffer< Cell, 2 > other_buffer)
 Copy the contents of the SYCL buffer into the grid.
 
void copy_to_buffer (sycl::buffer< Cell, 2 > other_buffer)
 Copy the contents of the grid into the SYCL buffer.
 
uindex_t get_grid_width () const
 Return the width, or number of columns, of the grid.
 
uindex_t get_grid_height () const
 Return the height, or number of rows, of the grid.
 
Grid make_similar () const
 Create an new, uninitialized grid with the same size as the current one.
 
sycl::buffer< Cell, 2 > & get_buffer ()
 

Static Public Attributes

static constexpr uindex_t dimensions = 2
 The number of dimensions of the grid.
 

Detailed Description

template<typename Cell>
class stencil::cpu::Grid< Cell >

A grid class for the CPU backend.

This grid, which fullfils the Grid concept, contains a two-dimensional buffer of cells to be used together with the StencilUpdate class.

The contents of the grid can be accessed by a host-side program using the GridAccessor class template. For example, one can write the contents of a grid object as follows:

for (uindex_t c = 0; c < grid.get_grid_width(); c++) {
for (uindex_t r = 0; r < grid.get_grid_height(); r++) {
accessor[c][r] = foo(c, r);
}
}
An accessor for the grid.
Definition Grid.hpp:147
BOOST_PP_CAT(BOOST_PP_CAT(uint, STENCIL_INDEX_WIDTH), _t) uindex_t
An unsigned integer of configurable width.
Definition Index.hpp:42

Alternatively, one may write their data into a SYCL buffer and copy it into the grid using the method copy_from_buffer. The method copy_to_buffer does the reverse: It writes the contents of the grid into a SYCL buffer.

Template Parameters
CellThe cell type to store.

Constructor & Destructor Documentation

◆ Grid() [1/4]

template<typename Cell >
stencil::cpu::Grid< Cell >::Grid ( uindex_t  c,
uindex_t  r 
)
inline

Create a new, uninitialized grid with the given dimensions.

Parameters
cThe width, or number of columns, of the new grid.
rThe height, or number of rows, of the new grid.

◆ Grid() [2/4]

template<typename Cell >
stencil::cpu::Grid< Cell >::Grid ( sycl::range< 2 >  range)
inline

Create a new, uninitialized grid with the given dimensions.

Parameters
rangeThe range of the new grid. The first index will be the width and the second index will be the height of the grid.

◆ Grid() [3/4]

template<typename Cell >
stencil::cpu::Grid< Cell >::Grid ( sycl::buffer< Cell, 2 >  other_buffer)
inline

Create a new grid with the same size and contents as the given SYCL buffer.

The contents of the buffer will be copied to the grid by the host. The SYCL buffer can later be used elsewhere.

Parameters
other_bufferThe buffer with the contents of the new grid.

◆ Grid() [4/4]

template<typename Cell >
stencil::cpu::Grid< Cell >::Grid ( Grid< Cell > const &  other_grid)
inline

Create a new reference to the given grid.

The newly created grid object will point to the same underlying data as the referenced grid. Changes made via the newly created grid object will also be visible to the old grid object, and vice-versa.

Parameters
other_gridThe other grid the new grid should reference.

Member Function Documentation

◆ copy_from_buffer()

template<typename Cell >
void stencil::cpu::Grid< Cell >::copy_from_buffer ( sycl::buffer< Cell, 2 >  other_buffer)
inline

Copy the contents of the SYCL buffer into the grid.

The SYCL buffer will be accessed read-only one the host; It may be used elsewhere too. The buffer however has to have the same size as the grid, otherwise a std::range_error is thrown.

Parameters
other_bufferThe buffer to copy the data from.
Exceptions
std::range_errorThe size of the buffer does not match the grid.

◆ copy_to_buffer()

template<typename Cell >
void stencil::cpu::Grid< Cell >::copy_to_buffer ( sycl::buffer< Cell, 2 >  other_buffer)
inline

Copy the contents of the grid into the SYCL buffer.

The contents of the SYCL buffer will be overwritten on the host. The buffer also has to have the same size as the grid, otherwise a std::range_error is thrown.

Parameters
other_bufferThe buffer to copy the data to.
Exceptions
std::range_errorThe size of the buffer does not match the grid.

◆ get_buffer()

template<typename Cell >
sycl::buffer< Cell, 2 > & stencil::cpu::Grid< Cell >::get_buffer ( )
inline

◆ get_grid_height()

template<typename Cell >
uindex_t stencil::cpu::Grid< Cell >::get_grid_height ( ) const
inline

Return the height, or number of rows, of the grid.

◆ get_grid_width()

template<typename Cell >
uindex_t stencil::cpu::Grid< Cell >::get_grid_width ( ) const
inline

Return the width, or number of columns, of the grid.

◆ make_similar()

template<typename Cell >
Grid stencil::cpu::Grid< Cell >::make_similar ( ) const
inline

Create an new, uninitialized grid with the same size as the current one.

Member Data Documentation

◆ dimensions

template<typename Cell >
constexpr uindex_t stencil::cpu::Grid< Cell >::dimensions = 2
staticconstexpr

The number of dimensions of the grid.

May be changed in the future when other dimensions are supported.


The documentation for this class was generated from the following file: