@@ -7,6 +7,30 @@ template <unsigned ID> struct ethernet_pipe_id {
7
7
static constexpr unsigned id = ID;
8
8
};
9
9
10
+ template <typename T, cl::sycl::access::address_space space>
11
+ void lsu_body (cl::sycl::multi_ptr<T,space> input_ptr,cl::sycl::multi_ptr<T,space> output_ptr) {
12
+ using PrefetchingLSU =
13
+ cl::sycl::INTEL::lsu<cl::sycl::INTEL::prefetch<true >,
14
+ cl::sycl::INTEL::statically_coalesce<false >>;
15
+
16
+ using BurstCoalescedLSU =
17
+ cl::sycl::INTEL::lsu<cl::sycl::INTEL::burst_coalesce<true >,
18
+ cl::sycl::INTEL::statically_coalesce<false >>;
19
+
20
+ using CachingLSU =
21
+ cl::sycl::INTEL::lsu<cl::sycl::INTEL::burst_coalesce<true >,
22
+ cl::sycl::INTEL::cache<1024 >,
23
+ cl::sycl::INTEL::statically_coalesce<false >>;
24
+
25
+ using PipelinedLSU = cl::sycl::INTEL::lsu<>;
26
+
27
+ int X = PrefetchingLSU::load (input_ptr); // int X = input_ptr[0]
28
+ int Y = CachingLSU::load (input_ptr + 1 ); // int Y = input_ptr[1]
29
+
30
+ BurstCoalescedLSU::store (output_ptr, X); // output_ptr[0] = X
31
+ PipelinedLSU::store (output_ptr + 1 , Y); // output_ptr[1] = Y
32
+ }
33
+
10
34
using ethernet_read_pipe =
11
35
sycl::INTEL::kernel_readable_io_pipe<ethernet_pipe_id<0 >, int , 0 >;
12
36
using ethernet_write_pipe =
@@ -58,39 +82,48 @@ int main() {
58
82
59
83
/* Check LSU interface*/
60
84
{
61
- cl::sycl::buffer<int , 1 > output_buffer (1 );
62
- auto *in_ptr = cl::sycl::malloc_host<int >(1 , Queue.get_context ());
63
-
64
- Queue.submit ([&](cl::sycl::handler &cgh) {
65
- auto output_accessor =
66
- output_buffer.get_access <cl::sycl::access::mode::write>(cgh);
67
-
68
- cgh.single_task <class kernel >([=] {
69
- cl::sycl::host_ptr<int > input_ptr (in_ptr);
70
- auto output_ptr = output_accessor.get_pointer ();
71
85
72
- using PrefetchingLSU =
73
- cl::sycl::INTEL::lsu<cl::sycl::INTEL::prefetch<true >,
74
- cl::sycl::INTEL::statically_coalesce<false >>;
75
-
76
- using BurstCoalescedLSU =
77
- cl::sycl::INTEL::lsu<cl::sycl::INTEL::burst_coalesce<true >,
78
- cl::sycl::INTEL::statically_coalesce<false >>;
79
-
80
- using CachingLSU =
81
- cl::sycl::INTEL::lsu<cl::sycl::INTEL::burst_coalesce<true >,
82
- cl::sycl::INTEL::cache<1024 >,
83
- cl::sycl::INTEL::statically_coalesce<false >>;
84
-
85
- using PipelinedLSU = cl::sycl::INTEL::lsu<>;
86
-
87
- int X = PrefetchingLSU::load (input_ptr); // int X = input_ptr[0]
88
- int Y = CachingLSU::load (input_ptr + 1 ); // int Y = input_ptr[1]
89
-
90
- BurstCoalescedLSU::store (output_ptr, X); // output_ptr[0] = X
91
- PipelinedLSU::store (output_ptr + 1 , Y); // output_ptr[1] = Y
86
+ {
87
+ auto *out_ptr = cl::sycl::malloc_host<int >(1 , Queue.get_context ());
88
+ auto *in_ptr = cl::sycl::malloc_host<int >(1 , Queue.get_context ());
89
+ Queue.submit ([&](sycl::handler &cgh) {
90
+ cgh.single_task <class HostAnnotation >([=]() {
91
+ cl::sycl::host_ptr<int > input_ptr (in_ptr);
92
+ cl::sycl::host_ptr<int > output_ptr (out_ptr);
93
+ intelfpga::lsu_body<
94
+ int , cl::sycl::access::address_space::global_host_space>(
95
+ input_ptr, output_ptr);
96
+ });
92
97
});
93
- });
98
+ }
99
+ {
100
+ auto *out_ptr = cl::sycl::malloc_device<int >(1 , Queue);
101
+ auto *in_ptr = cl::sycl::malloc_device<int >(1 , Queue);
102
+ Queue.submit ([&](sycl::handler &cgh) {
103
+ cgh.single_task <class DeviceAnnotation >([=]() {
104
+ cl::sycl::device_ptr<int > input_ptr (in_ptr);
105
+ cl::sycl::device_ptr<int > output_ptr (out_ptr);
106
+ intelfpga::lsu_body<
107
+ int , cl::sycl::access::address_space::global_device_space>(
108
+ input_ptr, output_ptr);
109
+ });
110
+ });
111
+ }
112
+ {
113
+ cl::sycl::buffer<int , 1 > output_buffer (1 );
114
+ cl::sycl::buffer<int , 1 > input_buffer (1 );
115
+ Queue.submit ([&](sycl::handler &cgh) {
116
+ auto output_accessor =
117
+ output_buffer.get_access <cl::sycl::access::mode::write>(cgh);
118
+ auto input_accessor =
119
+ input_buffer.get_access <cl::sycl::access::mode::read>(cgh);
120
+ cgh.single_task <class AccessorAnnotation >([=]() {
121
+ auto input_ptr = input_accessor.get_pointer ();
122
+ auto output_ptr = output_accessor.get_pointer ();
123
+ intelfpga::lsu_body<>(input_ptr, output_ptr);
124
+ });
125
+ });
126
+ }
94
127
}
95
128
96
129
return 0 ;
0 commit comments