Skip to content

Commit 9b84140

Browse files
Fix two unittests
1 parent d5b9385 commit 9b84140

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

sycl/unittests/handler/SetArgForLocalAccessor.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
#include <sycl/sycl.hpp>
1515

16+
#include <iostream>
17+
1618
// This test checks that we pass the correct buffer size value when setting
1719
// local_accessor as an argument through handler::set_arg to a kernel created
1820
// using OpenCL interoperability methods.
@@ -28,11 +30,28 @@ ur_result_t redefined_urKernelSetArgLocal(void *pParams) {
2830
return UR_RESULT_SUCCESS;
2931
}
3032

33+
inline ur_result_t redefined_urKernelGetInfo(void *pParams) {
34+
auto params = *static_cast<ur_kernel_get_info_params_t *>(pParams);
35+
constexpr char MockKernel[] = "MockKernel";
36+
if (*params.ppropName == UR_KERNEL_INFO_FUNCTION_NAME) {
37+
if (*params.ppPropValue) {
38+
assert(*params.ppropSize == sizeof(MockKernel));
39+
std::memcpy(*params.ppPropValue, MockKernel, sizeof(MockKernel));
40+
}
41+
if (*params.ppPropSizeRet)
42+
**params.ppPropSizeRet = sizeof(MockKernel);
43+
}
44+
return UR_RESULT_SUCCESS;
45+
}
46+
47+
3148
TEST(HandlerSetArg, LocalAccessor) {
3249
sycl::unittest::UrMock<> Mock;
3350
redefineMockForKernelInterop(Mock);
3451
mock::getCallbacks().set_replace_callback("urKernelSetArgLocal",
3552
&redefined_urKernelSetArgLocal);
53+
mock::getCallbacks().set_replace_callback("urKernelGetInfo",
54+
&redefined_urKernelGetInfo);
3655

3756
constexpr size_t Size = 128;
3857
sycl::queue Q;

sycl/unittests/thread_safety/InteropKernelEnqueue.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,27 @@ ur_result_t redefined_urKernelSetArgValue(void *pParams) {
3636
return UR_RESULT_SUCCESS;
3737
}
3838

39+
inline ur_result_t redefined_urKernelGetInfo(void *pParams) {
40+
auto params = *static_cast<ur_kernel_get_info_params_t *>(pParams);
41+
constexpr char MockKernel[] = "MockKernel";
42+
if (*params.ppropName == UR_KERNEL_INFO_FUNCTION_NAME) {
43+
if (*params.ppPropValue) {
44+
assert(*params.ppropSize == sizeof(MockKernel));
45+
std::memcpy(*params.ppPropValue, MockKernel, sizeof(MockKernel));
46+
}
47+
if (*params.ppPropSizeRet)
48+
**params.ppPropSizeRet = sizeof(MockKernel);
49+
}
50+
return UR_RESULT_SUCCESS;
51+
}
52+
3953
TEST(KernelEnqueue, InteropKernel) {
4054
unittest::UrMock<> Mock;
4155
redefineMockForKernelInterop(Mock);
4256
mock::getCallbacks().set_replace_callback("urKernelSetArgValue",
4357
&redefined_urKernelSetArgValue);
58+
mock::getCallbacks().set_replace_callback("urKernelGetInfo",
59+
&redefined_urKernelGetInfo);
4460

4561
platform Plt = sycl::platform();
4662
queue Q;

0 commit comments

Comments
 (0)