37
37
38
38
#include < filesystem>
39
39
#include < fstream>
40
+ #include < utility>
41
+
40
42
#include < gtest/gtest.h>
41
43
#include < sycl/sycl.hpp>
42
- #include < utility>
43
44
44
45
namespace
45
46
{
46
- constexpr std::size_t SIZE = 100 ;
47
+ constexpr std::size_t SIZE = 320 ;
48
+
49
+ static_assert (SIZE % 10 == 0 );
47
50
48
51
using namespace dpctl ::syclinterface;
49
52
@@ -69,11 +72,13 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
69
72
a_ptr[i] = 0 ;
70
73
}
71
74
72
- auto la1 = MDLocalAccessor{1 , kernelArgTy, SIZE / 10 , 1 , 1 };
75
+ std::size_t lws = SIZE / 10 ;
76
+
77
+ auto la1 = MDLocalAccessor{1 , kernelArgTy, lws, 1 , 1 };
73
78
74
79
// Create kernel args for vector_add
75
80
std::size_t gRange [] = {SIZE};
76
- std::size_t lRange[] = {SIZE / 10 };
81
+ std::size_t lRange[] = {lws };
77
82
void *args_1d[NARGS] = {unwrap<void >(a), (void *)&la1};
78
83
DPCTLKernelArgType addKernelArgTypes[] = {DPCTL_VOID_PTR,
79
84
DPCTL_LOCAL_ACCESSOR};
@@ -84,7 +89,7 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
84
89
ASSERT_TRUE (E1Ref != nullptr );
85
90
86
91
DPCTLSyclEventRef DepEv1[] = {E1Ref};
87
- auto la2 = MDLocalAccessor{2 , kernelArgTy, SIZE / 10 , 1 , 1 };
92
+ auto la2 = MDLocalAccessor{2 , kernelArgTy, lws , 1 , 1 };
88
93
void *args_2d[NARGS] = {unwrap<void >(a), (void *)&la2};
89
94
90
95
DPCTLSyclEventRef E2Ref =
@@ -93,7 +98,7 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
93
98
ASSERT_TRUE (E2Ref != nullptr );
94
99
95
100
DPCTLSyclEventRef DepEv2[] = {E1Ref, E2Ref};
96
- auto la3 = MDLocalAccessor{3 , kernelArgTy, SIZE / 10 , 1 , 1 };
101
+ auto la3 = MDLocalAccessor{3 , kernelArgTy, lws , 1 , 1 };
97
102
void *args_3d[NARGS] = {unwrap<void >(a), (void *)&la3};
98
103
99
104
DPCTLSyclEventRef E3Ref =
@@ -103,10 +108,7 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
103
108
104
109
DPCTLEvent_Wait (E3Ref);
105
110
106
- if (kernelArgTy != DPCTL_FLOAT32_T && kernelArgTy != DPCTL_FLOAT64_T)
107
- ASSERT_TRUE (a_ptr[0 ] == 20 );
108
- else
109
- ASSERT_TRUE (a_ptr[0 ] == 20.0 );
111
+ ASSERT_TRUE (a_ptr[0 ] == T (lws * 2 ));
110
112
111
113
// clean ups
112
114
DPCTLEvent_Delete (E1Ref);
@@ -133,9 +135,9 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
133
135
// figure which SPV file contains the kernels, use `spirv-dis` from the
134
136
// spirv-tools package to translate the SPV binary format to a human-readable
135
137
// textual format.
136
- #include <CL/sycl.hpp>
137
138
#include <iostream>
138
139
#include <sstream>
140
+ #include <sycl/sycl.hpp>
139
141
140
142
template <typename T>
141
143
class SyclKernel_SLM
@@ -195,7 +197,7 @@ int main(int argc, const char **argv)
195
197
driver<int8_t>(N);
196
198
driver<uint8_t>(N);
197
199
driver<int16_t>(N);
198
- driver<int32_t >(N);
200
+ driver<uint16_t >(N);
199
201
driver<int32_t>(N);
200
202
driver<uint32_t>(N);
201
203
driver<int64_t>(N);
@@ -220,11 +222,10 @@ struct TestQueueSubmitWithLocalAccessor : public ::testing::Test
220
222
{
221
223
DPCTLSyclDeviceSelectorRef DSRef = nullptr ;
222
224
DPCTLSyclDeviceRef DRef = nullptr ;
225
+ const char *test_spv_fn = " ./local_accessor_kernel_inttys_fp32.spv" ;
223
226
224
- spirvFile.open (" ./local_accessor_kernel_inttys_fp32.spv" ,
225
- std::ios::binary | std::ios::ate);
226
- spirvFileSize_ = std::filesystem::file_size (
227
- " ./local_accessor_kernel_inttys_fp32.spv" );
227
+ spirvFile.open (test_spv_fn, std::ios::binary | std::ios::ate);
228
+ spirvFileSize_ = std::filesystem::file_size (test_spv_fn);
228
229
spirvBuffer_.reserve (spirvFileSize_);
229
230
spirvFile.seekg (0 , std::ios::beg);
230
231
spirvFile.read (spirvBuffer_.data (), spirvFileSize_);
@@ -261,11 +262,10 @@ struct TestQueueSubmitWithLocalAccessorFP64 : public ::testing::Test
261
262
TestQueueSubmitWithLocalAccessorFP64 ()
262
263
{
263
264
DPCTLSyclDeviceSelectorRef DSRef = nullptr ;
265
+ const char *test_spv_fn = " ./local_accessor_kernel_fp64.spv" ;
264
266
265
- spirvFile.open (" ./local_accessor_kernel_fp64.spv" ,
266
- std::ios::binary | std::ios::ate);
267
- spirvFileSize_ =
268
- std::filesystem::file_size (" ./local_accessor_kernel_fp64.spv" );
267
+ spirvFile.open (test_spv_fn, std::ios::binary | std::ios::ate);
268
+ spirvFileSize_ = std::filesystem::file_size (test_spv_fn);
269
269
spirvBuffer_.reserve (spirvFileSize_);
270
270
spirvFile.seekg (0 , std::ios::beg);
271
271
spirvFile.read (spirvBuffer_.data (), spirvFileSize_);
0 commit comments