-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.hpp
43 lines (38 loc) · 1.63 KB
/
common.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef COMMON_HPP
#define COMMON_HPP
#include <Kokkos_Core.hpp>
template <typename View>
struct MemoryTraitsMask {
enum : unsigned int {
value = ((View::traits::memory_traits::is_random_access ? Kokkos::RandomAccess : 0) |
(View::traits::memory_traits::is_atomic ? Kokkos::Atomic : 0) |
(View::traits::memory_traits::is_restrict ? Kokkos::Restrict : 0) |
(View::traits::memory_traits::is_aligned ? Kokkos::Aligned : 0) |
(View::traits::memory_traits::is_unmanaged ? Kokkos::Unmanaged : 0))
};
};
template <typename View>
using Unmanaged =
// Provide a full View type specification, augmented with Unmanaged.
Kokkos::View<typename View::traits::scalar_array_type,
typename View::traits::array_layout,
typename View::traits::device_type,
Kokkos::MemoryTraits<
// All the current values...
MemoryTraitsMask<View>::value |
// ... |ed with the one we want, whether or not it's
// already there.
Kokkos::Unmanaged> >;
template <typename View>
using Atomic =
// Provide a full View type specification, augmented with Unmanaged.
Kokkos::View<typename View::traits::scalar_array_type,
typename View::traits::array_layout,
typename View::traits::device_type,
Kokkos::MemoryTraits<
// All the current values...
MemoryTraitsMask<View>::value |
// ... |ed with the one we want, whether or not it's
// already there.
Kokkos::Atomic> >;
#endif