Skip to content

Commit 817b3eb

Browse files
committed
[UR] Handle INVALID_VALUE in OCL urPlatformGet
Pre-commit MR for: oneapi-src/unified-runtime#2227 As there is a spec change in UR, adapter handling code has been updated - it no longer tries to populate the platform list if it would be empty (otherwise both "destination" pointers could be null, which is now illegal). This fixes a bug Intel tracks internally as URT-831
1 parent 573470f commit 817b3eb

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

sycl/cmake/modules/FetchUnifiedRuntime.cmake

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,24 @@ if(SYCL_UR_USE_FETCH_CONTENT)
116116
CACHE PATH "Path to external '${name}' adapter source dir" FORCE)
117117
endfunction()
118118

119-
set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
120-
# commit c742ca49efb12380a35b8b0b467e6577ab8174ce
121-
# Merge: 3a8bf2c5 504d3b63
122-
# Author: Kenneth Benzie (Benie) <[email protected]>
123-
# Date: Mon Oct 21 11:55:23 2024 +0100
124-
# Merge pull request #2131 from Bensuo/ben/command-handle-fix
125-
# [EXP][CMDBUF] Make command handle behaviour consistent
126-
set(UNIFIED_RUNTIME_TAG c742ca49efb12380a35b8b0b467e6577ab8174ce)
119+
set(UNIFIED_RUNTIME_REPO "https://github.com/RossBrunton/unified-runtime.git")
120+
# commit 9989d97bceeabd1e83949ff3c86ba34af94907d3
121+
# Author: Ross Brunton <[email protected]>
122+
# Date: Mon Oct 21 16:35:45 2024 +0100
123+
# Handle INVALID_VALUE in OCL urPlatformGet
124+
#
125+
# The OpenCL function clGetPlatformIDs may return CL_INVALID_VALUE, which
126+
# needs to be converted into appropriate UR returns as follows:
127+
#
128+
# * If a non-null platforms list is provided, but the number of elements
129+
# in it is 0, then return UR_RESULT_ERROR_INVALID_SIZE.
130+
# * If neither platform or sizes outputs are provided, then return
131+
# UR_RESULT_ERROR_INVALID_VALUE.
132+
#
133+
# This required a spec change.
134+
#
135+
# This fixes a bug Intel are tracking internally as URT-831.
136+
set(UNIFIED_RUNTIME_TAG 9989d97bceeabd1e83949ff3c86ba34af94907d3)
127137

128138
set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES")
129139
# Due to the use of dependentloadflag and no installer for UMF and hwloc we need

sycl/source/detail/adapter.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ class Adapter {
100100
uint32_t platformCount = 0;
101101
call<UrApiKind::urPlatformGet>(&MAdapter, 1, 0, nullptr, &platformCount);
102102
UrPlatforms.resize(platformCount);
103-
call<UrApiKind::urPlatformGet>(&MAdapter, 1, platformCount,
104-
UrPlatforms.data(), nullptr);
103+
if (platformCount) {
104+
call<UrApiKind::urPlatformGet>(&MAdapter, 1, platformCount,
105+
UrPlatforms.data(), nullptr);
106+
}
105107
// We need one entry in this per platform
106108
LastDeviceIds.resize(platformCount);
107109
});

0 commit comments

Comments
 (0)