alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
IdxLayer.hpp
Go to the documentation of this file.
1/* Copyright 2024 René Widera
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
7#include "alpaka/Vec.hpp"
8#include "alpaka/core/Tag.hpp"
10
11#include <cassert>
12#include <tuple>
13
14namespace alpaka::onAcc
15{
16 namespace cpu
17 {
18 template<typename IndexVecType>
19 struct OneLayer
20 {
21 constexpr OneLayer() = default;
22
23 constexpr auto idx() const
24 {
25 return IndexVecType::fill(0);
26 }
27
28 constexpr auto idx() const requires alpaka::concepts::CVector<IndexVecType>
29 {
30 return IndexVecType::template fill<0>();
31 }
32
33 constexpr auto count() const
34 {
35 return IndexVecType::fill(1);
36 }
37
38 constexpr auto count() const requires alpaka::concepts::CVector<IndexVecType>
39 {
40 return IndexVecType::template fill<1u>();
41 }
42 };
43
44 template<typename T_Idx, typename T_Count>
46 {
47 constexpr GenericLayer(T_Idx idx, T_Count count) : m_idx(idx), m_count(count)
48 {
49 }
50
51 constexpr decltype(auto) idx() const
52 {
53 return unWrapp(m_idx);
54 }
55
56 constexpr decltype(auto) count() const
57 {
58 return unWrapp(m_count);
59 }
60
61 T_Idx m_idx;
62 T_Count m_count;
63 };
64 } // namespace cpu
65} // namespace alpaka::onAcc
functionality which is usable on the accelerator compute device from within a kernel.
Definition executor.hpp:38
main alpaka namespace.
Definition alpaka.hpp:76
constexpr decltype(auto) unWrapp(T &&value)
Definition util.hpp:16
constexpr decltype(auto) count() const
Definition IdxLayer.hpp:56
constexpr decltype(auto) idx() const
Definition IdxLayer.hpp:51
constexpr GenericLayer(T_Idx idx, T_Count count)
Definition IdxLayer.hpp:47
constexpr auto count() const
Definition IdxLayer.hpp:33
constexpr OneLayer()=default
constexpr auto idx() const
Definition IdxLayer.hpp:23
constexpr auto idx() const
Definition IdxLayer.hpp:28
constexpr auto count() const
Definition IdxLayer.hpp:38