Skip to content

Commit ea19360

Browse files
Added libsyclinterface/tests for DCPTLKernel_Copy and DPCTLKernelBundle_Copy
Also change commented out, or preprocessor disabled code for testing, implementing, or declaring DCPTLKernel_GetMaxSubGroupsSize since it is now supported in 2023 compiler.
1 parent 35f93a3 commit ea19360

File tree

4 files changed

+46
-9
lines changed

4 files changed

+46
-9
lines changed

libsyclinterface/include/dpctl_sycl_kernel_interface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#pragma once
2828

29+
#include "Config/dpctl_config.h"
2930
#include "Support/DllExport.h"
3031
#include "Support/ExternC.h"
3132
#include "Support/MemOwnershipAttrs.h"
@@ -129,7 +130,7 @@ DPCTL_API
129130
uint32_t
130131
DPCTLKernel_GetMaxNumSubGroups(__dpctl_keep const DPCTLSyclKernelRef KRef);
131132

132-
#if 0
133+
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_2023_SWITCHOVER
133134
/*!
134135
* !brief Wrapper around
135136
* `kernel::get_info<info::kernel_device_specific::max_sub_group_size>()`.

libsyclinterface/source/dpctl_sycl_kernel_interface.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
//===----------------------------------------------------------------------===//
2626

2727
#include "dpctl_sycl_kernel_interface.h"
28+
#include "Config/dpctl_config.h"
2829
#include "dpctl_error_handlers.h"
2930
#include "dpctl_string_utils.hpp"
3031
#include "dpctl_sycl_type_casters.hpp"
@@ -160,7 +161,7 @@ DPCTLKernel_GetMaxNumSubGroups(__dpctl_keep const DPCTLSyclKernelRef KRef)
160161
return static_cast<uint32_t>(v);
161162
}
162163

163-
#if 0
164+
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_2023_SWITCHOVER
164165
// commented out due to bug in DPC++ runtime, get_info for max_sub_group_size
165166
// exported by libsycl has different, not SPEC-compliant signature
166167
uint32_t
@@ -179,8 +180,9 @@ DPCTLKernel_GetMaxSubGroupSize(__dpctl_keep const DPCTLSyclKernelRef KRef)
179180
__FILE__, __func__, __LINE__);
180181
return 0;
181182
}
182-
auto v = sycl_kern
183-
->get_info<info::kernel_device_specific::max_sub_group_size>(devs[0]);
183+
auto v =
184+
sycl_kern->get_info<info::kernel_device_specific::max_sub_group_size>(
185+
devs[0]);
184186
return v;
185187
}
186188
#endif

libsyclinterface/tests/test_sycl_kernel_bundle_interface.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,27 @@ TEST_P(TestDPCTLSyclKernelBundleInterface, ChkCreateFromSpirv)
102102
ASSERT_FALSE(DPCTLKernelBundle_HasKernel(KBRef, nullptr));
103103
}
104104

105+
TEST_P(TestDPCTLSyclKernelBundleInterface, ChkCopy)
106+
{
107+
DPCTLSyclKernelBundleRef Copied_KBRef = nullptr;
108+
ASSERT_TRUE(KBRef != nullptr);
109+
110+
EXPECT_NO_FATAL_FAILURE(Copied_KBRef = DPCTLKernelBundle_Copy(KBRef));
111+
ASSERT_TRUE(DPCTLKernelBundle_HasKernel(Copied_KBRef, "add"));
112+
ASSERT_TRUE(DPCTLKernelBundle_HasKernel(Copied_KBRef, "axpy"));
113+
114+
EXPECT_NO_FATAL_FAILURE(DPCTLKernelBundle_Delete(Copied_KBRef));
115+
}
116+
117+
TEST_P(TestDPCTLSyclKernelBundleInterface, ChkCopyNullArgument)
118+
{
119+
DPCTLSyclKernelBundleRef Null_KBRef = nullptr;
120+
DPCTLSyclKernelBundleRef Copied_KBRef = nullptr;
121+
122+
EXPECT_NO_FATAL_FAILURE(Copied_KBRef = DPCTLKernelBundle_Copy(Null_KBRef));
123+
ASSERT_TRUE(Copied_KBRef == nullptr);
124+
}
125+
105126
TEST_P(TestDPCTLSyclKernelBundleInterface, ChkCreateFromSpirvNull)
106127
{
107128
DPCTLSyclContextRef Null_CRef = nullptr;

libsyclinterface/tests/test_sycl_kernel_interface.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
///
2525
//===----------------------------------------------------------------------===//
2626

27+
#include "Config/dpctl_config.h"
2728
#include "dpctl_sycl_context_interface.h"
2829
#include "dpctl_sycl_device_interface.h"
2930
#include "dpctl_sycl_device_selector_interface.h"
@@ -99,11 +100,18 @@ struct TestDPCTLSyclKernelInterface
99100

100101
TEST_P(TestDPCTLSyclKernelInterface, CheckGetNumArgs)
101102
{
102-
103103
ASSERT_EQ(DPCTLKernel_GetNumArgs(AddKRef), 3ul);
104104
ASSERT_EQ(DPCTLKernel_GetNumArgs(AxpyKRef), 4ul);
105105
}
106106

107+
TEST_P(TestDPCTLSyclKernelInterface, CheckCopy)
108+
{
109+
DPCTLSyclKernelRef Copied_KRef = nullptr;
110+
EXPECT_NO_FATAL_FAILURE(Copied_KRef = DPCTLKernel_Copy(AddKRef));
111+
ASSERT_EQ(DPCTLKernel_GetNumArgs(Copied_KRef), 3ul);
112+
EXPECT_NO_FATAL_FAILURE(DPCTLKernel_Delete(Copied_KRef));
113+
}
114+
107115
TEST_P(TestDPCTLSyclKernelInterface, CheckGetWorkGroupSize)
108116
{
109117

@@ -159,7 +167,7 @@ TEST_P(TestDPCTLSyclKernelInterface, CheckGetMaxNumSubGroups)
159167
ASSERT_TRUE(axpy_mnsg != 0);
160168
}
161169

162-
/*
170+
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_2023_SWITCHOVER
163171
TEST_P(TestDPCTLSyclKernelInterface, CheckGetMaxSubGroupSize)
164172
{
165173

@@ -172,7 +180,7 @@ TEST_P(TestDPCTLSyclKernelInterface, CheckGetMaxSubGroupSize)
172180
ASSERT_TRUE(add_msg_sz != 0);
173181
ASSERT_TRUE(axpy_msg_sz != 0);
174182
}
175-
*/
183+
#endif
176184

