alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
concepts.hpp
Go to the documentation of this file.
1/* Copyright 2024 René Widera, Tim Hanel
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
15#include "alpaka/tag.hpp"
16
17#include <concepts>
18
19namespace alpaka
20{
21 namespace concepts
22 {
23 /** @brief Concept to check if the given type has a `get()` function.
24 */
25 template<typename T>
26 concept HasGet = requires(T t) { t.get(); };
27
28 /** @brief Concept to check if the given type has a static `dim()` function
29 */
30 template<typename T>
31 concept HasStaticDim = requires(T t) { T::dim(); };
32
33 /** @brief Concept to check if the given type is of the given dimensionality
34 *
35 * @details
36 * The checked type must also fulfill HasStaticDim.
37 *
38 * @tparam T The type to check
39 * @tparam T_dim The dimension the checked type should have
40 */
41 template<typename T, unsigned int T_dim>
42 concept Dim = (T::dim() == T_dim);
43
44 /** @brief Concept to check if the given type is a GPU DeviceKind
45 */
46 template<typename T>
47 concept GpuType
50
51 /** @brief Concept to check if the given type is a pointer, using std::is_pointer
52 */
53 template<typename T>
54 concept Pointer = std::is_pointer_v<T>;
55
56 /** @brief Concept to check that a device specification with an API and device kind can be extracted. */
57 template<typename T>
62
63 /** Concept to check for a backend specification
64 *
65 * The object must provide the possibility for querying the device specification properties and the executor.
66 */
67 template<typename T>
68 concept BackendSpec = requires(T t) {
69 requires DeviceSpec<T>;
71 };
72 } // namespace concepts
73
74 namespace internal
75 {
76 template<alpaka::concepts::Api T_Api>
77 struct GetApi::Op<T_Api>
78 {
79 inline constexpr auto operator()(auto&& api) const
80 {
81 return api;
82 }
83 };
84 } // namespace internal
85} // namespace alpaka
Concept to check for APIs.
Definition api.hpp:42
Concept to check for a backend specification.
Definition concepts.hpp:68
Concept to check if something is a device kind.
Definition tag.hpp:145
Concept to check that a device specification with an API and device kind can be extracted.
Definition concepts.hpp:58
Concept to check if the given type is of the given dimensionality.
Definition concepts.hpp:42
Concept to check for an executor.
Definition trait.hpp:133
Concept to check if the given type is a GPU DeviceKind.
Definition concepts.hpp:48
Concept to check if the given type has a get() function.
Definition concepts.hpp:26
Concept to check if the given type has a static dim() function.
Definition concepts.hpp:31
Concept to check if the given type is a pointer, using std::is_pointer.
Definition concepts.hpp:54
constexpr auto intelGpu
Definition tag.hpp:208
constexpr auto amdGpu
Definition tag.hpp:188
constexpr auto nvidiaGpu
Definition tag.hpp:198
alpaka internal implementations.
Definition generic.hpp:19
constexpr auto getExecutor(T_Any &&any) -> decltype(GetExecutor::Op< ALPAKA_TYPEOF(any)>{}(any))
Definition interface.hpp:86
constexpr auto getDeviceKind(auto &&any) -> decltype(GetDeviceType::Op< ALPAKA_TYPEOF(any)>{}(any))
constexpr auto getApi(auto &&any) -> decltype(GetApi::Op< ALPAKA_TYPEOF(any)>{}(any))
Definition interface.hpp:62
main alpaka namespace.
Definition alpaka.hpp:76
constexpr auto operator()(auto &&api) const
Definition concepts.hpp:79