-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmin_deep_copy.cpp
More file actions
88 lines (72 loc) · 2.97 KB
/
Copy pathmin_deep_copy.cpp
File metadata and controls
88 lines (72 loc) · 2.97 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <Kokkos_Core.hpp>
#include <iostream>
#include "pretty_name.h"
volatile int dummy;
using execution_space = Kokkos::Experimental::SYCL;
using memory_space = execution_space::memory_space;
using view_type = Kokkos::View<int*>;
using PF = Kokkos::Impl::ParallelFor<
Kokkos::Impl::ViewCopy<
Kokkos::View<int *, ::Kokkos::LayoutLeft,
::Kokkos::Device< ::Kokkos::Experimental::SYCL,
::Kokkos::AnonymousSpace>,
::Kokkos::MemoryTraits<0> >,
Kokkos::View<const int *, ::Kokkos::LayoutLeft,
::Kokkos::Device< ::Kokkos::Experimental::SYCL,
::Kokkos::AnonymousSpace>,
::Kokkos::MemoryTraits<0> >,
Kokkos::LayoutLeft, Kokkos::Experimental::SYCL, 1, long, false>,
Kokkos::RangePolicy< ::Kokkos::Experimental::SYCL,
::Kokkos::IndexType<long> >,
Kokkos::Experimental::SYCL>;
void view_test()
{
std::cout << __PRETTY_FUNCTION__ << " Before view " << ++dummy << std::endl;
Kokkos::View<int*> v("V", 1);
std::cout << __PRETTY_FUNCTION__ << " After view " << ++dummy << std::endl;
}
void view_pf_test()
{
std::cout << __PRETTY_FUNCTION__ << " Before view " << ++dummy << std::endl;
view_type v("V", 1);
std::cout << __PRETTY_FUNCTION__ << " After view " << ++dummy << std::endl;
std::cout << __PRETTY_FUNCTION__ << " Before pf " << ++dummy << std::endl;
using functor_type = PF::functor_type;
using Policy = PF::Policy;
PF pf(functor_type{v, v}, Policy{});
std::cout << __PRETTY_FUNCTION__ << " After pf " << ++dummy << std::endl;
}
void view_pf_execute_test()
{
std::cout << __PRETTY_FUNCTION__ << " Before view " << ++dummy << std::endl;
view_type v("V", 1);
std::cout << __PRETTY_FUNCTION__ << " After view " << ++dummy << std::endl;
std::cout << __PRETTY_FUNCTION__ << " Before pf " << ++dummy << std::endl;
using functor_type = PF::functor_type;
using Policy = PF::Policy;
PF pf(functor_type{v, v}, Policy{});
std::cout << __PRETTY_FUNCTION__ << " After pf " << ++dummy << std::endl;
std::cout << __PRETTY_FUNCTION__ << " Before execute " << ++dummy << std::endl;
pf.execute();
std::cout << __PRETTY_FUNCTION__ << " After execute " << ++dummy << std::endl;
}
void view_deepcopy_test()
{
std::cout << __PRETTY_FUNCTION__ << " Before view " << ++dummy << std::endl;
view_type v("V", 1);
std::cout << __PRETTY_FUNCTION__ << " After view " << ++dummy << std::endl;
std::cout << __PRETTY_FUNCTION__ << " Before deep_copy " << ++dummy << std::endl;
Kokkos::deep_copy(v, v);
std::cout << __PRETTY_FUNCTION__ << " After deep_copy " << ++dummy << std::endl;
}
int main() {
Kokkos::ScopeGuard _;
view_test();
std::cout << std::endl;
view_pf_test();
std::cout << std::endl;
view_pf_execute_test();
std::cout << std::endl;
view_deepcopy_test();
std::cout << std::endl;
}