Brick Library 0.1
Performance-portable stencil datalayout & codegen
|
Compilation have two phase when using the code generator.
include/vecscatter.h
defined two different code generation targets: a) for use with tiled code b) more importantly, for use with bricked code. The detailed usage are shown with defintions #tile(...)
and #brick(...)
, correspondingly.
For examples see Line 34 in weak/main.cpp
using the brick version. One constant expanded version of this call is as follows:
The code generator, codegen/vecscatter
, will run C/C++ preprocessor that can resolve all preprocessor defines and expanded into vecscatter
pragma by the preprocessor. The code generator will then scan the processed code and look for #pragma vecscatter
to generate the code.
In CMake this code generation step is achieved by simply calling VSTARGET
:
This defines a code generation target with name N3MPI
.
This CMake call uses information defined by include_directories
, CMAKE_CXX_FLAGS
, and any custom options in ${NAME}_COMPILE_OPTIONS
.
The preprocessor to use can be customized by setting variable VS_PREPROCESSOR
, who uses cpp
as the default.
The main-out.cpp
in the argument to VSTARGET
is the code generated output. This is also captured by cmake variable ${VSTARGET_${NAME}_OUTPUT}
.
To compile with Make is just as simple. The source code doesn't needs to be changed.
However, the work done with VSTARGET
needs to be written as explicit targets in Make.
This target calls the code generator by running codegen/vecscatter
. The first two arguments are the input and output filename. The other options can be querried by running codegen/vecscatter -h
.
main-out.cpp
can thus be used as normal.