Skip to content

Commit 73cd278

Browse files
Use qualified C++ integral types in test_sycl_queue_submit_local_accessor_arg.cpp
1 parent affe2db commit 73cd278

File tree

2 files changed

+90
-87
lines changed

2 files changed

+90
-87
lines changed

libsyclinterface/tests/test_sycl_queue_submit.cpp

Lines changed: 52 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,20 @@
3232
#include "dpctl_sycl_queue_interface.h"
3333
#include "dpctl_sycl_type_casters.hpp"
3434
#include "dpctl_sycl_usm_interface.h"
35+
36+
#include <stddef.h>
37+
38+
#include <cstdint>
3539
#include <filesystem>
3640
#include <fstream>
3741
#include <gtest/gtest.h>
3842
#include <iostream>
39-
#include <stddef.h>
4043
#include <sycl/sycl.hpp>
4144
#include <utility>
4245

4346
namespace
4447
{
45-
constexpr size_t SIZE = 1024;
48+
constexpr std::size_t SIZE = 1024;
4649
static_assert(SIZE % 8 == 0);
4750

4851
using namespace dpctl::syclinterface;
@@ -51,15 +54,15 @@ template <typename T>
5154
void submit_kernel(DPCTLSyclQueueRef QRef,
5255
DPCTLSyclKernelBundleRef KBRef,
5356
std::vector<char> spirvBuffer,
54-
size_t spirvFileSize,
57+
std::size_t spirvFileSize,
5558
DPCTLKernelArgType kernelArgTy,
5659
std::string kernelName)
5760
{
5861
T scalarVal = 3;
59-
constexpr size_t NARGS = 4;
60-
constexpr size_t RANGE_NDIMS_1 = 1;
61-
constexpr size_t RANGE_NDIMS_2 = 2;
62-
constexpr size_t RANGE_NDIMS_3 = 3;
62+
constexpr std::size_t NARGS = 4;
63+
constexpr std::size_t RANGE_NDIMS_1 = 1;
64+
constexpr std::size_t RANGE_NDIMS_2 = 2;
65+
constexpr std::size_t RANGE_NDIMS_3 = 3;
6366

6467
ASSERT_TRUE(DPCTLKernelBundle_HasKernel(KBRef, kernelName.c_str()));
6568
auto kernel = DPCTLKernelBundle_GetKernel(KBRef, kernelName.c_str());
@@ -73,7 +76,7 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
7376
ASSERT_TRUE(c != nullptr);
7477

7578
// Create kernel args for vector_add
76-
size_t Range[] = {SIZE};
79+
std::size_t Range[] = {SIZE};
7780
void *args[NARGS] = {unwrap<void>(a), unwrap<void>(b), unwrap<void>(c),
7881
(void *)&scalarVal};
7982
DPCTLKernelArgType addKernelArgTypes[] = {DPCTL_VOID_PTR, DPCTL_VOID_PTR,
@@ -84,15 +87,15 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
8487
ASSERT_TRUE(E1Ref != nullptr);
8588

8689
// Create kernel args for vector_add
87-
size_t Range2D[] = {SIZE, 1};
90+
std::size_t Range2D[] = {SIZE, 1};
8891
DPCTLSyclEventRef DepEvs[] = {E1Ref};
8992
auto E2Ref =
9093
DPCTLQueue_SubmitRange(kernel, QRef, args, addKernelArgTypes, NARGS,
9194
Range2D, RANGE_NDIMS_2, DepEvs, 1);
9295
ASSERT_TRUE(E2Ref != nullptr);
9396

9497
// Create kernel args for vector_add
95-
size_t Range3D[] = {SIZE, 1, 1};
98+
std::size_t Range3D[] = {SIZE, 1, 1};
9699
DPCTLSyclEventRef DepEvs2[] = {E1Ref, E2Ref};
97100
auto E3Ref =
98101
DPCTLQueue_SubmitRange(kernel, QRef, args, addKernelArgTypes, NARGS,
@@ -174,7 +177,7 @@ void submit_kernel(
174177
}
175178
176179
template <typename T>
177-
void driver(size_t N)
180+
void driver(std::size_t N)
178181
{
179182
sycl::queue q;
180183
auto *a = sycl::malloc_shared<T>(N, q);
@@ -191,19 +194,19 @@ void driver(size_t N)
191194
192195
int main(int argc, const char **argv)
193196
{
194-
size_t N = 0;
197+
std::size_t N = 0;
195198
std::cout << "Enter problem size in N:\n";
196199
std::cin >> N;
197200
std::cout << "Executing with N = " << N << std::endl;
198201
199-
driver<int8_t>(N);
200-
driver<uint8_t>(N);
201-
driver<int16_t>(N);
202-
driver<uint16_t>(N);
203-
driver<int32_t>(N);
204-
driver<uint32_t>(N);
205-
driver<int64_t>(N);
206-
driver<uint64_t>(N);
202+
driver<std::int8_t>(N);
203+
driver<std::uint8_t>(N);
204+
driver<std::int16_t>(N);
205+
driver<std::uint16_t>(N);
206+
driver<std::int32_t>(N);
207+
driver<std::uint32_t>(N);
208+
driver<std::int64_t>(N);
209+
driver<std::uint64_t>(N);
207210
driver<float>(N);
208211
driver<double>(N);
209212
@@ -214,7 +217,7 @@ int main(int argc, const char **argv)
214217
struct TestQueueSubmit : public ::testing::Test
215218
{
216219
std::ifstream spirvFile;
217-
size_t spirvFileSize_;
220+
std::size_t spirvFileSize_;
218221
std::vector<char> spirvBuffer_;
219222
DPCTLSyclQueueRef QRef = nullptr;
220223
DPCTLSyclKernelBundleRef KBRef = nullptr;
@@ -255,7 +258,7 @@ struct TestQueueSubmit : public ::testing::Test
255258
struct TestQueueSubmitFP64 : public ::testing::Test
256259
{
257260
std::ifstream spirvFile;
258-
size_t spirvFileSize_;
261+
std::size_t spirvFileSize_;
259262
std::vector<char> spirvBuffer_;
260263
DPCTLSyclDeviceRef DRef = nullptr;
261264
DPCTLSyclQueueRef QRef = nullptr;
@@ -294,58 +297,58 @@ struct TestQueueSubmitFP64 : public ::testing::Test
294297

295298
TEST_F(TestQueueSubmit, CheckForInt8)
296299
{
297-
submit_kernel<int8_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
298-
DPCTLKernelArgType::DPCTL_INT8_T,
299-
"_ZTS11RangeKernelIaE");
300+
submit_kernel<std::int8_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
301+
DPCTLKernelArgType::DPCTL_INT8_T,
302+
"_ZTS11RangeKernelIaE");
300303
}
301304

302305
TEST_F(TestQueueSubmit, CheckForUInt8)
303306
{
304-
submit_kernel<uint8_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
305-
DPCTLKernelArgType::DPCTL_UINT8_T,
306-
"_ZTS11RangeKernelIhE");
307+
submit_kernel<std::uint8_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
308+
DPCTLKernelArgType::DPCTL_UINT8_T,
309+
"_ZTS11RangeKernelIhE");
307310
}
308311

309312
TEST_F(TestQueueSubmit, CheckForInt16)
310313
{
311-
submit_kernel<int16_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
312-
DPCTLKernelArgType::DPCTL_INT16_T,
313-
"_ZTS11RangeKernelIsE");
314+
submit_kernel<std::int16_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
315+
DPCTLKernelArgType::DPCTL_INT16_T,
316+
"_ZTS11RangeKernelIsE");
314317
}
315318

316319
TEST_F(TestQueueSubmit, CheckForUInt16)
317320
{
318-
submit_kernel<uint16_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
319-
DPCTLKernelArgType::DPCTL_UINT16_T,
320-
"_ZTS11RangeKernelItE");
321+
submit_kernel<std::uint16_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
322+
DPCTLKernelArgType::DPCTL_UINT16_T,
323+
"_ZTS11RangeKernelItE");
321324
}
322325

