Skip to content

Commit cc03176

Browse files
[SYCL] Fix unittests on MSVC (intel#6805)
This commit makes two changes: * Fixes a cast of incompatible size in the PI mock plugin that caused a warning on MSVC. * Changes the definition of the captureless lambda function in the RedefineAPI PiMock unittest to avoid MSVC considering it equal to the function defined by the PI mock plugin. Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
1 parent 832161b commit cc03176

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

sycl/unittests/pi/PiMock.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@ TEST(PiMockTest, RedefineAPI) {
8080

8181
// Pass a captureless lambda
8282
auto *OldFuncPtr = Table.piProgramRetain;
83-
Mock.redefine<detail::PiApiKind::piProgramRetain>(
84-
[](pi_program) -> pi_result { return PI_SUCCESS; });
83+
auto Lambda = [](pi_program) -> pi_result {
84+
return PI_ERROR_INVALID_PROGRAM;
85+
};
86+
EXPECT_FALSE(OldFuncPtr == Lambda)
87+
<< "Lambda is the same as the existing function.";
88+
Mock.redefine<detail::PiApiKind::piProgramRetain>(Lambda);
8589
EXPECT_FALSE(Table.piProgramRetain == OldFuncPtr)
8690
<< "Passing a lambda didn't change the function table entry";
8791
ASSERT_FALSE(Table.piProgramRetain == nullptr)

sycl/unittests/queue/DeviceCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pi_result redefinedDevicePartition(
6868
pi_device device, const pi_device_partition_property *properties,
6969
pi_uint32 num_devices, pi_device *out_devices, pi_uint32 *out_num_devices) {
7070
if (out_devices) {
71-
for (pi_uint32 I = 0; I < num_devices; ++I) {
71+
for (size_t I = 0; I < num_devices; ++I) {
7272
out_devices[I] = reinterpret_cast<pi_device>(1000 + I);
7373
}
7474
}

0 commit comments

Comments
 (0)