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 //! True if TPlatform is a platform, i.e. if it implements the ConceptPlatform concept.
22 template<typename TPlatform>
24
25 //! The platform traits.
26 namespace trait
27 {
28 //! The platform type trait.
29 template<typename T, typename TSfinae = void>
31
32 template<typename TPlatform>
34 TPlatform,
35 std::enable_if_t<interface::ImplementsInterface<ConceptPlatform, TPlatform>::value>>
36 {
38 };
39
40 //! The device count get trait.
41 template<typename T, typename TSfinae = void>
43
44 //! The device get trait.
45 template<typename T, typename TSfinae = void>
46 struct GetDevByIdx;
47 } // namespace trait
48
49 //! The platform type trait alias template to remove the ::type.
50 template<typename T>
52
53 //! \return The device identified by its index.
54 template<typename TPlatform>
55 ALPAKA_FN_HOST auto getDevCount(TPlatform const& platform)
56 {
58 }
59
60 //! \return The device identified by its index.
61 template<typename TPlatform>
62 ALPAKA_FN_HOST auto getDevByIdx(TPlatform const& platform, std::size_t const& devIdx) -> Dev<TPlatform>
63 {
64 return trait::GetDevByIdx<TPlatform>::getDevByIdx(platform, devIdx);
65 }
66
67 //! \return All the devices available on this accelerator.
68 template<typename TPlatform>
69 ALPAKA_FN_HOST auto getDevs(TPlatform const& platform) -> std::vector<Dev<TPlatform>>
70 {
71 std::vector<Dev<TPlatform>> devs;
72
73 std::size_t const devCount = getDevCount(platform);
74 devs.reserve(devCount);
75 for(std::size_t devIdx(0); devIdx < devCount; ++devIdx)
76 {
77 devs.push_back(getDevByIdx(platform, devIdx));
78 }
79
80 return devs;
81 }
82
83 namespace trait
84 {
85 template<typename TPlatform, typename TProperty>
86 struct QueueType<
87 TPlatform,
88 TProperty,
89 std::enable_if_t<interface::ImplementsInterface<ConceptPlatform, TPlatform>::value>>
90 {
92 };
93 } // namespace trait
94} // 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::DevType< T >::type Dev
The device type trait alias template to remove the ::type.
Definition Traits.hpp:56
ALPAKA_FN_HOST auto getDevCount(TPlatform const &platform)
Definition Traits.hpp:55
constexpr bool isPlatform
True if TPlatform is a platform, i.e. if it implements the ConceptPlatform concept.
Definition Traits.hpp:23
ALPAKA_FN_HOST auto getDevByIdx(TPlatform const &platform, std::size_t const &devIdx) -> Dev< TPlatform >
Definition Traits.hpp:62
ALPAKA_FN_HOST auto getDevs(TPlatform const &platform) -> std::vector< Dev< TPlatform > >
Definition Traits.hpp:69
typename trait::PlatformType< T >::type Platform
The platform type trait alias template to remove the ::type.
Definition Traits.hpp:51
STL namespace.
Checks whether the interface is implemented by the given class.
Definition Interface.hpp:21
The device get trait.
Definition DevCpu.hpp:41
The device count get trait.
Definition Traits.hpp:42
The platform type trait.
Definition Traits.hpp:30
typename QueueType< typename alpaka::trait::DevType< TPlatform >::type, TProperty >::type type
Definition Traits.hpp:91
Queue for an accelerator.
Definition Traits.hpp:35