alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
traverse.hpp
Go to the documentation of this file.
1/* Copyright 2024 Andrea Bocci, René Widera
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
7#include "alpaka/Vec.hpp"
10
11namespace alpaka::onAcc
12{
13 namespace traverse
14 {
15 /** Linearize the index domain for traversing.
16 *
17 * Maps each linear index into the M-dimensional index space.
18 * Mapping the linear index to a MD-index is increasing the computations (usage of multiplications and
19 * additions) and can therefore slow down the performance.
20 */
21 struct Flat
22 {
23 ALPAKA_FN_HOST_ACC static constexpr auto make(
24 auto const& idxRange,
25 auto const& threadSpace,
26 auto const& idxLayout,
27 alpaka::concepts::CVector auto const& cSelect)
28 {
29 return FlatIdxContainer{idxRange, threadSpace, idxLayout, cSelect};
30 }
31 };
32
33 constexpr auto flat = Flat{};
34
35 /** Traversing the index domain with MD-tiles
36 *
37 * The worker specification is seen as MD-tile and iterating over the index space is done in a tiled strided
38 * way. There are no multiplication required (only additions) and therefore are less computations required
39 * compared to @see Flat.
40 */
41 struct Tiled
42 {
43 ALPAKA_FN_HOST_ACC static constexpr auto make(
44 auto const& idxRange,
45 auto const& threadSpace,
46 auto const& idxLayout,
47 alpaka::concepts::CVector auto const& cSelect)
48 {
49 return TiledIdxContainer{idxRange, threadSpace, idxLayout, cSelect};
50 }
51 };
52
53 constexpr auto tiled = Tiled{};
54 } // namespace traverse
55} // namespace alpaka::onAcc
#define ALPAKA_FN_HOST_ACC
All functions that can be used on an accelerator have to be attributed with ALPAKA_FN_ACC or ALPAKA_F...
Definition common.hpp:32
Concept to check if a type is a CVector.
Definition Vec.hpp:75
constexpr auto tiled
Definition traverse.hpp:53
constexpr auto flat
Definition traverse.hpp:33
functionality which is usable on the accelerator compute device from within a kernel.
Definition executor.hpp:38
Linearize the index domain for traversing.
Definition traverse.hpp:22
static ALPAKA_FN_HOST_ACC constexpr auto make(auto const &idxRange, auto const &threadSpace, auto const &idxLayout, alpaka::concepts::CVector auto const &cSelect)
Definition traverse.hpp:23
Traversing the index domain with MD-tiles.
Definition traverse.hpp:42
static ALPAKA_FN_HOST_ACC constexpr auto make(auto const &idxRange, auto const &threadSpace, auto const &idxLayout, alpaka::concepts::CVector auto const &cSelect)
Definition traverse.hpp:43