File rajalib.hxx#

Defines

RAJALIB_H#

RAJA library utilities and wrappers

Defines:

  • RajaForAll A class which handles Region indices, and wraps RAJA::forall

  • BOUT_FOR_RAJA A macro which uses RajaForAll when BOUT_HAS_RAJA Falls back to BOUT_FOR when RAJA not enabled

Notes:

  • DISABLE_RAJA can be defined to 1 before including this header, to locally disable RAJA for testing.

SHADOW_ARG(var)#

Create a variable which shadows another (has the same name)

CAPTURE(...)#

Transform a list of variables into a list of var=var assignments Useful for capturing class members in lambda function arguments.

BOUT_FOR_RAJA(index, region, ...)#

Functions

because it s a lambda function **Extra arguments can be passed after the and will be added *to the lambda capture The intended use for this is to capture *class member variables which can t be used directly in a RAJA CUDA *loop CAPTURE (var1, var2))

Variables

**where f is a Field **For multiple loops

Wrapper around RAJA::forall Enables computations to be done on CPU or GPU (CUDA).

Must be constructed with a Region. When passed a lambda function via the << operator, the lambda function will be called with the Region indices (index.ind).

Usage:

RajaForAll(f.getRegion(“RGN_NOBNDRY”)) << [=](int id) { /* …

**where f is a Field **For multiple the RajaForAll object can be created once
**and then passed lambda functions multiple times
*** Note

Iterate an index over a region

If BOUT_HAS_RAJA is true and DISABLE_RAJA is false, then this macro uses RAJA (via RajaForAll) to perform the iteration.

Usage:

BOUT_FOR_RAJA(i, f.region(“RGN_NOBNDRY”)) { /* …

because it s a lambda function **Extra arguments can be passed after the region
because it s a lambda function **Extra arguments can be passed after the and will be added *to the lambda capture The intended use for this is to capture *class member variables which can t be used directly in a RAJA CUDA *loop ** Usage
struct RajaForAll#

Public Functions

RajaForAll() = delete#

Need a Region to construct.

template<typename IndType>
inline RajaForAll(const Region<IndType> &region)#

Construct by specifying a Region to iterate over. Converts the range into a form which can be used in a RAJA loop.

Template Parameters:

IndType – Ind2D or Ind3D. The lambda function will be called with 1D (flattened) indices of this type.

Parameters:

region – The region to iterate over

template<typename F>
inline const RajaForAll &operator<<(F f) const#

Pass a lambda function to RAJA::forall Iterates over the range passed to the constructor

Returns a reference to this, so that << can be chained.

Template Parameters:

F – The function type. Expected to take an int input e.g. Lambda(int) -> void

Parameters:

f – Lambda function to call each iteration

Private Members

Array<int> _ob_i_ind#

Holds the index array.