alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
WarpSingleThread.hpp
Go to the documentation of this file.
1/* Copyright 2026 Sergei Bastrakov, David M. Rogers, Bernhard Manfred Gruber, Aurora Perego, Simone Balducci
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
8
9#include <cstdint>
10
11namespace alpaka::warp
12{
13 //! The single-threaded warp to emulate it on CPUs.
14 struct WarpSingleThread : public interface::Implements<ConceptWarp, WarpSingleThread>
15 {
16 using mask_type = std::uint32_t;
17 };
18
19 namespace trait
20 {
21
22 template<>
24 {
25 static auto getSize(warp::WarpSingleThread const& /*warp*/) -> std::int32_t
26 {
27 return 1;
28 }
29 };
30
31 template<>
33 {
34 static constexpr auto getSizeCompileTime() -> std::int32_t
35 {
36 return 1;
37 }
38 };
39
40 template<>
42 {
43 static constexpr auto getSizeUpperLimit() -> std::int32_t
44 {
45 return 1;
46 }
47 };
48
49 template<>
51 {
53 {
54 return 1u;
55 }
56 };
57
58 template<>
60 {
61 static auto all(warp::WarpSingleThread const& /*warp*/, std::int32_t predicate)
62 {
63 return predicate;
64 }
65 };
66
67 template<>
69 {
70 static auto any(warp::WarpSingleThread const& /*warp*/, std::int32_t predicate)
71 {
72 return predicate;
73 }
74 };
75
76 template<>
78 {
79 static auto ballot(warp::WarpSingleThread const& /*warp*/, std::int32_t predicate)
81 {
82 return predicate ? 1u : 0u;
83 }
84 };
85
86 template<>
88 {
89 template<typename T>
90 static auto shfl(
91 warp::WarpSingleThread const& /*warp*/,
92 T val,
93 std::int32_t /*srcLane*/,
94 std::int32_t /*width*/)
95 {
96 return val;
97 }
98 };
99
100 template<>
102 {
103 template<typename T>
104 static auto shfl_up(
105 warp::WarpSingleThread const& /*warp*/,
106 T val,
107 std::uint32_t /*srcLane*/,
108 std::int32_t /*width*/)
109 {
110 return val;
111 }
112 };
113
114 template<>
116 {
117 template<typename T>
118 static auto shfl_down(
119 warp::WarpSingleThread const& /*warp*/,
120 T val,
121 std::uint32_t /*srcLane*/,
122 std::int32_t /*width*/)
123 {
124 return val;
125 }
126 };
127
128 template<>
130 {
131 template<typename T>
132 static auto shfl_xor(
133 warp::WarpSingleThread const& /*warp*/,
134 T val,
135 std::int32_t /*srcLane*/,
136 std::int32_t /*width*/)
137 {
138 return val;
139 }
140 };
141 } // namespace trait
142} // namespace alpaka::warp
Tag used in class inheritance hierarchies that describes that a specific interface (TInterface) is im...
Definition Interface.hpp:15
The single-threaded warp to emulate it on CPUs.
static auto activemask(warp::WarpSingleThread const &) -> WarpSingleThread::mask_type
The active mask trait.
Definition Traits.hpp:64
static auto all(warp::WarpSingleThread const &, std::int32_t predicate)
The all warp vote trait.
Definition Traits.hpp:36
static auto any(warp::WarpSingleThread const &, std::int32_t predicate)
The any warp vote trait.
Definition Traits.hpp:40
static auto ballot(warp::WarpSingleThread const &, std::int32_t predicate) -> WarpSingleThread::mask_type
The ballot warp vote trait.
Definition Traits.hpp:44
static constexpr auto getSizeCompileTime() -> std::int32_t
The compile-time warp size trait.
Definition Traits.hpp:28
static constexpr auto getSizeUpperLimit() -> std::int32_t
The warp size upper-limit trait.
Definition Traits.hpp:32
static auto getSize(warp::WarpSingleThread const &) -> std::int32_t
The warp size trait.
Definition Traits.hpp:24
static auto shfl_down(warp::WarpSingleThread const &, T val, std::uint32_t, std::int32_t)
The shfl down warp swizzling trait.
Definition Traits.hpp:56
static auto shfl_up(warp::WarpSingleThread const &, T val, std::uint32_t, std::int32_t)
The shfl up warp swizzling trait.
Definition Traits.hpp:52
static auto shfl_xor(warp::WarpSingleThread const &, T val, std::int32_t, std::int32_t)
The shfl xor warp swizzling trait.
Definition Traits.hpp:60
static auto shfl(warp::WarpSingleThread const &, T val, std::int32_t, std::int32_t)
The shfl warp swizzling trait.
Definition Traits.hpp:48