|
Astaroth
3.1
Scalable Multi-GPU Stencil Computations
|
Directories | |
| acc | |
| api | |
The DSL source files should have a postfix *.ac and by default there should be only one *.ac file per directory. Optionally you can give the *.ac file to be compiled.
* `mkdir build`
* `cd build`
* `cmake -DDSL_MODULE_DIR=<path (relative to the build directory) to the dir containing DSL sources> \
[-DSL_MODULE_FILE=<you can optionally give the file in DSL_MODULE_DIR to be compiled>] ..`
* `make -j`
As ACC is in active development, compiler bugs and cryptic error messages are expected. In case of issues, please check the following files in acc-runtime/api in the build directory.
Intermediate files:
Final files:
To make inspecting the code easier, we recommend using an autoformatting tool, for example, clang-format or GNU indent.
The Astaroth Domain-Specific Language (DSL) is a high-level general-purpose(GP)GPU language designed for improved productivity and performance in stencil computations. The Astaroth DSL compiler (< build dir >/acc-runtime/acc) is a source-to-source compiler, which converts DSL kernels into CUDA/HIP kernels. The generated kernels provide performance that is on-par with hand-tuned low-level GPGPU code in stencil computations. Special care has been taken to ensure efficient code generation in use cases encountered in computational physics, where there are multiple coupled fields, which makes manual caching notoriously difficult.
The Astaroth DSL is based on the stream processing model, where an array of instructions is executed on streams of data in parallel. A kernel is a small GPU program, which defines the operations performed on a number of data streams. In our case, data streams correspond to vertices in a grid, similar to how vertex shaders operate in graphics shading languages.
Since the language is still an active development user recommendations/requests for new features are highly desirable. To make a recommendation/request for a new feature make pull request where you outline the new feature and the use case it would be needed in.
The Astaroth preprocessor works similar to the C preprocessor (gcc) with one exception:
By default include files are searched relative to DSL_MODULE_DIR.
With two extensions:
The Astaroth DSL language is statically typed. All global variables require an explicit datatype declaration. Otherwise explicit typing is allowed but not required, with the exception of the parameters of overloaded functions. Some advanced features also require an explicit type declaration. By default we use C++ type inference rules (auto) with extensions where they would be ambiguous.
A Field is a scalar array that can be used in conjuction with Stencil operations and for operations involving only the current vertex point. The array containing the values of a Field is size of the local subdomain with the halos included so in other terms the array is of size [AC_mlocal.x][AC_mlocal.y][AC_mlocal.z] A vector field can be constructed either by combining three scalar Fields into a Field3 structure or one declaring a Field3 structure on its own.
To get the value of a Field at the current vertex use the built-in function value. A Field can be used directly in unary expressions and binary arithmetic expressions (+, -, /,*) which is equivalent to calling value on the Field. Also, calling a built-in math functions with Field is equivalent to first calling value on the Field. The same applies for Field3 and for arrays of them (Field[] and Field3[]).
Note: Internally, Field is an enum handle (VertexBufferHandle) referring to the input and output buffers (data cubes). Note: The numerical value of the handle is monotonically increasing in the order of the declarations of the Fields.
Arrays of Field variables can be declared with constant dimensions. The individual Field elements can be accessed by indexing the declared array.
The following primitive C++ types are usable:
Note: Whenever possible one should prefer using bools compared to e.g. integers which only have the values 0 and 1, since using bools gives the DSL compiler more information, which it can use to perform optimizations.
We support Matrix*real3,real*Matrix and -Matrix.
Structures can be defined similar to the C syntax:
They can be initialized as in C, except for type inference an explicit cast might be needed.
Note: Currently, declaring multiple members from a single type specifier is not allowed.
If all of the members of the structure are real we provide member-wise arithmetic operators (+, -, /, *) with real scalars. Additionally + and - are supported between structures of the same type, all of the members of which are real or int. For all operators the corresponding compound assignment operator is also supported.
Enums are declared in the C syntax
Note: Whenever possible one should prefer using enums compared to e.g. named integers, since using enums gives the DSL compiler more information which it can use to perform optimizations.
>Note: For performance reasons you should use gmem arrays when different indexes are used at different vertices at the same time. Additionally too large arrays on the device constant memory can degrade performance by limiting the amount of available cache too much.
Note: one can combine these to have communicated auxiliary Fields, without communicated, auxiliary Fields are not communicated.
The DSL compiler can also infer these qualifiers if OPTIMIZE_FIELDS=ON from write, value and Stencil calls. Additionally the DSL compiler can infer which Fields can be dead if you also have ALLOW_DEAD_FIELDS=ON Important requires that all conditionals are known at compile-time (or when loading Astaroth if using runtime compilation).
Note: At the moment, can be used only via ComputeSteps. See the section describing ComputeSteps for example usage.
Note: implicitly allocates memory on the GPU to perform reductions.
Variable declaration and naming conventions follow C, except shadowing is not allowed: all identifiers within a scope must be unique.
Instead of { } initializer of C++ we use [ ]
Note: Arrays are stored in column-major format, if you want to pass arrays in row-major set AC_host_has_row_memory_order=1. Arrays are still internally stored as column-major but the arrays are converted correctly between the two data formats. If you have a use case where having Astaroth store data in row-major format would be important make a pull request describing the use case and we can consider supporting it.
In branch reference-row-major-implementation one can find a version of Astaroth that internally supports also row-major. If OPTIMIZE_ARRAYS=ON the DSL compiler will identify unused gmem arrays and will not allocate them on the GPU.
One can use C and C++ casting.
Loops follow the Python style
Functions follow the C declaration syntax.
For functions which have take in a real parameter one can also provide a Field expression in the function call, with the expression being automatically converted to real by calling value with the value of the expression. The same is also true for Field3,real3,Field[],real[] and Field3[],real3[].
Overloading is supported. In case there are multiple possible functions that an overloaded call could be resolved to the functions are prioritized in the following order:
After applying the overloading resolution rules each function call should have only a single unique prefered function.
Note: This is most likely broken when declaring overloaded functions, where for some input parameters types are defined and for some not. A general solution to this is to define the input type of all input parameters, or simply to consider the priority rules in more detail and see why uniqueness fails.
func(param) {print("%s", param)}</blockquote>func2(val) {return val}func3(real x) {return fabs(x)}func3(real3 v) {returnreal3(fabs(v.x),fabs(v.y),fabs(v.z))}func3(v) {return 0.0}func3(v1,v2) {return 0.0}elemental abs(real x){return fabs(x)}@icode> Note: Function parameters are **passed by constant reference**. Therefore input parameters **cannot be modified** and one may need to introduce temporary variables for intermediate values when performing more complex calculations.The `elemental` type qualifier on a function means that it is a pure function that returns a value,for which the function's semantics are composable on structures and arrays containing the type of the return value.In the previous example functions we had some duplicate code since `func3` for `real3` does nothing but applies the scalar overload to all of its members.Since the `abs` function that takes in a `real` value has been declared `elemental` it can also be called with a `real3` and will produce the same effect as if `abs` was called on all of the members of the parameter.A `elemental` function taking a `real` parameter can be called with any structure that recursively only consist of types of `real`.By this we mean that one can call the functions with `real3` variables, but also with structures like e.g. `multiple_real3` that consist of `real3`s or even of structures that consist of `multiple_real3` or any other structure that recursively only consists of types of `real`.The same applies for arrays of these structures like `real[]` and `real3[]`.A `elemental` function taking a `Field` parameter has exactly the same rules, but now `real` interchanged for `Field`.### Printing// print is the same as printf in the C programming language print("Hello from thread (%d, %d, %d)\n", vertexIdx.x, vertexIdx.y, vertexIdx.z)
### KernelsKernels are functions visible outside of the DSL code, called by the host.Calling kernels is the only way to execute DSL code.> Note: Kernels can not be called from other kernels.> Note: Array input parameters of known sizes are not supported> Note: The types of the input parameters have to be declared.> Note: There are different ways to pass input parameters to kernels through API functions.Kernel func3(type param) {
}
Kernel func4(type[] ptr) {
}
> Note: In the example of func4 the input param `ptr` is functionally a pointer to GPU allocated memory. The correctness of the pointer is not checked by Astaroth and is responsibility of the user.### StencilsStencils are functions that take in a `Field` input parameter and have an unique syntax and semantics.**Importantly**, they are the only way to access values of a `Field` on other vertexes than at the current one.A stencil operation multiplies all points of the stencil by their corresponding coefficients and performs a binary reduction operation (`Sum` or `Max`) over these values.Because Stencils act uniformly on the input parameter it is not declared.// Format <Optional reduction operation> Stencil <identifier> { [z][y][x] = coefficient, ... }
where [z][y][x] is the x/y/z offset from the current vertex position.For exampleStencil example { [0][0][-1] = a, [0][0][0] = b, [0][0][1] = c }
Which is equivalent toSum Stencil example { ... }
And is calculated equivalently toexample(field) { return a * field[IDX(vertexIdx.x - 1, vertexIdx.y, vertexIdx.z)] + b * field[IDX(vertexIdx.x, vertexIdx.y, vertexIdx.z)] + c * field[IDX(vertexIdx.x + 1, vertexIdx.y, vertexIdx.z)] }
By default, the binary operation for reducing `Stencil` elements is `Sum` (as above). Currently supported operations are `Sum` and `Max`.// Real-world example Max Stencil largest_neighbor { [1][0][0] = 1, [-1][0][0] = 1, [0][1][0] = 1, [0][-1][0] = 1, [0][0][1] = 1, [0][0][-1] = 1 }
real3 AC_ds
//dconst variables can be used in stencil coefficients (their values are looked up from the config during loading).
Stencil derx { [0][0][-3] = -AC_ds.x*DER1_3, [0][0][-2] = -AC_ds.x*DER1_2, [0][0][-1] = -AC_ds.x*DER1_1, [0][0][1] = AC_ds.x*DER1_1, [0][0][2] = AC_ds.x*DER1_2, [0][0][3] = AC_ds.x*DER1_3 }
Stencil dery { [0][-3][0] = -AC_ds.y*DER1_3, [0][-2][0] = ... }
Stencil derz { [-3][0][0] = -AC_ds.z*DER1_3, [-2][0][0] = ... }
gradient(field) { return real3(derx(field), dery(field), derz(field)) }
> Note: Stencil coefficients supplied in the DSL source must either be compile-time constants or dconst. The coefficients can also be loaded at runtime with API calls, see [instructions below](#loading-and-storing-stencil-coefficients-at-runtime).> Note: To reduce redundant communication or to enable larger stencils, the stencil order can be changed by declaring `hostdefine STENCIL\_ORDER (YOUR VALUE)` in DSL.## Built-in variables, functions and constants// Variables int3 vertexIdx // The vertex index that is iterated over, within the subdomain of the current device int3 globalVertexIdx // The vertex index that is iterated over, within the global domain int3 globalGridN // The total size of the computational domain (incl. all subdomains of all processes) int3 threadIdx // Current thread index within a thread block (see CUDA docs) int3 blockIdx // Current thread block index (see CUDA docs)
// Built-in Functions void write(Field dst, real src) // Writes the real value 'src' to the output field 'dst' at current 'vertexIdx' elemental dot(real3, real3) // Dot product real3 cross(real3 a, real3 b) // Right-hand-side cross product a x b size_t size(arr) // Returns the length of an array arr
Accessible from stdlib/mathreal sin(real) real cos(real) real tan(real) real atan2(real) real sinh(real) real cosh(real) real tanh(real) real/complex exp(real/complex) real log(real) real sqrt(real) real pow(real) real fabs(real) real min(real,real) real max(real,real) int ceil(real) real random_uniform()
Advanced functions (should avoid, dangerous)real previous(Field) // Returns the value in the output buffer. Call after write() results in undefined behaviour.
### Built-in constantsreal AC_REAL_PI // Value of pi using the same precision as real real AC_REAL_MAX // Either DBL_MAX or FLT_MAX base on precision of real real AC_REAL_MIN // Either DBL_MIN or FLT_MIN base on precision of real real AC_REAL_EPSILON // Either DBL_EPSILON or FLT_EPSILON base on precision of real
### Built-in variables[See built-in variables here](https://toxpuro.github.io/astaroth/variables_8h.html)## Advanced featuresIf OPTIMIZE_FIELDS=ON, the DSL compiler will identify unused `Fields` and will not allocate them on the GPU.To still enable a loop across all allocated `Fields` non-allocated `Fields` are not counted in `NUM_FIELDS`and their numerical index is higher than `NUM_FIELDS`.**Important** If you use runtime-compilation this can mean that the index valueof the main application that calls Astaroth and the index value inside it might not match.To get the correct indexes, use API functions acGet< Field name >.The input arrays can also be accessed without declaring a `Stencil` as follows.**Important!!** Do not use this if you do not know what you are doing, since it has slightly different semantics and thus lead to subtle bugs and performance degradation. However, a use case where this is basically always safe, and almost required, are boundary conditions as showcased later.Field field0 Field field1
Kernel kernel() { int3 coord = ... //Writing to the input array is inherently unsafe so it really only be done inside boundary conditions field0[coord.x][coord.y][coord.y] = field1[coord.x][coord.y][coord.z] } //Since the input parameter f has explicitly been given the type of Field one can access with it the input buffer, which would not be possible without the explicit type declaration. func(Field f) { return field[vertexIdx.x][vertexIdx.y][vertexIdx.z] }
> Note: Accessing field elements this way is suboptimal compared to accessing then using a `Stencil` or calling `value` since the reads are not cached. Only access field elements this way if otherwise not possible.### Profiles`Profiles` are either one- or two-dimensional arrays of `reals` that have extents equal to the side lengths of the local subdomain, with halos included.Thus there 9 different possible types of `Profiles`:* `Profile<X>`* `Profile<Y>`* `Profile<Z>`* `Profile<XY>`* `Profile<XZ>`* `Profile<YX>`* `Profile<YZ>`* `Profile<ZX>`* `Profile<ZY>`One can get the value of a `Profile` that corresponds to the local vertex by calling `value` on it. For example the value of a `Profile<X>` would depend only on the x-coordinate of the vertex where as for a `Profile<XY>` it would depend on both the x- and y-coordinates.The same rules about inserting automatic `value` calls hold for `Profiles` as for `Fields`.### Allocating declarations`Field` and `Profile` types are special types compared to other types because they imply allocations on the global memory, for which the sizes are inferable from the types.Thus naturally aggregates, arrays and structures, that consist only of `Fields` and `Profiles` and other aggregates of them, also imply memory allocations.A perfect example is `Field3`. It is a structure that consists of three `Field` members and thus `Field3` declaration implies the same memory allocations that three separate `Field` declarations would imply. Another common example are `Field[]` variables.One can consider declarations of such aggregate varibles as syntactic sugar for recursively declaring the base `Fields` or `Profiles` and combining them together in the right structures.Field3 field_vecs[3] \This can be considered syntactic sugar for the following:
Field field_vecs0_X,field_vecs_0_Y,field_vecs_0_Z const Field3 field_vecs_0 = {field_vecs_0_X,field_vecs_0_Y,field_vecs_0_Z} Field field_vecs1_X,field_vecs_1_Y,field_vecs_1_Z const Field3 field_vecs_1 = {field_vecs_1_X,field_vecs_1_Y,field_vecs_1_Z} Field field_vecs2_X,field_vecs_2_Y,field_vecs_2_Z const Field3 field_vecs_2 = {field_vecs_2_X,field_vecs_2_Y,field_vecs_2_Z} const Field3 field_vecs = {field_vecs_0,field_vecs_1,fields_vecs_2}
> Note: Here it helps to understand that `Fields` and `Profiles` are handles to memory, not memory themselves, and thus the const assignments do not imply memory allocations, but are a simple grouping of handles.### ReductionsFor reductions the kernel has to be invoked at each vertex point of the domain.The three types of binary operations currently supported are min,max and sum.output real max_derux output real min_derux output global real global_max_derux output real sum_derux Field ux,f Profile<X> X_PROFILE Profile<XY> XY_PROFILE Kernel reduce_kernel() { reduce_max(derx(ux),max_derux) //scalar reduction; will output a different value at each process corresponding to its subdomain. //Said in a simpler manner: calculates the maximum across the subdomain reduce_min(derx(ux),min_derux) //Same as above but calculates the minimum value. reduce_max(derx(ux),global_max_derux) //scalar reduction; will produce a unique maximum across the whole grid that each process sees. //Said in a simpler manner: calculates the maximum across the whole grid. reduce_sum(derx(ux),sum_derux) //Will write the sum of derx(ux) to sum_derux reduce_sum_add(derx(ux),sum_derux) //Will write the sum of derx(ux) + value(sum_derux) to sum_derux (works only if launched on the normal subdomain size) reduce_sum(ux,X_PROFILE) //Reduction along y and z resulting in array that is x-dependent. reduce_sum(ux,XY_PROFILE) //Reduction along z resulting in array that is xy-dependent. //Both of these profile reductions are global across the whole grid. }
Kernel read_output() { write(ux,max_derux) //One can read directly the results of reductions in the DSL. The value of max_derux in this kernel would be the result of the reduction in the previous kernel. write(f,X_PROFILE) //Will read the reduced value in the X_PROFILE at index vertexIdx.x }
* The reduce functions take two parameters:* The value to reduce at this vertex* The output value to which to store the reduced valueAfter executing the kernels reductions are finalized by the taskgraph behind the scenes.One can access the reduced value on the DSL similar to other varibles as in the example above.On the host side one can access the values with the appropriate API functions.The reduced scalar values can be accessed with `acDeviceGetOutput` or for `Profiles` with the corresponding API functions.When the result of the reduction is a `Profile` finalization is automatically included in the execution of the `TaskGraph`.For a simple end-to-end test see `test/use-scalar-reduce` and `test/reduce-test`### ComputeStepsThis feature that only works if MPI is enabledThe `BoundConds` construct is used to declare how to calculate the values of `Field`s when the boundary conditions are to be imposed.BoundConds boundconds { periodic(BOUNDARY_XY) bc_sym_z(BOUNDARY_Z_TOP,FIELD_X) bc_sym_z(BOUNDARY_Z_BOT,FIELD_Y) set_y_z_bc(BOUNDARY_Z) //Calculated fields inferred from write calls inside set_y_z_bc }
It contains function calls that are used to calculate the values of the outermost halo regions.`periodic` is a unique construct to tell that the domain is periodic in the specified directions.Otherwise normal functions are called with an additional mandatory first parameter specifying the boundary.The used example boundary condition `bc_sym_z` which sets the input `Field` symmetric on the boundary could look like the following:bc_sym_z(AcBoundary boundary, Field field) { if(boundary == BOUNDARY_Z_BOT) { for i in 0:NGHOST { field[vertexIdx.x][vertexIdx.y][NGHOST-i]=field[vertexIdx.x][vertexIdx.y][NGHOST+i]; }
} else { for i in 0:NGHOST { field[vertexIdx.x][vertexIdx.y][AC_nz_max+i]=field[vertexIdx.x][vertexIdx.y][AC_nz_max-i]; } } }
For more examples of boundary conditions see `acc-runtime/stdlib/bc.h`The `ComputeSteps` construct is used to declare a sequence of (possibly dependent) kernel invocations in the DSL,from which a `TaskGraph` is produced.The kernels are analysed to infer input and output fields, when halo exchanges and evaluations of boundary conditions are needed and in case `Fields` of non-standard size are used the starting and ending indexes of the corresponding 3d loops of the kernel launches.So in other words: you specify the boundary conditions and Astaroth makes sure that they are applied as needed in order to evaluate the stencils.Dependencies between invocations are based on the needed `Fields` and reduction outputs for the kernel and the `Fields` updated and reduction outputs generated inside it.E.g. if kernel_call_1 would update `A` and kernel_call_2 would read `A`, kernel_call_2 is only called after kernel_call_1 has updated `A`.And similary if kernel_call_1 would reduce `S` and kernel_call_2 would read it, kernel_call_2 is only called after kernel_call_1 has produced `S`.input real ac_input_val ComputeSteps rhs(boundconds) { kernel_call_1(ac_input_val,2.0) kernel_call_2() ... ... ... }
`ComputeSteps` take in a parameter of `BoundConds`, from which it knows which boundary conditions to impose.In case required boundary conditions are not declared, the compilation will fail.You can access the generated `TaskGraph` with `acGetDSLTaskGraph`.To pass input values from the host side call `acDeviceSetInput`.With the example above to pass `2.0` to the first parameter of `kernel_call_1` one should call `acDeviceSetInput(device,ac_input_val,2.0)`### RaysSome computations of interest are not as parallel as applying stencils or reductions.For example integration of rays along integer directions have sequential dependencies along two-dimensional wavefronts.Take for example rays moving in the positive x-directions, to compute the update because of the moving ray at `(x,y,z)`the incoming value at `(x-1,y,z)` has to be computed and in more general for a ray moving in direction `(i,j,k)` one has tofirst compute the incoming value at `(x-i,y-j,z-k)`. When the incoming values at the boundaries of the local subdomain are set this hasthe effect that it is sufficient to have sequential dependency only in one of the cardinal directions and one thus has a slice of two-dimensional points for which the values can be computed in parallel.Rays are declared using the construct `Raytrace` and the direction in which the ray traverses.For example the following would declare rays moving in the positive x-direction and negative y-direction.Raytrace (+1,+0,+0) x_ray Raytrace (+0,-1,+0) y_ray
And the following would compute the sum of a `Field` along lines in the x-direction.Field f Kernel sum_along_x_lines() { write(f,f + incoming_x_ray(f)) }
And the following along lines in the y-direction.Field f Kernel sum_along_y_lines() { write(f,f + incoming_y_ray(f)) }
Notice an important details, these `Kernels` that have dependencies that are in different directionswere separate. Understandable rays that have dependencies in different directions have to be in separate kernels.Rays that have the same dependencies can be naturally combined. The following is the maximal example of nine rays in a single kernel.Raytrace (+1,+1,+1) ppp_ray Raytrace (+0,+1,+1) zpp_ray Raytrace (-1,+1,+1) mpp_ray
Raytrace (+1,+0,+1) pzp_ray Raytrace (+0,+0,+1) zzp_ray Raytrace (-1,+0,+1) mzp_ray
Raytrace (+1,-1,+1) pmp_ray Raytrace (+0,-1,+1) zmp_ray Raytrace (-1,-1,+1) mmp_ray Kernel nine_rays() { write(Q_PPP,incoming_ppp_ray(Q_PPP)+1.0) write(Q_ZPP,incoming_zpp_ray(Q_ZPP)+1.0) write(Q_MPP,incoming_mpp_ray(Q_MPP)+1.0)
write(Q_PZP,incoming_pzp_ray(Q_PZP)+1.0) write(Q_ZZP,incoming_zzp_ray(Q_ZZP)+1.0) write(Q_MZP,incoming_mzp_ray(Q_MZP)+1.0)
write(Q_PMP,incoming_pmp_ray(Q_PMP)+1.0) write(Q_ZMP,incoming_zmp_ray(Q_ZMP)+1.0) write(Q_MMP,incoming_mmp_ray(Q_MMP)+1.0) } Since all the rays were moving in the positive z-direction they depend on the -z vertex before them. Thus there are 9 rays depending on -z,9 depending on +z,3 on -y, 3 on +y, 1 on -x and 1 on +x. We favour grouping rays in the z and y-directions since they are more performant since dependencies in the x-direction are less performant due to x being the fastest growing index. For a more expansive test case using rays see test/ray-test.
Dimensions can be set as inactive using the bool3 variable AC_dimension_inactive or by setting the grid dimensions in the corresponding dimension to unity. The operators and derivative stencils in stdlib/general_operators.h and stdlib/general_derivs.h take the inactive dimensions correctly into account (namely derivatives across inactive dimensions are always zero). Additionally the ghost layers in the direction of inactive dimensions will not be allocated, which produces a memory saving of times 7 in 2d and and 49 in 1d for stencil of radius three.
The Astaroth Runtime API provides the functions acLoadStencil and acStoreStencil for loading/storing stencil coefficients at runtime. This is useful for, say, for setting the coefficients programmatically if too cumbersome by hand. We however highly recommend to use device constant variables in the stencil coefficients instead of separately loading stencil coefficients at runtime , since it eliminates coding errors where the actual stencil coefficients are calculated separately from the stencil declarations.
See also the functions acDeviceLoadStencil, acDeviceStoreStencil, acGridLoadStencil, and acGridStoreStencil provided by the Astaroth Core library.
To enable additional API functions in the Astaroth Core library for integration (acIntegrate function family) and MHD-specific tasks (automated testing, MHD samples), one must set hostdefine AC_INTEGRATION_ENABLED (1) in the DSL file. Note that if used in the DSL code, the hostdefine must not define anything that is not visible at compile-time. For example, hostdefine R_PI (M_PI), where M_PI is defined is some host header, M_PI will not be visible in the DSL code and will result in a compilation error. Additionally, code such as #if M_PI will be always false in the DSL source if M_PI is not visible in the DSL file.
Note: The extended API depends on several hardcoded fields and device constants. It is not recommended to enable it unless you work on the MHD sample case (acc-runtime/samples/mhd) or its derivatives.
The stencil order can be set by the user by hostdefine STENCIL_ORDER (x), where x is the total number of cells on both sides of the center point per axis. For example, a simple von Neumann stencil is of order 2.
Alternatively it can be set via CMAKE with -DAC_STENCIL_ORDER=N.
Note: The size of the halo surrounding the computational is the same as STENCIL_ORDER.