323326
TEST_F(TestQueueSubmit, CheckForInt32)
324327
{
325-
submit_kernel<int32_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
326-
DPCTLKernelArgType::DPCTL_INT32_T,
327-
"_ZTS11RangeKernelIiE");
328+
submit_kernel<std::int32_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
329+
DPCTLKernelArgType::DPCTL_INT32_T,
330+
"_ZTS11RangeKernelIiE");
328331
}
329332

330333
TEST_F(TestQueueSubmit, CheckForUInt32)
331334
{
332-
submit_kernel<uint32_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
333-
DPCTLKernelArgType::DPCTL_UINT32_T,
334-
"_ZTS11RangeKernelIjE");
335+
submit_kernel<std::uint32_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
336+
DPCTLKernelArgType::DPCTL_UINT32_T,
337+
"_ZTS11RangeKernelIjE");
335338
}
336339

337340
TEST_F(TestQueueSubmit, CheckForInt64)
338341
{
339-
submit_kernel<int64_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
340-
DPCTLKernelArgType::DPCTL_INT64_T,
341-
"_ZTS11RangeKernelIlE");
342+
submit_kernel<std::int64_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
343+
DPCTLKernelArgType::DPCTL_INT64_T,
344+
"_ZTS11RangeKernelIlE");
342345
}
343346

