-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprintf.cpp
More file actions
42 lines (37 loc) · 1.19 KB
/
printf.cpp
File metadata and controls
42 lines (37 loc) · 1.19 KB
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
//#include <CL/sycl.hpp>
#include "Kokkos_Core.hpp"
#include <stdlib.h>
#include <iostream>
//using namespace cl::sycl;
using HostSpace = Kokkos::HostSpace;
using MemSpace = Kokkos::Experimental::SYCLHostUSMSpace;
using ExSpace = Kokkos::Experimental::SYCL;
//using MemSpace = Kokkos::Experimental::OpenMPTargetSpace;
//using ExSpace = Kokkos::Experimental::OpenMPTarget;
//using MemSpace = Kokkos::HostSpace;
//using ExSpace = Kokkos::Serial;
using KokkosDevice = Kokkos::Device<ExSpace, MemSpace>;
int main(int, char**)
{
int num[3];
Kokkos::initialize();
{
Kokkos::View<int*, KokkosDevice> num_v("label", 3);
//Kokkos::View<int*, KokkosDevice> num_v(num, 3);
Kokkos::View<int*, HostSpace> num_h(num, 3);
num_v(0) = 1; num_v(1) = 1; num_v(2) = 0;
auto lam = [=](const int idx) {
num_v(2) = num_v(idx) + (num_v(idx));
//num_v(2) = 99;
};
Kokkos::parallel_for(2, lam);
Kokkos::fence();
std::cout << "1 + 1 = " << num_v(2) << std::endl;
std::cout << "num_h.data() == " << num_h.data() << '\n';
std::cout << "num_v.data() == " << num_v.data() << '\n';
Kokkos::deep_copy(num_h, num_v);
}
Kokkos::finalize();
std::cout << "1 + 1 = " << num[2] << std::endl;
return 0;
}