-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunmanaged_t.cxx
46 lines (39 loc) · 870 Bytes
/
unmanaged_t.cxx
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
44
45
46
#include <iostream>
#include <string>
#include <Kokkos_Core.hpp>
#include "common.hpp"
using namespace std;
using view_t = Kokkos::View<int**>;
using uview_t = Unmanaged<view_t>;
using aview_t = Atomic<uview_t>;
void func1(const view_t& arg)
{
for (size_t i = 0; i < arg.size(); ++i) {
std::cout << arg.data()[i] << " ";
}
std::cout << std::endl;
}
void func2(const uview_t& arg)
{
for (size_t i = 0; i < arg.size(); ++i) {
std::cout << arg.data()[i] << " ";
}
std::cout << std::endl;
}
int main(int argc, char** argv)
{
Kokkos::initialize(argc, argv); {
view_t data("data", 2, 4);
uview_t data2(data.data(), 2, 4);
aview_t data3(data.data(), 2, 4);
Kokkos::deep_copy(data, 42);
func1(data);
func2(data);
func1(data2);
func2(data2);
func1(data3);
func2(data3);
}
Kokkos::finalize();
return 0;
}