Kokkos Core Kernels Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
Kokkos_MemoryTraits.hpp
1
//@HEADER
2
// ************************************************************************
3
//
4
// Kokkos v. 4.0
5
// Copyright (2022) National Technology & Engineering
6
// Solutions of Sandia, LLC (NTESS).
7
//
8
// Under the terms of Contract DE-NA0003525 with NTESS,
9
// the U.S. Government retains certain rights in this software.
10
//
11
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
12
// See https://kokkos.org/LICENSE for license information.
13
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14
//
15
//@HEADER
16
17
#ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
18
#include <Kokkos_Macros.hpp>
19
static_assert
(
false
,
20
"Including non-public Kokkos header files is not allowed."
);
21
#endif
22
#ifndef KOKKOS_MEMORYTRAITS_HPP
23
#define KOKKOS_MEMORYTRAITS_HPP
24
25
#include <impl/Kokkos_Traits.hpp>
26
27
//----------------------------------------------------------------------------
28
29
namespace
Kokkos {
30
39
enum
MemoryTraitsFlags {
40
Unmanaged = 0x01,
41
RandomAccess = 0x02,
42
Atomic = 0x04,
43
Restrict = 0x08,
44
Aligned = 0x10
45
};
46
47
template
<
unsigned
T>
48
struct
MemoryTraits {
50
using
memory_traits = MemoryTraits<T>;
51
52
static
constexpr
unsigned
impl_value = T;
53
54
static
constexpr
bool
is_unmanaged =
55
(unsigned(0) != (T & unsigned(Kokkos::Unmanaged)));
56
static
constexpr
bool
is_random_access =
57
(unsigned(0) != (T & unsigned(Kokkos::RandomAccess)));
58
static
constexpr
bool
is_atomic =
59
(unsigned(0) != (T & unsigned(Kokkos::Atomic)));
60
static
constexpr
bool
is_restrict =
61
(unsigned(0) != (T & unsigned(Kokkos::Restrict)));
62
static
constexpr
bool
is_aligned =
63
(unsigned(0) != (T & unsigned(Kokkos::Aligned)));
64
};
65
66
}
// namespace Kokkos
67
68
//----------------------------------------------------------------------------
69
70
namespace
Kokkos {
71
72
using
MemoryManaged = Kokkos::MemoryTraits<0>;
73
using
MemoryUnmanaged = Kokkos::MemoryTraits<Kokkos::Unmanaged>;
74
using
MemoryRandomAccess =
75
Kokkos::MemoryTraits<Kokkos::Unmanaged | Kokkos::RandomAccess>;
76
77
}
// namespace Kokkos
78
79
//----------------------------------------------------------------------------
80
81
namespace
Kokkos {
82
namespace
Impl
{
83
84
static_assert
((0 < int(KOKKOS_MEMORY_ALIGNMENT)) &&
85
(0 == (int(KOKKOS_MEMORY_ALIGNMENT) &
86
(int(KOKKOS_MEMORY_ALIGNMENT) - 1))),
87
"KOKKOS_MEMORY_ALIGNMENT must be a power of two"
);
88
95
enum :
unsigned
{
96
MEMORY_ALIGNMENT = KOKKOS_MEMORY_ALIGNMENT,
97
MEMORY_ALIGNMENT_THRESHOLD = KOKKOS_MEMORY_ALIGNMENT_THRESHOLD
98
};
99
100
// ------------------------------------------------------------------ //
101
// this identifies the default memory trait
102
//
103
template
<
typename
Tp>
104
struct
is_default_memory_trait : std::false_type {};
105
106
template
<>
107
struct
is_default_memory_trait<Kokkos::MemoryTraits<0>> : std::true_type {};
108
109
}
// namespace Impl
110
}
// namespace Kokkos
111
112
#endif
/* #ifndef KOKKOS_MEMORYTRAITS_HPP */
Kokkos::Impl
ScopeGuard Some user scope issues have been identified with some Kokkos::finalize calls; ScopeGuard a...
Definition
Kokkos_AnonymousSpace.hpp:61
Generated by
1.17.0