344347
TEST_F(TestQueueSubmit, CheckForUInt64)
345348
{
346-
submit_kernel<uint64_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
347-
DPCTLKernelArgType::DPCTL_UINT64_T,
348-
"_ZTS11RangeKernelImE");
349+
submit_kernel<std::uint64_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
350+
DPCTLKernelArgType::DPCTL_UINT64_T,
351+
"_ZTS11RangeKernelImE");
349352
}
350353

351354
TEST_F(TestQueueSubmit, CheckForFloat)
@@ -368,9 +371,9 @@ TEST_F(TestQueueSubmit, CheckForUnsupportedArgTy)
368371
{
369372

370373
int scalarVal = 3;
371-
size_t Range[] = {SIZE};
372-
size_t RANGE_NDIMS = 1;
373-
constexpr size_t NARGS = 4;
374+
std::size_t Range[] = {SIZE};
375+
std::size_t RANGE_NDIMS = 1;
376+
constexpr std::size_t NARGS = 4;
374377

375378
auto kernel = DPCTLKernelBundle_GetKernel(KBRef, "_ZTS11RangeKernelIdE");
376379
void *args[NARGS] = {unwrap<void>(nullptr), unwrap<void>(nullptr),

libsyclinterface/tests/test_sycl_queue_submit_local_accessor_arg.cpp

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,20 @@
4141

4242
namespace
4343
{
44-
constexpr size_t SIZE = 100;
44+
constexpr std::size_t SIZE = 100;
4545

4646
using namespace dpctl::syclinterface;
4747

4848
template <typename T>
4949
void submit_kernel(DPCTLSyclQueueRef QRef,
5050
DPCTLSyclKernelBundleRef KBRef,
5151
std::vector<char> spirvBuffer,
52-
size_t spirvFileSize,
52+
std::size_t spirvFileSize,
5353
DPCTLKernelArgType kernelArgTy,
5454
std::string kernelName)
5555
{
56-
constexpr size_t NARGS = 2;
57-
constexpr size_t RANGE_NDIMS = 1;
56+
constexpr std::size_t NARGS = 2;
57+
constexpr std::size_t RANGE_NDIMS = 1;
5858

5959
ASSERT_TRUE(DPCTLKernelBundle_HasKernel(KBRef, kernelName.c_str()));
6060
auto kernel = DPCTLKernelBundle_GetKernel(KBRef, kernelName.c_str());
@@ -70,8 +70,8 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
7070
auto la1 = MDLocalAccessor{1, kernelArgTy, SIZE / 10, 1, 1};
7171

7272
// Create kernel args for vector_add
73-
size_t gRange[] = {SIZE};
74-
size_t lRange[] = {SIZE / 10};
73+
std::size_t gRange[] = {SIZE};
74+
std::size_t lRange[] = {SIZE / 10};
7575
void *args_1d[NARGS] = {unwrap<void>(a), (void *)&la1};
7676
DPCTLKernelArgType addKernelArgTypes[] = {DPCTL_VOID_PTR,
7777
DPCTL_LOCAL_ACCESSOR};
@@ -174,7 +174,7 @@ void submit_kernel(sycl::queue q, const unsigned long N, T *a)
174174
}
175175
176176
template <typename T>
177-
void driver(size_t N)
177+
void driver(std::size_t N)
178178
{
179179
sycl::queue q;
180180
auto *a = sycl::malloc_shared<T>(N, q);
@@ -185,7 +185,7 @@ void driver(size_t N)
185185
186186
int main(int argc, const char **argv)
187187
{
188-
size_t N = 0;
188+
std::size_t N = 0;
189189
std::cout << "Enter problem size in N:\n";
190190
std::cin >> N;
191191
std::cout << "Executing with N = " << N << std::endl;
@@ -209,7 +209,7 @@ int main(int argc, const char **argv)
209209
struct TestQueueSubmitWithLocalAccessor : public ::testing::Test
210210
{
211211
std::ifstream spirvFile;
212-
size_t spirvFileSize_;
212+
std::size_t spirvFileSize_;
213213
std::vector<char> spirvBuffer_;
214214
DPCTLSyclQueueRef QRef = nullptr;
215215
DPCTLSyclKernelBundleRef KBRef = nullptr;
@@ -250,7 +250,7 @@ struct TestQueueSubmitWithLocalAccessor : public ::testing::Test
250250
struct TestQueueSubmitWithLocalAccessorFP64 : public ::testing::Test
251251
{
252252
std::ifstream spirvFile;
253-
size_t spirvFileSize_;
253+
std::size_t spirvFileSize_;
254254
std::vector<char> spirvBuffer_;
255255
DPCTLSyclDeviceRef DRef = nullptr;
256256
DPCTLSyclQueueRef QRef = nullptr;
@@ -289,58 +289,58 @@ struct TestQueueSubmitWithLocalAccessorFP64 : public ::testing::Test
289289

290290
TEST_F(TestQueueSubmitWithLocalAccessor, CheckForInt8)
291291
{
292-
submit_kernel<int8_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
293-
DPCTLKernelArgType::DPCTL_INT8_T,
294-
"_ZTS14SyclKernel_SLMIaE");
292+
submit_kernel<std::int8_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
293+
DPCTLKernelArgType::DPCTL_INT8_T,
294+
"_ZTS14SyclKernel_SLMIaE");
295295
}
296296

297297
TEST_F(TestQueueSubmitWithLocalAccessor, CheckForUInt8)
298298
{
299-
submit_kernel<uint8_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
300-
DPCTLKernelArgType::DPCTL_UINT8_T,
301-
"_ZTS14SyclKernel_SLMIhE");
299+
submit_kernel<std::uint8_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
300+
DPCTLKernelArgType::DPCTL_UINT8_T,
301+
"_ZTS14SyclKernel_SLMIhE");
302302
}
303303

304304
TEST_F(TestQueueSubmitWithLocalAccessor, CheckForInt16)
305305
{
306-
submit_kernel<int16_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
307-
DPCTLKernelArgType::DPCTL_INT16_T,
308-
"_ZTS14SyclKernel_SLMIsE");
306+
submit_kernel<std::int16_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
307+
DPCTLKernelArgType::DPCTL_INT16_T,
308+
"_ZTS14SyclKernel_SLMIsE");
309309
}
310310

311311
TEST_F(TestQueueSubmitWithLocalAccessor, CheckForUInt16)
312312
{
313-
submit_kernel<uint16_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
314-
DPCTLKernelArgType::DPCTL_UINT16_T,
315-
"_ZTS14SyclKernel_SLMItE");
313+
submit_kernel<std::uint16_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
314+
DPCTLKernelArgType::DPCTL_UINT16_T,
315+
"_ZTS14SyclKernel_SLMItE");
316316
}
317317

