Skip to content

Commit f69dd09

Browse files
dm-vodopyanovcallumfareJaime Arteaga
authored
[SYCL][UR] Update Unified Runtime tag to support UR_DEVICE_INFO_IP_VERSION (#9873)
This should have been an obvious update of Unified Runtime tag to support UR_DEVICE_INFO_IP_VERSION, required in #9843 (just tag update, nothing else), but it also brought many API breaks caused by this patch: oneapi-src/unified-runtime#536. So the current PR updates our codebase in accordance with changed UR API. --------- Signed-off-by: Dmitry Vodopyanov <[email protected]> Co-authored-by: Callum Fare <[email protected]> Co-authored-by: Jaime Arteaga <[email protected]>
1 parent abeec11 commit f69dd09

File tree

9 files changed

+71
-52
lines changed

9 files changed

+71
-52
lines changed

sycl/plugins/unified_runtime/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if (NOT DEFINED UNIFIED_RUNTIME_LIBRARY OR NOT DEFINED UNIFIED_RUNTIME_INCLUDE_D
44
include(FetchContent)
55

66
set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
7-
set(UNIFIED_RUNTIME_TAG 4a9e53b0d7b15d9b0239864d13999f32e6c73bac)
7+
set(UNIFIED_RUNTIME_TAG 4136fbb19c37a8aa9d368559a738e2e7cc35033e)
88

99
message(STATUS "Will fetch Unified Runtime from ${UNIFIED_RUNTIME_REPO}")
1010
FetchContent_Declare(unified-runtime

sycl/plugins/unified_runtime/pi2ur.hpp

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -287,35 +287,34 @@ inline pi_result ur2piDeviceInfoValue(ur_device_info_t ParamName,
287287
return Value.convertBitSet<ur_device_affinity_domain_flag_t,
288288
pi_device_affinity_domain>(ConvertFunc);
289289
} else if (ParamName == UR_DEVICE_INFO_PARTITION_TYPE) {
290-
auto ConvertFunc = [](ur_device_partition_property_t UrValue) {
291-
switch (UrValue) {
292-
case UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN:
290+
auto ConvertFunc = [](ur_device_partition_t UrValue) {
291+
if (UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN == UrValue)
293292
return PI_DEVICE_PARTITION_BY_AFFINITY_DOMAIN;
294-
case UR_DEVICE_PARTITION_BY_CSLICE:
293+
else if (UR_DEVICE_PARTITION_BY_CSLICE == UrValue)
295294
return PI_EXT_INTEL_DEVICE_PARTITION_BY_CSLICE;
296-
case (ur_device_partition_property_t)
297-
UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE:
295+
else if ((ur_device_partition_t)
296+
UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE == UrValue)
298297
return (pi_device_partition_property)
299298
PI_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE;
300-
default:
301-
die("UR_DEVICE_INFO_PARTITION_TYPE: unhandled value");
302-
}
299+
die("UR_DEVICE_INFO_PARTITION_TYPE: unhandled value");
303300
};
304-
return Value.convertArray<ur_device_partition_property_t,
305-
pi_device_partition_property>(ConvertFunc);
306-
} else if (ParamName == UR_DEVICE_INFO_PARTITION_PROPERTIES) {
307-
auto ConvertFunc = [](ur_device_partition_property_t UrValue) {
301+
return Value
302+
.convertArray<ur_device_partition_t, pi_device_partition_property>(
303+
ConvertFunc);
304+
} else if (ParamName == UR_DEVICE_INFO_SUPPORTED_PARTITIONS) {
305+
auto ConvertFunc = [](ur_device_partition_t UrValue) {
308306
switch (UrValue) {
309307
case UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN:
310308
return PI_DEVICE_PARTITION_BY_AFFINITY_DOMAIN;
311309
case UR_DEVICE_PARTITION_BY_CSLICE:
312310
return PI_EXT_INTEL_DEVICE_PARTITION_BY_CSLICE;
313311
default:
314-
die("UR_DEVICE_INFO_PARTITION_PROPERTIES: unhandled value");
312+
die("UR_DEVICE_INFO_SUPPORTED_PARTITIONS: unhandled value");
315313
}
316314
};
317-
return Value.convertArray<ur_device_partition_property_t,
318-
pi_device_partition_property>(ConvertFunc);
315+
return Value
316+
.convertArray<ur_device_partition_t, pi_device_partition_property>(
317+
ConvertFunc);
319318
} else if (ParamName == UR_DEVICE_INFO_LOCAL_MEM_TYPE) {
320319
auto ConvertFunc = [](ur_device_local_mem_type_t UrValue) {
321320
switch (UrValue) {
@@ -774,7 +773,7 @@ inline pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
774773
InfoType = UR_DEVICE_INFO_REFERENCE_COUNT;
775774
break;
776775
case PI_DEVICE_INFO_PARTITION_PROPERTIES:
777-
InfoType = UR_DEVICE_INFO_PARTITION_PROPERTIES;
776+
InfoType = UR_DEVICE_INFO_SUPPORTED_PARTITIONS;
778777
break;
779778
case PI_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN:
780779
InfoType = UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN;
@@ -1081,7 +1080,7 @@ inline pi_result piDevicePartition(
10811080
if (!Properties || !Properties[0])
10821081
return PI_ERROR_INVALID_VALUE;
10831082

1084-
ur_device_partition_property_t Property;
1083+
ur_device_partition_t Property;
10851084
switch (Properties[0]) {
10861085
case PI_DEVICE_PARTITION_EQUALLY:
10871086
Property = UR_DEVICE_PARTITION_EQUALLY;
@@ -1121,12 +1120,20 @@ inline pi_result piDevicePartition(
11211120
// TODO: correctly terminate the UR properties, see:
11221121
// https://github.com/oneapi-src/unified-runtime/issues/183
11231122
//
1124-
ur_device_partition_property_t UrProperties[] = {
1125-
ur_device_partition_property_t(Property), Value, 0};
1123+
ur_device_partition_property_t UrProperty;
1124+
UrProperty.type = Property;
1125+
UrProperty.value.equally = Value;
1126+
1127+
ur_device_partition_properties_t UrProperties{
1128+
UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES,
1129+
nullptr,
1130+
&UrProperty,
1131+
1,
1132+
};
11261133

11271134
auto UrDevice = reinterpret_cast<ur_device_handle_t>(Device);
11281135
auto UrSubDevices = reinterpret_cast<ur_device_handle_t *>(SubDevices);
1129-
HANDLE_ERRORS(urDevicePartition(UrDevice, UrProperties, NumEntries,
1136+
HANDLE_ERRORS(urDevicePartition(UrDevice, &UrProperties, NumEntries,
11301137
UrSubDevices, NumSubDevices));
11311138
return PI_SUCCESS;
11321139
}
@@ -1911,6 +1918,8 @@ inline pi_result piextKernelSetArgMemObj(pi_kernel Kernel, pi_uint32 ArgIndex,
19111918
if (ArgValue)
19121919
UrMemory = reinterpret_cast<ur_mem_handle_t>(*ArgValue);
19131920

1921+
ur_kernel_arg_mem_obj_properties_t Properties{};
1922+
19141923
// We don't yet know the device where this kernel will next be run on.
19151924
// Thus we can't know the actual memory allocation that needs to be used.
19161925
// Remember the memory object being used as an argument for this kernel
@@ -1922,7 +1931,8 @@ inline pi_result piextKernelSetArgMemObj(pi_kernel Kernel, pi_uint32 ArgIndex,
19221931
//
19231932

19241933
ur_kernel_handle_t UrKernel = reinterpret_cast<ur_kernel_handle_t>(Kernel);
1925-
HANDLE_ERRORS(urKernelSetArgMemObj(UrKernel, ArgIndex, UrMemory));
1934+
HANDLE_ERRORS(
1935+
urKernelSetArgMemObj(UrKernel, ArgIndex, &Properties, UrMemory));
19261936
return PI_SUCCESS;
19271937
}
19281938

sycl/plugins/unified_runtime/ur/adapters/cuda/device.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
694694
case UR_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES: {
695695
return ReturnValue(0u);
696696
}
697-
case UR_DEVICE_INFO_PARTITION_PROPERTIES: {
697+
case UR_DEVICE_INFO_SUPPORTED_PARTITIONS: {
698698
return ReturnValue(static_cast<ur_device_partition_t>(0u));
699699
}
700700
case UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN: {
@@ -1023,7 +1023,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceRetain(ur_device_handle_t hDevice) {
10231023
}
10241024

10251025
UR_APIEXPORT ur_result_t UR_APICALL
1026-
urDevicePartition(ur_device_handle_t, const ur_device_partition_property_t *,
1026+
urDevicePartition(ur_device_handle_t, const ur_device_partition_properties_t *,
10271027
uint32_t, ur_device_handle_t *, uint32_t *) {
10281028
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
10291029
}

sycl/plugins/unified_runtime/ur/adapters/cuda/kernel.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgPointer(
295295
return UR_RESULT_SUCCESS;
296296
}
297297

298-
UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgMemObj(
299-
ur_kernel_handle_t hKernel, uint32_t argIndex, ur_mem_handle_t hArgValue) {
298+
UR_APIEXPORT ur_result_t UR_APICALL
299+
urKernelSetArgMemObj(ur_kernel_handle_t hKernel, uint32_t argIndex,
300+
const ur_kernel_arg_mem_obj_properties_t *Properties,
301+
ur_mem_handle_t hArgValue) {
300302

301303
UR_ASSERT(hKernel, UR_RESULT_ERROR_INVALID_NULL_HANDLE);
302304

sycl/plugins/unified_runtime/ur/adapters/cuda/ur_interface_loader.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable(
200200
if (UR_RESULT_SUCCESS != result) {
201201
return result;
202202
}
203-
pDdiTable->pfnGetLastResult = urGetLastResult;
204203
pDdiTable->pfnInit = urInit;
205204
pDdiTable->pfnTearDown = urTearDown;
206205
return UR_RESULT_SUCCESS;

sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_device.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
281281
}
282282
case UR_DEVICE_INFO_REFERENCE_COUNT:
283283
return ReturnValue(uint32_t{Device->RefCount.load()});
284-
case UR_DEVICE_INFO_PARTITION_PROPERTIES: {
284+
case UR_DEVICE_INFO_SUPPORTED_PARTITIONS: {
285285
// SYCL spec says: if this SYCL device cannot be partitioned into at least
286286
// two sub devices then the returned vector must be empty.
287287
auto Res = Device->Platform->populateDeviceCacheIfNeeded();
@@ -291,15 +291,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
291291

292292
uint32_t ZeSubDeviceCount = Device->SubDevices.size();
293293
if (ZeSubDeviceCount < 2) {
294-
return ReturnValue((ur_device_partition_property_t)0);
294+
return ReturnValue((ur_device_partition_t)0);
295295
}
296296
bool PartitionedByCSlice = Device->SubDevices[0]->isCCS();
297297

298298
auto ReturnHelper = [&](auto... Partitions) {
299299
struct {
300-
ur_device_partition_property_t Arr[sizeof...(Partitions) + 1];
301-
} PartitionProperties = {
302-
{Partitions..., ur_device_partition_property_t(0)}};
300+
ur_device_partition_t Arr[sizeof...(Partitions) + 1];
301+
} PartitionProperties = {{Partitions..., ur_device_partition_t(0)}};
303302
return ReturnValue(PartitionProperties);
304303
};
305304

@@ -324,23 +323,23 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
324323
case UR_DEVICE_INFO_PARTITION_TYPE: {
325324
// For root-device there is no partitioning to report.
326325
if (!Device->isSubDevice())
327-
return ReturnValue(ur_device_partition_property_t(0));
326+
return ReturnValue(ur_device_partition_t(0));
328327

329328
if (Device->isCCS()) {
330329
struct {
331330
ur_device_partition_property_t Arr[2];
332331
} PartitionProperties = {
333-
{UR_DEVICE_PARTITION_BY_CSLICE, ur_device_partition_property_t(0)}};
332+
{UR_DEVICE_PARTITION_BY_CSLICE, ur_device_partition_t(0)}};
334333
return ReturnValue(PartitionProperties);
335334
}
336335

337336
struct {
338337
ur_device_partition_property_t Arr[3];
339338
} PartitionProperties = {
340339
{UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN,
341-
(ur_device_partition_property_t)
340+
(ur_device_partition_t)
342341
UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE,
343-
ur_device_partition_property_t(0)}};
342+
ur_device_partition_t(0)}};
344343
return ReturnValue(PartitionProperties);
345344
}
346345

@@ -1088,9 +1087,8 @@ void ZeUSMImportExtension::doZeUSMRelease(ze_driver_handle_t DriverHandle,
10881087

10891088
UR_APIEXPORT ur_result_t UR_APICALL urDevicePartition(
10901089
ur_device_handle_t Device, ///< [in] handle of the device to partition.
1091-
const ur_device_partition_property_t
1092-
*Properties, ///< [in] null-terminated array of <$_device_partition_t
1093-
///< enum, value> pairs.
1090+
const ur_device_partition_properties_t
1091+
*Properties, ///< [in] Device partition properties.
10941092
uint32_t NumDevices, ///< [in] the number of sub-devices.
10951093
ur_device_handle_t
10961094
*OutDevices, ///< [out][optional][range(0, NumDevices)] array of handle
@@ -1102,13 +1100,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urDevicePartition(
11021100
///< according to the partitioning property.
11031101
) {
11041102
// Other partitioning ways are not supported by Level Zero
1105-
if (Properties[0] == UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN) {
1106-
if ((Properties[1] != UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE &&
1107-
Properties[1] != UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA)) {
1103+
if (Properties->pProperties->type == UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN) {
1104+
if ((Properties->pProperties->value.affinity_domain !=
1105+
UR_DEVICE_AFFINITY_DOMAIN_FLAG_NEXT_PARTITIONABLE &&
1106+
Properties->pProperties->value.affinity_domain !=
1107+
UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA)) {
11081108
return UR_RESULT_ERROR_INVALID_VALUE;
11091109
}
1110-
} else if (Properties[0] == UR_DEVICE_PARTITION_BY_CSLICE) {
1111-
if (Properties[1] != 0) {
1110+
} else if (Properties->pProperties->type == UR_DEVICE_PARTITION_BY_CSLICE) {
1111+
if (Properties->pProperties->value.affinity_domain != 0) {
11121112
return UR_RESULT_ERROR_INVALID_VALUE;
11131113
}
11141114
} else {
@@ -1132,13 +1132,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urDevicePartition(
11321132
// UR_L0_EXPOSE_CSLICE_IN_AFFINITY_PARTITIONING overrides that
11331133
// still expose CSlices in partitioning by affinity domain for compatibility
11341134
// reasons.
1135-
if (Properties[0] == UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN &&
1135+
if (Properties->pProperties->type ==
1136+
UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN &&
11361137
!ExposeCSliceInAffinityPartitioning) {
11371138
if (Device->isSubDevice()) {
11381139
return 0;
11391140
}
11401141
}
1141-
if (Properties[0] == UR_DEVICE_PARTITION_BY_CSLICE) {
1142+
if (Properties->pProperties->type == UR_DEVICE_PARTITION_BY_CSLICE) {
11421143
// Not a CSlice-based partitioning.
11431144
if (!Device->SubDevices[0]->isCCS()) {
11441145
return 0;

sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_kernel.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgSampler(
669669

670670
UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgMemObj(
671671
ur_kernel_handle_t Kernel, ///< [in] handle of the kernel object
672-
uint32_t ArgIndex, ///< [in] argument index in range [0, num args - 1]
672+
uint32_t ArgIndex, ///< [in] argument index in range [0, num args - 1]
673+
const ur_kernel_arg_mem_obj_properties_t
674+
*Properties, ///< [in][optional] pointer to Memory object properties.
673675
ur_mem_handle_t ArgValue ///< [in][optional] handle of Memory object.
674676
) {
677+
std::ignore = Properties;
678+
675679
std::scoped_lock<ur_shared_mutex> Guard(Kernel->Mutex);
676680
// The ArgValue may be a NULL pointer in which case a NULL value is used for
677681
// the kernel argument declared as a pointer to global or constant memory.

sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_level_zero_platform.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformCreateWithNativeHandle(
341341
return UR_RESULT_ERROR_INVALID_VALUE;
342342
}
343343

344-
UR_APIEXPORT ur_result_t UR_APICALL urGetLastResult(
344+
UR_APIEXPORT ur_result_t UR_APICALL urPlatformGetLastError(
345345
ur_platform_handle_t Platform, ///< [in] handle of the platform instance
346-
const char **Message ///< [out] pointer to a string containing adapter
347-
///< specific result in string representation.
346+
const char **Message, ///< [out] pointer to a C string where the adapter
347+
///< specific error message will be stored.
348+
int32_t *Error ///< [out] pointer to an integer where the adapter specific
349+
///< error code will be stored.
348350
) {
349351
std::ignore = Platform;
350352
std::ignore = Message;
353+
std::ignore = Error;
351354
urPrint("[UR][L0] %s function not implemented!\n", __FUNCTION__);
352355
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
353356
}

sycl/plugins/unified_runtime/ur/adapters/level_zero/ur_loader_interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable(
3232
}
3333

3434
pDdiTable->pfnInit = urInit;
35-
pDdiTable->pfnGetLastResult = urGetLastResult;
3635
pDdiTable->pfnTearDown = urTearDown;
3736

3837
return retVal;
@@ -183,6 +182,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPlatformProcAddrTable(
183182
pDdiTable->pfnCreateWithNativeHandle = urPlatformCreateWithNativeHandle;
184183
pDdiTable->pfnGetApiVersion = urPlatformGetApiVersion;
185184
pDdiTable->pfnGetBackendOption = urPlatformGetBackendOption;
185+
pDdiTable->pfnGetLastError = urPlatformGetLastError;
186186

187187
return retVal;
188188
}

0 commit comments

Comments
 (0)