alpaka
Abstraction Library for Parallel Kernel Acceleration
Traits.hpp
Go to the documentation of this file.
1 /* Copyright 2024 Benjamin Worpitz, Bernhard Manfred Gruber, Andrea Bocci
2  * SPDX-License-Identifier: MPL-2.0
3  */
4 
5 #pragma once
6 
8 #include "alpaka/core/Common.hpp"
11 #include "alpaka/dev/Traits.hpp"
12 #include "alpaka/dim/Traits.hpp"
13 #include "alpaka/idx/Traits.hpp"
14 #include "alpaka/kernel/Traits.hpp"
16 #include "alpaka/queue/Traits.hpp"
17 
18 #include <string>
19 #include <type_traits>
20 #include <typeinfo>
21 
22 namespace alpaka
23 {
24  struct ConceptAcc
25  {
26  };
27 
28  //! True if TAcc is an accelerator, i.e. if it implements the ConceptAcc concept.
29  template<typename TAcc>
31 
32  //! The accelerator traits.
33  namespace trait
34  {
35  //! The accelerator type trait.
36  template<typename T, typename TSfinae = void>
37  struct AccType;
38 
39  //! The single thread accelerator trait.
40  //!
41  //! If TAcc is an accelerator that supports only a single thread per block, inherit from std::true_type.
42  //! If TAcc is not an accelerator, or an accelerator that supports multiple threads per block, inherit from
43  //! std::false_type.
44  template<typename TAcc, typename TSfinae = void>
45  struct IsSingleThreadAcc : std::false_type
46  {
47  };
48 
49  //! The multi thread accelerator trait.
50  //!
51  //! If TAcc is an accelerator that supports multiple threads per block, inherit from std::true_type.
52  //! If TAcc is not an accelerator, or an accelerator that supports only a single thread per block, inherit from
53  //! std::false_type.
54  template<typename TAcc, typename TSfinae = void>
55  struct IsMultiThreadAcc : std::false_type
56  {
57  };
58 
59  //! The device properties get trait.
60  template<typename TAcc, typename TSfinae = void>
62 
63  //! The accelerator name trait.
64  //!
65  //! The default implementation returns the mangled class name.
66  template<typename TAcc, typename TSfinae = void>
67  struct GetAccName
68  {
69  ALPAKA_FN_HOST static auto getAccName() -> std::string
70  {
71  return core::demangled<TAcc>;
72  }
73  };
74  } // namespace trait
75 
76  //! The accelerator type trait alias template to remove the ::type.
77  template<typename T>
78  using Acc = typename trait::AccType<T>::type;
79 
80  //! True if TAcc is an accelerator that supports only a single thread per block, false otherwise.
81  template<typename TAcc>
83 
84  //! True if TAcc is an accelerator that supports multiple threads per block, false otherwise.
85  template<typename TAcc>
87 
88  //! \return The acceleration properties on the given device.
89  template<typename TAcc, typename TDev>
91  {
94  }
95 
96  //! \return The accelerator name
97  //!
98  //! \tparam TAcc The accelerator type.
99  template<typename TAcc>
100  ALPAKA_FN_HOST auto getAccName() -> std::string
101  {
103  }
104 
105  namespace trait
106  {
107  template<typename TAcc, typename TProperty>
108  struct QueueType<TAcc, TProperty, std::enable_if_t<interface::ImplementsInterface<ConceptAcc, TAcc>::value>>
109  {
111  };
112 
113  } // namespace trait
114 
115 } // namespace alpaka
#define ALPAKA_FN_HOST
Definition: Common.hpp:40
typename detail::ImplementationBaseType< TInterface, TDerived >::type ImplementationBase
Returns the type that implements the given interface in the inheritance hierarchy.
Definition: Interface.hpp:66
The alpaka accelerator library.
typename trait::IdxType< T >::type Idx
Definition: Traits.hpp:29
constexpr bool isAccelerator
True if TAcc is an accelerator, i.e. if it implements the ConceptAcc concept.
Definition: Traits.hpp:30
ALPAKA_FN_HOST auto getAccDevProps(TDev const &dev) -> AccDevProps< Dim< TAcc >, Idx< TAcc >>
Definition: Traits.hpp:90
constexpr bool isSingleThreadAcc
True if TAcc is an accelerator that supports only a single thread per block, false otherwise.
Definition: Traits.hpp:82
constexpr bool isMultiThreadAcc
True if TAcc is an accelerator that supports multiple threads per block, false otherwise.
Definition: Traits.hpp:86
ALPAKA_FN_HOST auto getAccName() -> std::string
Definition: Traits.hpp:100
typename trait::AccType< T >::type Acc
The accelerator type trait alias template to remove the ::type.
Definition: Traits.hpp:78
The acceleration properties on a device.
Definition: AccDevProps.hpp:18
Checks whether the interface is implemented by the given class.
Definition: Interface.hpp:21
The accelerator type trait.
Definition: Traits.hpp:37
The device properties get trait.
Definition: Traits.hpp:61
The accelerator name trait.
Definition: Traits.hpp:68
static ALPAKA_FN_HOST auto getAccName() -> std::string
Definition: Traits.hpp:69
The multi thread accelerator trait.
Definition: Traits.hpp:56
The single thread accelerator trait.
Definition: Traits.hpp:46
typename QueueType< typename alpaka::trait::PlatformType< TAcc >::type, TProperty >::type type
Definition: Traits.hpp:110
Queue for an accelerator.
Definition: Traits.hpp:35