alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
IView.hpp
Go to the documentation of this file.
1/* Copyright 2025 Simeon Ehrig
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
10#include "alpaka/trait.hpp"
11
12#include <type_traits>
13
14namespace alpaka::concepts
15{
16 namespace impl
17 {
18 /** @brief Interface concept for objects describing api-related multidimensional memory access.
19 *
20 * @details
21 * An `alpaka::view`-like object contains information about the device(s) to which it is connected. The
22 * `alpaka::view`-like object has no memory ownership, and therefore, it does not manage the memory lifetime.
23 * The represented memory can have any dimensionality.
24 *
25 * Any object fitting the `IView` concept is also an `IMdSpan`.
26 **/
27 template<typename T, typename T_Mut, typename T_Const>
28 concept IView = requires(T t, alpaka::Vec<typename T::index_type, T::dim()> vec) {
30 { t.getApi() } -> alpaka::concepts::Api;
31
32 /** @brief Creates a sub view to a part of the memory.
33 *
34 * @see alpaka::View::getSubView
35 *
36 * @{
37 */
38 t.getSubView(vec /* extents */) /* -> alpaka::concepts::impl::IView */;
39 t.getSubView(vec /* offset */, vec /* extents */) /* -> alpaka::concepts::impl::IView */;
40
41 /** @} */
42 };
43 } // namespace impl
44
45 /** @brief Interface concept for objects describing api-related multidimensional memory access.
46 *
47 * @details
48 * An `alpaka::view`-like object contains information about the device(s) to which it is connected. The
49 * `alpaka::view`-like object has no memory ownership, and, therefore, it does not manage the memory lifetime.
50 * The represented memory can have any dimensionality.
51 *
52 * @attention Use `alpaka::IView` to restrict types in your code. The actual interface is described in
53 * alpaka::concepts::impl::IView.
54 **/
55 template<typename T, typename T_ValueType = alpaka::NotRequired>
56 concept IView = requires(T t) {
57 requires impl::IView<
58 std::remove_reference_t<T>,
59 std::remove_const_t<std::remove_reference_t<T>>,
60 std::add_const_t<std::remove_reference_t<T>>>;
62 };
63} // namespace alpaka::concepts
Concept to check for APIs.
Definition api.hpp:42
Check whether the specified data type matches the expected type, or if the expected type is alpaka::N...
Interface concept for objects describing api-related multidimensional memory access.
Definition IView.hpp:56
Interface concept for objects describing multidimensional memory access.
Definition IMdSpan.hpp:54
Interface concept for objects describing api-related multidimensional memory access.
Definition IView.hpp:28