alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
IBuffer.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
9#include "alpaka/trait.hpp"
10
11#include <type_traits>
12
13namespace alpaka::concepts
14{
15 /** Dummy function for concepts.
16 *
17 * Represent a callable without arguments and return value void. Required because nvcc could not handle empty
18 * lambdas in concepts.
19 */
20 inline void empty_callable()
21 {
22 }
23
24 namespace impl
25 {
26 /** @brief Interface concept for objects describing multidimensional owned memory.
27 *
28 * @details
29 * An `alpaka::buffer`-like object contains information about the device(s) to which it is connected. The
30 * `alpaka::buffer`-like object has memory ownership and therefore manages memory lifetime according to the
31 * RAII principle. The represented memory can have any dimensionality.
32 *
33 * Any object that fulfills the `IBuffer` concept is also an `IView` and `IMdSpan`.
34 *
35 * @section memberfunction member functions
36 *
37 * - <b>t.addDestructorAction</b>: Adds a destructor action to the shared buffer.
38 * @code{.unparsed}
39 * The action will be executed when the buffer is destroyed.
40 * This can be used to add additional cleanup actions e.g. waiting on a specific queue.
41 * Actions are executed in FIFO order.
42 * @endcode
43 * - <b>t.destructorWaitFor</b>: Add an action to be executed when the shared_ptr is destroyed.
44 **/
45 template<typename T, typename T_Mut, typename T_Const>
46 concept IBuffer = requires(T t) {
48 t.addDestructorAction(alpaka::concepts::empty_callable);
49 t.destructorWaitFor(alpaka::concepts::empty_callable);
50 };
51 } // namespace impl
52
53 /** @brief Interface concept for objects describing multidimensional owned memory.
54 *
55 * @details
56 * An `alpaka::buffer`-like object contains information about the device(s) to which it is connected. The
57 * `alpaka::buffer`-like object has memory ownership and therefore manages memory lifetime according to the RAII
58 * principle.
59 *
60 * @attention Use `alpaka::IBuffer` to restrict types in your code. The actual interface is described in
61 * alpaka::concepts::impl::IBuffer.
62 **/
63 template<typename T, typename T_ValueType = alpaka::NotRequired>
64 concept IBuffer = requires(T t) {
65 requires impl::IBuffer<
66 std::remove_reference_t<T>,
67 std::remove_const_t<std::remove_reference_t<T>>,
68 std::add_const_t<std::remove_reference_t<T>>>;
70 };
71} // namespace alpaka::concepts
Check whether the specified data type matches the expected type, or if the expected type is alpaka::N...
Interface concept for objects describing multidimensional owned memory.
Definition IBuffer.hpp:64
Interface concept for objects describing multidimensional owned memory.
Definition IBuffer.hpp:46
Interface concept for objects describing api-related multidimensional memory access.
Definition IView.hpp:28
void empty_callable()
Dummy function for concepts.
Definition IBuffer.hpp:20