alpaka
Abstraction Library for Parallel Kernel Acceleration
Traits.hpp
Go to the documentation of this file.
1 /* Copyright 2022 Benjamin Worpitz, Bernhard Manfred Gruber
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 device properties get trait.
40  template<typename TAcc, typename TSfinae = void>
42 
43  //! The accelerator name trait.
44  //!
45  //! The default implementation returns the mangled class name.
46  template<typename TAcc, typename TSfinae = void>
47  struct GetAccName
48  {
49  ALPAKA_FN_HOST static auto getAccName() -> std::string
50  {
51  return core::demangled<TAcc>;
52  }
53  };
54  } // namespace trait
55 
56  //! The accelerator type trait alias template to remove the ::type.
57  template<typename T>
58  using Acc = typename trait::AccType<T>::type;
59 
60  //! \return The acceleration properties on the given device.
61  template<typename TAcc, typename TDev>
63  {
66  }
67 
68  //! \return The accelerator name
69  //!
70  //! \tparam TAcc The accelerator type.
71  template<typename TAcc>
72  ALPAKA_FN_HOST auto getAccName() -> std::string
73  {
75  }
76 
77  namespace trait
78  {
79  template<typename TAcc, typename TProperty>
80  struct QueueType<TAcc, TProperty, std::enable_if_t<concepts::ImplementsConcept<ConceptAcc, TAcc>::value>>
81  {
83  };
84  } // namespace trait
85 } // namespace alpaka
#define ALPAKA_FN_HOST
Definition: Common.hpp:40
typename detail::ImplementationBaseType< TConcept, TDerived >::type ImplementationBase
Returns the type that implements the given concept in the inheritance hierarchy.
Definition: Concepts.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:62
ALPAKA_FN_HOST auto getAccName() -> std::string
Definition: Traits.hpp:72
typename trait::AccType< T >::type Acc
The accelerator type trait alias template to remove the ::type.
Definition: Traits.hpp:58
The acceleration properties on a device.
Definition: AccDevProps.hpp:18
Checks whether the concept is implemented by the given class.
Definition: Concepts.hpp:21
The accelerator type trait.
Definition: Traits.hpp:37
The device properties get trait.
Definition: Traits.hpp:41
The accelerator name trait.
Definition: Traits.hpp:48
static ALPAKA_FN_HOST auto getAccName() -> std::string
Definition: Traits.hpp:49
typename QueueType< typename alpaka::trait::PlatformType< TAcc >::type, TProperty >::type type
Definition: Traits.hpp:82
Queue for an accelerator.
Definition: Traits.hpp:35