Skip to content

Commit 9709472

Browse files
committed
[SYCL] fix incorrect use of PI_CONTEXT_INFO_NUM_DEVICES
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent b31c3a2 commit 9709472

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sycl/source/detail/context_impl.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ context_impl::context_impl(cl_context ClContext, async_handler AsyncHandler)
4444

4545
m_Context = pi_cast<RT::PiContext>(ClContext);
4646
vector_class<RT::PiDevice> DeviceIds;
47-
size_t DevicesBuffer = 0;
47+
size_t DevicesNum = 0;
4848
// TODO catch an exception and put it to list of asynchronous exceptions
4949
PI_CALL(RT::piContextGetInfo(m_Context, PI_CONTEXT_INFO_NUM_DEVICES,
50-
0, nullptr, &DevicesBuffer));
51-
DeviceIds.resize(DevicesBuffer / sizeof(RT::PiDevice));
50+
sizeof(DevicesNum), &DevicesNum, nullptr));
51+
DeviceIds.resize(DevicesNum);
5252
// TODO catch an exception and put it to list of asynchronous exceptions
53-
PI_CALL(RT::piContextGetInfo(m_Context, PI_CONTEXT_INFO_DEVICES,
54-
DevicesBuffer, &DeviceIds[0], nullptr));
53+
PI_CALL(RT::piContextGetInfo(
54+
m_Context, PI_CONTEXT_INFO_DEVICES,
55+
sizeof(RT::PiDevice) * DevicesNum, &DeviceIds[0], nullptr));
5556

5657
for (auto Dev : DeviceIds) {
5758
m_Devices.emplace_back(

0 commit comments

Comments
 (0)