Skip to content

Commit f7ffbf4

Browse files
[SYCL] Make the mock plugin report cl_khr_il_program as supported (#6823)
To make build-log tests not depend on the binary type, this commit makes the mock plugin report that the cl_khr_il_program is supported. Together with adding PI_DEVICE_INFO_NAME to mock_piDeviceGetInfo, the corresponding redefinition from the build-log tests can be removed. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 728ff81 commit f7ffbf4

File tree

2 files changed

+12
-29
lines changed

2 files changed

+12
-29
lines changed

sycl/unittests/helpers/PiMockPlugin.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ inline pi_result mock_piDeviceGetInfo(pi_device device,
9191
size_t param_value_size,
9292
void *param_value,
9393
size_t *param_value_size_ret) {
94-
constexpr char MockSupportedExtensions[] = "cl_khr_fp64 cl_khr_fp16";
94+
constexpr char MockDeviceName[] = "Mock device";
95+
constexpr char MockSupportedExtensions[] =
96+
"cl_khr_fp64 cl_khr_fp16 cl_khr_il_program";
9597
switch (param_name) {
9698
case PI_DEVICE_INFO_TYPE: {
9799
// Act like any device is a GPU.
@@ -102,6 +104,15 @@ inline pi_result mock_piDeviceGetInfo(pi_device device,
102104
*param_value_size_ret = sizeof(PI_DEVICE_TYPE_GPU);
103105
return PI_SUCCESS;
104106
}
107+
case PI_DEVICE_INFO_NAME: {
108+
if (param_value) {
109+
assert(param_value_size == sizeof(MockDeviceName));
110+
std::memcpy(param_value, MockDeviceName, sizeof(MockDeviceName));
111+
}
112+
if (param_value_size_ret)
113+
*param_value_size_ret = sizeof(MockDeviceName);
114+
return PI_SUCCESS;
115+
}
105116
case PI_DEVICE_INFO_PARENT_DEVICE: {
106117
if (param_value)
107118
*static_cast<pi_device **>(param_value) = nullptr;

sycl/unittests/program_manager/BuildLog.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,37 +47,9 @@ static pi_result redefinedProgramGetBuildInfo(
4747
return PI_SUCCESS;
4848
}
4949

50-
static pi_result redefinedDeviceGetInfo(pi_device device,
51-
pi_device_info param_name,
52-
size_t param_value_size,
53-
void *param_value,
54-
size_t *param_value_size_ret) {
55-
if (param_name == PI_DEVICE_INFO_NAME) {
56-
const std::string name = "Test Device";
57-
if (param_value_size_ret) {
58-
*param_value_size_ret = name.size();
59-
}
60-
if (param_value) {
61-
auto *val = static_cast<char *>(param_value);
62-
strcpy(val, name.data());
63-
}
64-
}
65-
if (param_name == PI_DEVICE_INFO_COMPILER_AVAILABLE) {
66-
if (param_value_size_ret) {
67-
*param_value_size_ret = sizeof(cl_bool);
68-
}
69-
if (param_value) {
70-
auto *val = static_cast<cl_bool *>(param_value);
71-
*val = 1;
72-
}
73-
}
74-
return PI_SUCCESS;
75-
}
76-
7750
static void setupCommonTestAPIs(sycl::unittest::PiMock &Mock) {
7851
using namespace sycl::detail;
7952
Mock.redefine<PiApiKind::piProgramGetBuildInfo>(redefinedProgramGetBuildInfo);
80-
Mock.redefine<PiApiKind::piDeviceGetInfo>(redefinedDeviceGetInfo);
8153
}
8254

8355
TEST(BuildLog, OutputNothingOnLevel1) {

0 commit comments

Comments
 (0)