alpaka
Abstraction Library for Parallel Kernel Acceleration
Queue.hpp
Go to the documentation of this file.
1 /* Copyright 2023 Benjamin Worpitz, Matthias Werner, RenĂ© Widera, Bernhard Manfred Gruber, Jan Stephan, Andrea Bocci
2  * SPDX-License-Identifier: MPL-2.0
3  */
4 
5 #pragma once
6 
7 #include "alpaka/alpaka.hpp"
8 
9 namespace alpaka::test
10 {
11  namespace trait
12  {
13  //! The default queue type trait for devices.
14  template<typename TDev, typename TSfinae = void>
16 
17  //! The default queue type trait specialization for the CPU device.
18  template<>
20  {
21 #if(ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL)
23 #else
24  using type = QueueCpuNonBlocking;
25 #endif
26  };
27 
28 #if defined(ALPAKA_ACC_GPU_CUDA_ENABLED) || defined(ALPAKA_ACC_GPU_HIP_ENABLED)
29 
30  //! The default queue type trait specialization for the CUDA/HIP device.
31  template<typename TApi>
33  {
34 # if(ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL)
36 # else
38 # endif
39  };
40 #endif
41  } // namespace trait
42 
43  //! The queue type that should be used for the given device.
44  template<typename TDev>
46 
47  namespace trait
48  {
49  //! The blocking queue trait.
50  template<typename TQueue, typename TSfinae = void>
52 
53  //! The blocking queue trait specialization for a blocking CPU queue.
54  template<typename TDev>
56  {
57  static constexpr bool value = true;
58  };
59 
60  //! The blocking queue trait specialization for a non-blocking CPU queue.
61  template<typename TDev>
63  {
64  static constexpr bool value = false;
65  };
66 
67 #if defined(ALPAKA_ACC_GPU_CUDA_ENABLED) || defined(ALPAKA_ACC_GPU_HIP_ENABLED)
68 
69  //! The blocking queue trait specialization for a blocking CUDA/HIP RT queue.
70  template<typename TApi>
72  {
73  static constexpr bool value = true;
74  };
75 
76  //! The blocking queue trait specialization for a non-blocking CUDA/HIP RT queue.
77  template<typename TApi>
79  {
80  static constexpr bool value = false;
81  };
82 #endif
83 
84 #ifdef ALPAKA_ACC_SYCL_ENABLED
85 # ifdef ALPAKA_SYCL_ONEAPI_CPU
86  //! The default queue type trait specialization for the Intel CPU device.
87  template<>
88  struct DefaultQueueType<alpaka::DevCpuSycl>
89  {
90 # if(ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL)
91  using type = alpaka::QueueCpuSyclBlocking;
92 # else
93  using type = alpaka::QueueCpuSyclNonBlocking;
94 # endif
95  };
96 
97  template<>
98  struct IsBlockingQueue<alpaka::QueueCpuSyclBlocking>
99  {
100  static constexpr auto value = true;
101  };
102 
103  template<>
104  struct IsBlockingQueue<alpaka::QueueCpuSyclNonBlocking>
105  {
106  static constexpr auto value = false;
107  };
108 # endif
109 # ifdef ALPAKA_SYCL_ONEAPI_FPGA
110  //! The default queue type trait specialization for the Intel SYCL device.
111  template<>
112  struct DefaultQueueType<alpaka::DevFpgaSyclIntel>
113  {
114 # if(ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL)
115  using type = alpaka::QueueFpgaSyclIntelBlocking;
116 # else
117  using type = alpaka::QueueFpgaSyclIntelNonBlocking;
118 # endif
119  };
120 
121  template<>
122  struct IsBlockingQueue<alpaka::QueueFpgaSyclIntelBlocking>
123  {
124  static constexpr auto value = true;
125  };
126 
127  template<>
128  struct IsBlockingQueue<alpaka::QueueFpgaSyclIntelNonBlocking>
129  {
130  static constexpr auto value = false;
131  };
132 # endif
133 # ifdef ALPAKA_SYCL_ONEAPI_GPU
134  //! The default queue type trait specialization for the Intel CPU device.
135  template<>
136  struct DefaultQueueType<alpaka::DevGpuSyclIntel>
137  {
138 # if(ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL)
139  using type = alpaka::QueueGpuSyclIntelBlocking;
140 # else
141  using type = alpaka::QueueGpuSyclIntelNonBlocking;
142 # endif
143  };
144 
145  template<>
146  struct IsBlockingQueue<alpaka::QueueGpuSyclIntelBlocking>
147  {
148  static constexpr auto value = true;
149  };
150 
151  template<>
152  struct IsBlockingQueue<alpaka::QueueGpuSyclIntelNonBlocking>
153  {
154  static constexpr auto value = false;
155  };
156 # endif
157 #endif
158  } // namespace trait
159 
160  //! The queue type that should be used for the given accelerator.
161  template<typename TQueue>
163 
164  //! A std::tuple holding tuples of devices and corresponding queue types.
165  using TestQueues = std::tuple<
166  std::tuple<DevCpu, QueueCpuBlocking>,
167  std::tuple<DevCpu, QueueCpuNonBlocking>
168 #ifdef ALPAKA_ACC_GPU_CUDA_ENABLED
169  ,
170  std::tuple<DevCudaRt, QueueCudaRtBlocking>,
171  std::tuple<DevCudaRt, QueueCudaRtNonBlocking>
172 #endif
173 #ifdef ALPAKA_ACC_GPU_HIP_ENABLED
174  ,
175  std::tuple<DevHipRt, QueueHipRtBlocking>,
176  std::tuple<DevHipRt, QueueHipRtNonBlocking>
177 #endif
178 #ifdef ALPAKA_ACC_SYCL_ENABLED
179 # ifdef ALPAKA_SYCL_ONEAPI_CPU
180  ,
181  std::tuple<alpaka::DevCpuSycl, alpaka::QueueCpuSyclBlocking>,
182  std::tuple<alpaka::DevCpuSycl, alpaka::QueueCpuSyclNonBlocking>
183 # endif
184 # ifdef ALPAKA_SYCL_ONEAPI_FPGA
185  ,
186  std::tuple<alpaka::DevFpgaSyclIntel, alpaka::QueueFpgaSyclIntelBlocking>,
187  std::tuple<alpaka::DevFpgaSyclIntel, alpaka::QueueFpgaSyclIntelNonBlocking>
188 # endif
189 # ifdef ALPAKA_SYCL_ONEAPI_GPU
190  ,
191  std::tuple<alpaka::DevGpuSyclIntel, alpaka::QueueGpuSyclIntelBlocking>,
192  std::tuple<alpaka::DevGpuSyclIntel, alpaka::QueueGpuSyclIntelNonBlocking>
193 # endif
194 #endif
195  >;
196 } // namespace alpaka::test
The CPU device handle.
Definition: DevCpu.hpp:56
The CUDA/HIP RT device handle.
The test specifics.
Definition: TestAccs.hpp:26
trait::IsBlockingQueue< TQueue > IsBlockingQueue
The queue type that should be used for the given accelerator.
Definition: Queue.hpp:162
std::tuple< std::tuple< DevCpu, QueueCpuBlocking >, std::tuple< DevCpu, QueueCpuNonBlocking >, std::tuple< DevCudaRt, QueueCudaRtBlocking >, std::tuple< DevCudaRt, QueueCudaRtNonBlocking > > TestQueues
A std::tuple holding tuples of devices and corresponding queue types.
Definition: Queue.hpp:195
typename trait::DefaultQueueType< TDev >::type DefaultQueue
The queue type that should be used for the given device.
Definition: Queue.hpp:45
The alpaka accelerator library.
QueueGenericThreadsBlocking< DevCpu > QueueCpuBlocking
Definition: DevCpu.hpp:191
QueueGenericThreadsNonBlocking< DevCpu > QueueCpuNonBlocking
Definition: DevCpu.hpp:190
The default queue type trait for devices.
Definition: Queue.hpp:15
The blocking queue trait.
Definition: Queue.hpp:51