alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
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
11
12#include <type_traits>
13#include <vector>
14
15namespace alpaka
16{
18 {
19 };
20
21 namespace concepts
22 {
23 template<typename TPlatform>
24 concept Platform
25 = requires { requires interface::ImplementsInterface<ConceptPlatform, std::decay_t<TPlatform>>::value; };
26 } // namespace concepts
27
28 //! True if TPlatform is a platform, i.e. if it implements the ConceptPlatform concept.
29 template<typename TPlatform>
30 [[deprecated("use the alpaka::concepts::Platform instead.")]] inline constexpr bool isPlatform
32
33 //! The platform traits.
34 namespace trait
35 {
36 //! The platform type trait.
37 template<typename T, typename TSfinae = void>
39
40 template<typename TPlatform>
42 TPlatform,
43 std::enable_if_t<interface::ImplementsInterface<ConceptPlatform, TPlatform>::value>>
44 {
46 };
47
48 //! The device count get trait.
49 template<typename T, typename TSfinae = void>
51
52 //! The device get trait.
53 template<typename T, typename TSfinae = void>
55 } // namespace trait
56
57 //! The platform type trait alias template to remove the ::type.
58 template<typename T>
60
61 //! \return The device identified by its index.
62 template<typename TPlatform>
63 ALPAKA_FN_HOST auto getDevCount(TPlatform const& platform)
64 {
66 }
67
68 //! \return The device identified by its index.
69 template<typename TPlatform>
70 ALPAKA_FN_HOST auto getDevByIdx(TPlatform const& platform, std::size_t const& devIdx) -> Dev<TPlatform>
71 {
72 return trait::GetDevByIdx<TPlatform>::getDevByIdx(platform, devIdx);
73 }
74
75 //! \return All the devices available on this accelerator.
76 template<typename TPlatform>
77 ALPAKA_FN_HOST auto getDevs(TPlatform const& platform) -> std::vector<Dev<TPlatform>>
78 {
79 std::vector<Dev<TPlatform>> devs;
80
81 std::size_t const devCount = getDevCount(platform);
82 devs.reserve(devCount);
83 for(std::size_t devIdx(0); devIdx < devCount; ++devIdx)
84 {
85 devs.push_back(getDevByIdx(platform, devIdx));
86 }
87
88 return devs;
89 }
90
91 namespace trait
92 {
93 template<typename TPlatform, typename TProperty>
94 struct QueueType<
95 TPlatform,
96 TProperty,
97 std::enable_if_t<interface::ImplementsInterface<ConceptPlatform, TPlatform>::value>>
98 {
100 };
101 } // namespace trait
102} // namespace alpaka
#define ALPAKA_FN_HOST
Definition Common.hpp:43
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.
ALPAKA_FN_HOST auto getDevCount(TPlatform const &platform)
Definition Traits.hpp:63
constexpr bool isPlatform
True if TPlatform is a platform, i.e. if it implements the ConceptPlatform concept.
Definition Traits.hpp:31
typename trait::DevType< T >::type Dev
The device type trait alias template to remove the ::type.
Definition Traits.hpp:56
ALPAKA_FN_HOST auto getDevByIdx(TPlatform const &platform, std::size_t const &devIdx) -> Dev< TPlatform >
Definition Traits.hpp:70
typename trait::PlatformType< T >::type Platform
The platform type trait alias template to remove the ::type.
Definition Traits.hpp:59
ALPAKA_FN_HOST auto getDevs(TPlatform const &platform) -> std::vector< Dev< TPlatform > >
Definition Traits.hpp:77
STL namespace.
The device get trait.
Definition Traits.hpp:54
The device count get trait.
Definition Traits.hpp:50
The platform type trait.
Definition Traits.hpp:38
typename QueueType< typename alpaka::trait::DevType< TPlatform >::type, TProperty >::type type
Definition Traits.hpp:99
Queue for an accelerator.
Definition Traits.hpp:42