alpaka
Abstraction Library for Parallel Kernel Acceleration
Queue.hpp
Go to the documentation of this file.
1 /* Copyright 2024 Benjamin Worpitz, Matthias Werner, RenĂ© Widera, Bernhard Manfred Gruber, Jan Stephan, Andrea Bocci,
2  * Aurora Perego
3  * SPDX-License-Identifier: MPL-2.0
4  */
5 
6 #pragma once
7 
8 #include "alpaka/alpaka.hpp"
9 
10 namespace alpaka::test
11 {
12  namespace trait
13  {
14  //! The default queue type trait for devices.
15  template<typename TDev, typename TSfinae = void>
17 
18  //! The default queue type trait specialization for the CPU device.
19  template<>
21  {
22 #if(ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL)
24 #else
25  using type = QueueCpuNonBlocking;
26 #endif
27  };
28 
29 #if defined(ALPAKA_ACC_GPU_CUDA_ENABLED) || defined(ALPAKA_ACC_GPU_HIP_ENABLED)
30 
31  //! The default queue type trait specialization for the CUDA/HIP device.
32  template<typename TApi>
34  {
35 # if(ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL)
37 # else
39 # endif
40  };
41 #endif
42 
43 #ifdef ALPAKA_ACC_SYCL_ENABLED
44  //! The default queue type trait specialization for the SYCL device.
45  template<concepts::Tag TTag>
46  struct DefaultQueueType<DevGenericSycl<TTag>>
47  {
48 # if(ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL)
49  using type = QueueGenericSyclBlocking<TTag>;
50 # else
51  using type = QueueGenericSyclNonBlocking<TTag>;
52 # endif
53  };
54 #endif
55 
56  //! The blocking queue trait.
57  template<typename TQueue, typename TSfinae = void>
59 
60  //! The blocking queue trait specialization for a blocking CPU queue.
61  template<typename TDev>
63  {
64  static constexpr bool value = true;
65  };
66 
67  //! The blocking queue trait specialization for a non-blocking CPU queue.
68  template<typename TDev>
70  {
71  static constexpr bool value = false;
72  };
73 
74 #if defined(ALPAKA_ACC_GPU_CUDA_ENABLED) || defined(ALPAKA_ACC_GPU_HIP_ENABLED)
75 
76  //! The blocking queue trait specialization for a blocking CUDA/HIP RT queue.
77  template<typename TApi>
79  {
80  static constexpr bool value = true;
81  };
82 
83  //! The blocking queue trait specialization for a non-blocking CUDA/HIP RT queue.
84  template<typename TApi>
86  {
87  static constexpr bool value = false;
88  };
89 #endif
90 
91 #ifdef ALPAKA_ACC_SYCL_ENABLED
92  template<concepts::Tag TTag>
93  struct IsBlockingQueue<QueueGenericSyclBlocking<TTag>>
94  {
95  static constexpr auto value = true;
96  };
97 
98  template<concepts::Tag TTag>
99  struct IsBlockingQueue<QueueGenericSyclNonBlocking<TTag>>
100  {
101  static constexpr auto value = false;
102  };
103 #endif
104  } // namespace trait
105 
106  //! The queue type that should be used for the given device.
107  template<typename TDev>
109 
110  //! The queue type that should be used for the given accelerator.
111  template<typename TQueue>
113 
114  //! A std::tuple holding tuples of devices and corresponding queue types.
115  using TestQueues = std::tuple<
116  std::tuple<DevCpu, QueueCpuBlocking>,
117  std::tuple<DevCpu, QueueCpuNonBlocking>
118 #ifdef ALPAKA_ACC_GPU_CUDA_ENABLED
119  ,
120  std::tuple<DevCudaRt, QueueCudaRtBlocking>,
121  std::tuple<DevCudaRt, QueueCudaRtNonBlocking>
122 #endif
123 #ifdef ALPAKA_ACC_GPU_HIP_ENABLED
124  ,
125  std::tuple<DevHipRt, QueueHipRtBlocking>,
126  std::tuple<DevHipRt, QueueHipRtNonBlocking>
127 #endif
128 #ifdef ALPAKA_ACC_SYCL_ENABLED
129 # ifdef ALPAKA_SYCL_ONEAPI_CPU
130  ,
131  std::tuple<alpaka::DevCpuSycl, alpaka::QueueCpuSyclBlocking>,
132  std::tuple<alpaka::DevCpuSycl, alpaka::QueueCpuSyclNonBlocking>
133 # endif
134 # ifdef ALPAKA_SYCL_ONEAPI_FPGA
135  ,
136  std::tuple<alpaka::DevFpgaSyclIntel, alpaka::QueueFpgaSyclIntelBlocking>,
137  std::tuple<alpaka::DevFpgaSyclIntel, alpaka::QueueFpgaSyclIntelNonBlocking>
138 # endif
139 # ifdef ALPAKA_SYCL_ONEAPI_GPU
140  ,
141  std::tuple<alpaka::DevGpuSyclIntel, alpaka::QueueGpuSyclIntelBlocking>,
142  std::tuple<alpaka::DevGpuSyclIntel, alpaka::QueueGpuSyclIntelNonBlocking>
143 # endif
144 #endif
145  >;
146 } // namespace alpaka::test
The CPU device handle.
Definition: DevCpu.hpp:56
The CUDA/HIP RT device handle.
The test specifics.
Definition: TestAccs.hpp:27
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:145
typename trait::DefaultQueueType< TDev >::type DefaultQueue
The queue type that should be used for the given device.
Definition: Queue.hpp:108
QueueGenericThreadsBlocking< DevCpu > QueueCpuBlocking
Definition: DevCpu.hpp:191
QueueGenericThreadsNonBlocking< DevCpu > QueueCpuNonBlocking
Definition: DevCpu.hpp:190
The default queue type trait for devices.
Definition: Queue.hpp:16
The blocking queue trait.
Definition: Queue.hpp:58