-
Notifications
You must be signed in to change notification settings - Fork 0
/
lr_deep_copy.cxx
56 lines (48 loc) · 1.47 KB
/
lr_deep_copy.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
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <string>
#include <Kokkos_Core.hpp>
#include <Kokkos_OffsetView.hpp>
#include "YAKL.h"
using namespace std;
using DefaultDevice =
Kokkos::Device<Kokkos::DefaultExecutionSpace, Kokkos::DefaultExecutionSpace::memory_space>;
using HostDevice =
Kokkos::Device<Kokkos::DefaultHostExecutionSpace, Kokkos::DefaultHostExecutionSpace::memory_space>;
template <typename T, typename Device=DefaultDevice>
using FView = Kokkos::View<T, Kokkos::LayoutLeft, Device>;
template <typename T, typename Device=DefaultDevice>
using CView = Kokkos::View<T, Kokkos::LayoutRight, Device>;
int main(int argc, char** argv)
{
Kokkos::initialize(argc, argv); {
FView<int**> fview("fview", 2, 3);
int count = 0;
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 3; ++j) {
fview(i, j) = ++count;
}
}
CView<int**> cview("cview", 2, 3);
Kokkos::deep_copy(cview, fview);
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 3; ++j) {
std::cout << "fview = " << fview(i, j) << std::endl;
}
}
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 3; ++j) {
std::cout << "cview = " << cview(i, j) << std::endl;
}
}
for (size_t i = 0; i < fview.size(); ++i) {
std::cout << fview.data()[i] << " ";
}
std::cout << std::endl;
for (size_t i = 0; i < cview.size(); ++i) {
std::cout << cview.data()[i] << " ";
}
std::cout << std::endl;
}
Kokkos::finalize();
return 0;
}