MemoryTraits¶
MemoryTraits is the last template parameter of View.
Usage¶
using DefaultMT = Kokkos::MemoryTraits<>;
using UnmanagedMT = Kokkos::MemoryTraits<Kokkos::Unmanaged>;
using AtomicRandomAccessMT =
Kokkos::MemoryTraits<Kokkos::Atomic | Kokkos::RandomAccess>;
Struct Interface¶
-
template<unsigned N>
struct MemoryTraits¶ When provided to a multidimensional View,
MemoryTraitsallow passing extra information about the treatment of the allocation. The template argument is expected to be a bitwise OR of enumeration values described below.Changed in version 4.7:
0was added as the default value for the template parameterN.template <unsigned N = 0> struct MemoryTraits;
Nested type
-
type memory_traits¶
A tag type signifying the memory access trait(s) denoted by
N.
Member Variables
-
static constexpr bool is_unmanaged¶
A boolean that indicates whether the Unmanaged trait is enabled.
-
static constexpr bool is_random_access¶
A boolean that indicates whether the RandomAccess trait is enabled.
-
static constexpr bool is_atomic¶
A boolean that indicates whether the Atomic trait is enabled.
-
static constexpr bool is_restrict¶
A boolean that indicates whether the Restrict trait is enabled.
-
static constexpr bool is_aligned¶
A boolean that indicates whether the Aligned trait is enabled.
Non-Member Enums¶
The following enumeration values are used to specify the memory access traits. Check the sub-section on memory access traits in the Programming Guide for further information about how these traits can be used in practice.
-
enum MemoryTraitsFlags¶
The following enumeration values are defined in this enumeration type.
-
enumerator Unmanaged¶
This traits means that Kokkos does neither reference counting nor automatic deallocation for such Views. This trait can be associated with memory allocated in any memory space. For example, an unmanaged view can be created by wrapping raw pointers of allocated memory, while also specifying the execution or memory space accordingly.
-
enumerator RandomAccess¶
Views that are going to be accessed irregularly (e.g., non-sequentially) can be declared as random access.
-
enumerator Atomic¶
In such a view, every access (read or write) to any element will be atomic.
-
enumerator Restrict¶
This trait indicates that the memory of this view doesn’t alias/overlap with another data structure in the current scope.
-
enumerator Aligned¶
This trait provides additional information to the compiler that the memory allocation in this
Viewhas an alignment of 64.
Non-Member Type aliases¶
The following type aliases are also available in the Kokkos namespace.
-
using MemoryManaged = MemoryTraits<0>;¶
Deprecated since version 4.7: The
MemoryManagedalias is deprecated. UseMemoryTraits<>instead. Note that prior Kokkos versions require an explicit0template argument.
-
using MemoryUnmanaged = MemoryTraits<Unmanaged>;¶
-
using MemoryRandomAccess = MemoryTraits<Unmanaged | RandomAccess>;¶
Changed in version 4.7:
MemoryRandomAccesswas changed toMemoryTraits<RandomAccess>and does not implyUnmanagedany more.
Example¶
Kokkos::View<DayaType,
LayoutType,
MemorySpace,
Kokkos::MemoryTraits<SomeFlag | SomeOtherFlag>> my_view;