318318
TEST_F(TestQueueSubmitWithLocalAccessor, CheckForInt32)
319319
{
320-
submit_kernel<int32_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
321-
DPCTLKernelArgType::DPCTL_INT32_T,
322-
"_ZTS14SyclKernel_SLMIiE");
320+
submit_kernel<std::int32_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
321+
DPCTLKernelArgType::DPCTL_INT32_T,
322+
"_ZTS14SyclKernel_SLMIiE");
323323
}
324324

325325
TEST_F(TestQueueSubmitWithLocalAccessor, CheckForUInt32)
326326
{
327-
submit_kernel<uint32_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
328-
DPCTLKernelArgType::DPCTL_UINT32_T,
329-
"_ZTS14SyclKernel_SLMIjE");
327+
submit_kernel<std::uint32_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
328+
DPCTLKernelArgType::DPCTL_UINT32_T,
329+
"_ZTS14SyclKernel_SLMIjE");
330330
}
331331

332332
TEST_F(TestQueueSubmitWithLocalAccessor, CheckForInt64)
333333
{
334-
submit_kernel<int64_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
335-
DPCTLKernelArgType::DPCTL_INT64_T,
336-
"_ZTS14SyclKernel_SLMIlE");
334+
submit_kernel<std::int64_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
335+
DPCTLKernelArgType::DPCTL_INT64_T,
336+
"_ZTS14SyclKernel_SLMIlE");
337337
}
338338

