Skip to content

Commit ed02bea

Browse files
authored
Merge pull request #1990 from IntelPython/clean-up-test_sycl_queue_submit_local_accessor_arg.cpp
Clean up of test_sycl_queue_submit_local_accessor_arg.cpp
2 parents a9bba0b + b056d66 commit ed02bea

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

libsyclinterface/tests/test_sycl_queue_submit_local_accessor_arg.cpp

+20-20
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@
3737

3838
#include <filesystem>
3939
#include <fstream>
40+
#include <utility>
41+
4042
#include <gtest/gtest.h>
4143
#include <sycl/sycl.hpp>
42-
#include <utility>
4344

4445
namespace
4546
{
46-
constexpr std::size_t SIZE = 100;
47+
constexpr std::size_t SIZE = 320;
48+
49+
static_assert(SIZE % 10 == 0);
4750

4851
using namespace dpctl::syclinterface;
4952

@@ -69,11 +72,13 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
6972
a_ptr[i] = 0;
7073
}
7174

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};
7378

7479
// Create kernel args for vector_add
7580
std::size_t gRange[] = {SIZE};
76-
std::size_t lRange[] = {SIZE / 10};
81+
std::size_t lRange[] = {lws};
7782
void *args_1d[NARGS] = {unwrap<void>(a), (void *)&la1};
7883
DPCTLKernelArgType addKernelArgTypes[] = {DPCTL_VOID_PTR,
7984
DPCTL_LOCAL_ACCESSOR};
@@ -84,7 +89,7 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
8489
ASSERT_TRUE(E1Ref != nullptr);
8590

8691
DPCTLSyclEventRef DepEv1[] = {E1Ref};
87-
auto la2 = MDLocalAccessor{2, kernelArgTy, SIZE / 10, 1, 1};
92+
auto la2 = MDLocalAccessor{2, kernelArgTy, lws, 1, 1};
8893
void *args_2d[NARGS] = {unwrap<void>(a), (void *)&la2};
8994

9095
DPCTLSyclEventRef E2Ref =
@@ -93,7 +98,7 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
9398
ASSERT_TRUE(E2Ref != nullptr);
9499

95100
DPCTLSyclEventRef DepEv2[] = {E1Ref, E2Ref};
96-
auto la3 = MDLocalAccessor{3, kernelArgTy, SIZE / 10, 1, 1};
101+
auto la3 = MDLocalAccessor{3, kernelArgTy, lws, 1, 1};
97102
void *args_3d[NARGS] = {unwrap<void>(a), (void *)&la3};
98103

99104
DPCTLSyclEventRef E3Ref =
@@ -103,10 +108,7 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
103108

104109
DPCTLEvent_Wait(E3Ref);
105110

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));
110112

111113
// clean ups
112114
DPCTLEvent_Delete(E1Ref);
@@ -133,9 +135,9 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
133135
// figure which SPV file contains the kernels, use `spirv-dis` from the
134136
// spirv-tools package to translate the SPV binary format to a human-readable
135137
// textual format.
136-
#include <CL/sycl.hpp>
137138
#include <iostream>
138139
#include <sstream>
140+
#include <sycl/sycl.hpp>
139141
140142
template <typename T>
141143
class SyclKernel_SLM
@@ -195,7 +197,7 @@ int main(int argc, const char **argv)
195197
driver<int8_t>(N);
196198
driver<uint8_t>(N);
197199
driver<int16_t>(N);
198-
driver<int32_t>(N);
200+
driver<uint16_t>(N);
199201
driver<int32_t>(N);
200202
driver<uint32_t>(N);
201203
driver<int64_t>(N);
@@ -220,11 +222,10 @@ struct TestQueueSubmitWithLocalAccessor : public ::testing::Test
220222
{
221223
DPCTLSyclDeviceSelectorRef DSRef = nullptr;
222224
DPCTLSyclDeviceRef DRef = nullptr;
225+
const char *test_spv_fn = "./local_accessor_kernel_inttys_fp32.spv";
223226

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);
228229
spirvBuffer_.reserve(spirvFileSize_);
229230
spirvFile.seekg(0, std::ios::beg);
230231
spirvFile.read(spirvBuffer_.data(), spirvFileSize_);
@@ -261,11 +262,10 @@ struct TestQueueSubmitWithLocalAccessorFP64 : public ::testing::Test
261262
TestQueueSubmitWithLocalAccessorFP64()
262263
{
263264
DPCTLSyclDeviceSelectorRef DSRef = nullptr;
265+
const char *test_spv_fn = "./local_accessor_kernel_fp64.spv";
264266

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);
269269
spirvBuffer_.reserve(spirvFileSize_);
270270
spirvFile.seekg(0, std::ios::beg);
271271
spirvFile.read(spirvBuffer_.data(), spirvFileSize_);

0 commit comments

Comments
 (0)