MemoryTraits
¶
MemoryTraits
is the last template parameter of View
.
Struct Interface¶
-
template<unsigned N>
struct MemoryTraits¶ When provided to a multidimensional View,
MemoryTraits
allow passing extra information about the treatment of the allocation. The template argument is expected to be a bitwise OR of enumeration values described below.
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
View
has an alignment of 64.
Non-Member Type aliases¶
The following type aliases are also available in the Kokkos
namespace.
-
using MemoryManaged = Kokkos::MemoryTraits<>;¶
-
using MemoryUnmanaged = Kokkos::MemoryTraits<Kokkos::Unmanaged>;¶
-
using MemoryRandomAccess = Kokkos::MemoryTraits<Kokkos::Unmanaged | Kokkos::RandomAccess>;¶
Note that in order to use a managed View in a random access manner, the memory trait should be specified as Kokkos::MemoryTraits<Kokkos::RandomAccess>
and not Kokkos::MemoryRandomAccess
.
Examples¶
Kokkos::View<DayaType, LayoutType, MemorySpace, Kokkos::MemoryTraits<SomeFlag | SomeOtherFlag> > my_view;
Example MemoryTraits type: Kokkos::MemoryTraits<Kokkos::Unmanaged | Kokkos::RandomAccess>