|
RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
|
A holder for adapting lambdas meant for multidimensional index spaces to allow their use in 1-dimensional index spaces. More...
#include <CombiningAdapter.hpp>
Public Types | |
| using | Layout = Layout_ |
| using | IndexRange = typename Layout::IndexRange |
| using | StrippedIdxLin = typename Layout::StrippedIdxLin |
| using | IndexLinear = typename Layout::IndexLinear |
| using | DimTuple = typename Layout::DimTuple |
| using | DimArr = typename Layout::DimArr |
| using | RangeLinear = RAJA::TypedRangeSegment< IndexLinear > |
Public Member Functions | |
| template<typename C_Lambda , typename C_Layout > | |
| RAJA_HOST_DEVICE | CombiningAdapter (C_Lambda &&lambda, C_Layout &&layout) |
| RAJA_HOST_DEVICE RAJA_INLINE auto | operator() (IndexLinear linear_index) -> decltype(call_helper(linear_index, IndexRange())) |
| RAJA_HOST_DEVICE RAJA_INLINE auto | operator() (IndexLinear linear_index) const -> decltype(call_helper(linear_index, IndexRange())) |
| RAJA_HOST_DEVICE RAJA_INLINE IndexLinear | size () const |
| RAJA_HOST_DEVICE RAJA_INLINE RangeLinear | getRange () const |
A holder for adapting lambdas meant for multidimensional index spaces to allow their use in 1-dimensional index spaces.
Creates callable object that when called with a 1-dimensional index, converts that index to a multi-dimensional index and calls the given lambda. This allows lambdas meant for use in multi-dimensional loop abstractions to be used in 1-dimensional loop abstractions. The 1-dimensional index is of the type of the IndexType template parameter.
For example:
// lambda for use in 3-d loop
auto lambda = [=](int i, int j, int k) {...};
// 3D loop bounds
int isize;
int jsize;
int ksize;
// example lambda usage
for (int i = 0; i < isize; ++i) {
for (int j = 0; j < jsize; ++j) {
for (int k = 0; k < ksize; ++k) {
lambda(i, j, k);
}
}
}
using Layout = Layout<3, int, // 3 dimensions, index type is int
2>; // optimization, stride 1 dim is 2
// Create a CombiningAdapter object for lambda and the ranges
// NOTE Use make_CombiningAdapter
RAJA::CombiningAdapter<decltype(lambda), Layout>
adapter(lambda, Layout(isize, jsize, ksize));
// Use with RAJA forall
RAJA::forall<policy>(adapter.getRange(), adapter);
// Use with c++-style loop
auto range = adapter.getRange();
for (auto it = begin(range); it < end(range); ++it) {
adapter(*it)
}
| using RAJA::CombiningAdapter< Lambda, Layout_ >::Layout = Layout_ |
| using RAJA::CombiningAdapter< Lambda, Layout_ >::IndexRange = typename Layout::IndexRange |
| using RAJA::CombiningAdapter< Lambda, Layout_ >::StrippedIdxLin = typename Layout::StrippedIdxLin |
| using RAJA::CombiningAdapter< Lambda, Layout_ >::IndexLinear = typename Layout::IndexLinear |
| using RAJA::CombiningAdapter< Lambda, Layout_ >::DimTuple = typename Layout::DimTuple |
| using RAJA::CombiningAdapter< Lambda, Layout_ >::DimArr = typename Layout::DimArr |
| using RAJA::CombiningAdapter< Lambda, Layout_ >::RangeLinear = RAJA::TypedRangeSegment<IndexLinear> |
|
inline |
Constructor from lambda and layout.
|
inline |
Call the lambda by converting the linear index to multidimensional indices.
|
inline |
|
inline |
Computes the total size of the layout's space.
|
inline |
Convenience method to get a 1-dimensional range representing the total size of the layout.