177185
TEST_P(TestDPCTLSyclKernelInterface, CheckGetCompileNumSubGroups)
178186
{
@@ -215,6 +223,11 @@ TEST_F(TestDPCTLSyclKernelNullArgs, CheckNumArgsNullKRef)
215223
ASSERT_EQ(DPCTLKernel_GetNumArgs(Null_KRef), -1);
216224
}
217225

226+
TEST_F(TestDPCTLSyclKernelNullArgs, CheckCopyNullKRef)
227+
{
228+
ASSERT_TRUE(DPCTLKernel_Copy(Null_KRef) == nullptr);
229+
}
230+
218231
TEST_F(TestDPCTLSyclKernelNullArgs, CheckGetWorkGroupsSizeNullKRef)
219232
{
220233
DPCTLSyclKernelRef NullKRef = nullptr;
@@ -244,14 +257,14 @@ TEST_F(TestDPCTLSyclKernelNullArgs, CheckGetMaxNumSubGroupsNullKRef)
244257
ASSERT_EQ(DPCTLKernel_GetMaxNumSubGroups(NullKRef), 0);
245258
}
246259

247-
/*
260+
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_2023_SWITCHOVER
248261
TEST_F(TestDPCTLSyclKernelNullArgs, CheckGetMaxSubGroupSizeNullKRef)
249262
{
250263
DPCTLSyclKernelRef NullKRef = nullptr;
251264

252265
ASSERT_EQ(DPCTLKernel_GetMaxSubGroupSize(NullKRef), 0);
253266
}
254-
*/
267+
#endif
255268

256269
TEST_F(TestDPCTLSyclKernelNullArgs, CheckGetCompileNumSubGroupsNullKRef)
257270
{

0 commit comments

Comments
 (0)