339339
TEST_F(TestQueueSubmitWithLocalAccessor, CheckForUInt64)
340340
{
341-
submit_kernel<uint64_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
342-
DPCTLKernelArgType::DPCTL_UINT64_T,
343-
"_ZTS14SyclKernel_SLMImE");
341+
submit_kernel<std::uint64_t>(QRef, KBRef, spirvBuffer_, spirvFileSize_,
342+
DPCTLKernelArgType::DPCTL_UINT64_T,
343+
"_ZTS14SyclKernel_SLMImE");
344344
}
345345

346346
TEST_F(TestQueueSubmitWithLocalAccessor, CheckForFloat)
@@ -361,10 +361,10 @@ TEST_F(TestQueueSubmitWithLocalAccessorFP64, CheckForDouble)
361361

362362
TEST_F(TestQueueSubmitWithLocalAccessor, CheckForUnsupportedArgTy)
363363
{
364-
size_t gRange[] = {SIZE};
365-
size_t lRange[] = {SIZE / 10};
366-
size_t RANGE_NDIMS = 1;
367-
constexpr size_t NARGS = 2;
364+
std::size_t gRange[] = {SIZE};
365+
std::size_t lRange[] = {SIZE / 10};
366+
std::size_t RANGE_NDIMS = 1;
367+
constexpr std::size_t NARGS = 2;
368368

369369
auto la = MDLocalAccessor{1, DPCTL_UNSUPPORTED_KERNEL_ARG, SIZE / 10, 1, 1};
370370
auto kernel = DPCTLKernelBundle_GetKernel(KBRef, "_ZTS14SyclKernel_SLMImE");

0 commit comments

Comments
 (0)