-
Notifications
You must be signed in to change notification settings - Fork 0
/
subview.cxx
38 lines (33 loc) · 1 KB
/
subview.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
#include <iostream>
#include <string>
#include <Kokkos_Core.hpp>
#include <Kokkos_OffsetView.hpp>
#include "YAKL.h"
using namespace std;
int main(int argc, char** argv)
{
Kokkos::initialize(argc, argv); {
const int dim0 = 4;
const int dim1 = 3;
Kokkos::View<int**> orig_view("testlayout", dim0, dim1);
for (int i = 0; i < dim0; ++i) {
for (int j = 0; j < dim1; ++j) {
orig_view(i, j) = i*10 + j;
}
}
Kokkos::View<int**> subv(orig_view, std::make_pair(2, 4), Kokkos::ALL);
for (size_t i = 0; i < subv.extent(0); ++i) {
for (size_t j = 0; j < subv.extent(1); ++j) {
std::cout << "subv(" << i << ", " << j << ") = " << subv(i, j) << std::endl;
}
}
for (auto r = 0; r < 2; ++r) {
std::cout << "orig DIM " << r << ": " << orig_view.layout().dimension[r] << std::endl;
}
for (auto r = 0; r < 2; ++r) {
std::cout << "subv DIM " << r << ": " << subv.layout().dimension[r] << std::endl;
}
}
Kokkos::finalize();
return 0;
}