Skip to content

Commit d494595

Browse files
authored
[SYCL] Add a built-in kernel test (#5046)
* [SYCL] Add a built-in kernel test - Check `device::get_info<info::device::built_in_kernel_ids>`. - Check that an attempt to get a kernel bundle with built-in kernels leads to an exception since they are not yet fully supported. The above functionality was added in #4996.
1 parent 7700edb commit d494595

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

sycl/unittests/kernel-and-program/DeviceInfo.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ struct TestCtx {
1919

2020
context &Ctx;
2121
bool UUIDInfoCalled = false;
22+
23+
std::string BuiltInKernels;
2224
};
2325
} // namespace
2426

@@ -31,6 +33,13 @@ static pi_result redefinedDeviceGetInfo(pi_device device,
3133
size_t *param_value_size_ret) {
3234
if (param_name == PI_DEVICE_INFO_UUID) {
3335
TestContext->UUIDInfoCalled = true;
36+
} else if (param_name == PI_DEVICE_INFO_BUILT_IN_KERNELS) {
37+
if (param_value_size_ret) {
38+
*param_value_size_ret = TestContext->BuiltInKernels.size() + 1;
39+
} else if (param_value) {
40+
char *dst = static_cast<char *>(param_value);
41+
dst[TestContext->BuiltInKernels.copy(dst, param_value_size)] = '\0';
42+
}
3443
}
3544

3645
return PI_SUCCESS;
@@ -85,3 +94,35 @@ TEST_F(DeviceInfoTest, GetDeviceUUID) {
8594
<< "Expect device UUID to be "
8695
<< "of 16 bytes";
8796
}
97+
98+
TEST_F(DeviceInfoTest, BuiltInKernelIDs) {
99+
if (Plt.is_host()) {
100+
return;
101+
}
102+
103+
context Ctx{Plt.get_devices()[0]};
104+
TestContext.reset(new TestCtx(Ctx));
105+
TestContext->BuiltInKernels = "Kernel0;Kernel1;Kernel2";
106+
107+
device Dev = Ctx.get_devices()[0];
108+
109+
auto ids = Dev.get_info<info::device::built_in_kernel_ids>();
110+
111+
ASSERT_EQ(ids.size(), 3u);
112+
EXPECT_STREQ(ids[0].get_name(), "Kernel0");
113+
EXPECT_STREQ(ids[1].get_name(), "Kernel1");
114+
EXPECT_STREQ(ids[2].get_name(), "Kernel2");
115+
116+
errc val = errc::success;
117+
std::string msg;
118+
try {
119+
get_kernel_bundle<bundle_state::executable>(Ctx, {Dev}, ids);
120+
} catch (sycl::exception &e) {
121+
val = errc(e.code().value());
122+
msg = e.what();
123+
}
124+
125+
EXPECT_EQ(val, errc::kernel_argument);
126+
EXPECT_EQ(
127+
msg, "Attempting to use a built-in kernel. They are not fully supported");
128+
}

0 commit comments

Comments
 (0)