How to use the template library
Brick library enables fine-grained data blocking for use in regular C++ program. It should support initialization of bricks and copying between regular array layout.
Overall design
The brick library uses C++ templates to handle dimensions and address calculation. There are three main components/data structures.
Creating bricks
To create a brick data structure consider the code in d3pt7 from stencils/3axis.cpp.
BrickInfo bInfo = init_grid<3>(grid_ptr, {4, 4, 4});
Metadata related to bricks.
Definition: brick.h:97
unsigned nbricks
Number of bricks in this list.
Definition: brick.h:103
Initializing and holding the storage of bricks.
Definition: brick.h:53
static BrickStorage allocate(long chunks, size_t step)
Allocation using *alloc.
Definition: brick.h:68
Generic base template, see Brick< Dim< BDims... >, Dim< Folds... > >
Definition: brick.h:340
Empty template to specify an n-D list.
Definition: brick.h:131
The above code creates $4\times 4 \times 4$ of $8\times 8\times 8$ bricks with two brick accessors interleaved. The following explains each line:
- BrickInfo struct is initialized by init_grid helper functions. It returns a three-dimensional array
grid_ptr. The second argument is the size of the grid in number of bricks per dimension.
- BrickStorage::allocate initialize a BrickStorage object with specified number of bricks and each "brick"'s size is specified in the second arguments. This accommodates for cases when multiple bricks from different "fields" are interleaved.
- Also 4. The Brick accessor is created with bIn and bOut interleaved in
bStorage. Each vector in brick is $2\times 2$.
Using bricks
- Each brick can be treated as a multidimensional array.
Cleaning up
Currently, the following requires manual cleanup.
- Any
grid_ptr created by either the user or with init_grid methods.
- The
adj field in brickInfo.