Skip to content

Commit f870412

Browse files
authored
[UR] Add UNSUPPORTED_FEATURE return for urDeviceGetGlobalTimestamps (#17389)
Similar to urContextSetExtendedDeleter this entry point isn't supported by devices that report a CL version < 2.1. We aren't going to support versions this old forever, so it's simplest to just allow the UNSUPPORTED_FEATURE return for now. Also cleans up some weird api usage I noticed in a fixture along the way. Fixes oneapi-src/unified-runtime#2633
1 parent 58e1410 commit f870412

File tree

8 files changed

+29
-20
lines changed

8 files changed

+29
-20
lines changed

unified-runtime/include/ur_api.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2790,6 +2790,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceCreateWithNativeHandle(
27902790
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
27912791
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
27922792
/// + `NULL == hDevice`
2793+
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
2794+
/// + If the adapter has no means to support the operation.
27932795
UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetGlobalTimestamps(
27942796
/// [in] handle of the device instance
27952797
ur_device_handle_t hDevice,
@@ -3170,6 +3172,8 @@ typedef void (*ur_context_extended_deleter_t)(
31703172
/// + `NULL == hContext`
31713173
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
31723174
/// + `NULL == pfnDeleter`
3175+
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
3176+
/// + If the adapter has no means to support the operation.
31733177
UR_APIEXPORT ur_result_t UR_APICALL urContextSetExtendedDeleter(
31743178
/// [in] handle of the context.
31753179
ur_context_handle_t hContext,

unified-runtime/scripts/core/context.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,6 @@ params:
269269
- type: void*
270270
name: pUserData
271271
desc: "[in][out][optional] pointer to data to be passed to callback."
272+
returns:
273+
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
274+
- "If the adapter has no means to support the operation."

unified-runtime/scripts/core/device.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,9 @@ params:
864864
desc: |
865865
[out][optional] pointer to the Host's global timestamp that
866866
correlates with the Device's global timestamp value
867+
returns:
868+
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
869+
- "If the adapter has no means to support the operation."
867870
--- #--------------------------------------------------------------------------
868871
type: enum
869872
desc: "Memory order capabilities"

unified-runtime/source/adapters/opencl/device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetGlobalTimestamps(
17231723
RetErr = cl_adapter::getPlatformVersion(Platform, PlatVer);
17241724

17251725
if (PlatVer < oclv::V2_1 || DevVer < oclv::V2_1) {
1726-
return UR_RESULT_ERROR_INVALID_OPERATION;
1726+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
17271727
}
17281728

17291729
if (pDeviceTimestamp) {

unified-runtime/source/loader/ur_libapi.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,8 @@ ur_result_t UR_APICALL urDeviceCreateWithNativeHandle(
11791179
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
11801180
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
11811181
/// + `NULL == hDevice`
1182+
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
1183+
/// + If the adapter has no means to support the operation.
11821184
ur_result_t UR_APICALL urDeviceGetGlobalTimestamps(
11831185
/// [in] handle of the device instance
11841186
ur_device_handle_t hDevice,
@@ -1475,6 +1477,8 @@ ur_result_t UR_APICALL urContextCreateWithNativeHandle(
14751477
/// + `NULL == hContext`
14761478
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
14771479
/// + `NULL == pfnDeleter`
1480+
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
1481+
/// + If the adapter has no means to support the operation.
14781482
ur_result_t UR_APICALL urContextSetExtendedDeleter(
14791483
/// [in] handle of the context.
14801484
ur_context_handle_t hContext,

unified-runtime/source/ur_api.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,8 @@ ur_result_t UR_APICALL urDeviceCreateWithNativeHandle(
10531053
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
10541054
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
10551055
/// + `NULL == hDevice`
1056+
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
1057+
/// + If the adapter has no means to support the operation.
10561058
ur_result_t UR_APICALL urDeviceGetGlobalTimestamps(
10571059
/// [in] handle of the device instance
10581060
ur_device_handle_t hDevice,
@@ -1310,6 +1312,8 @@ ur_result_t UR_APICALL urContextCreateWithNativeHandle(
13101312
/// + `NULL == hContext`
13111313
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
13121314
/// + `NULL == pfnDeleter`
1315+
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
1316+
/// + If the adapter has no means to support the operation.
13131317
ur_result_t UR_APICALL urContextSetExtendedDeleter(
13141318
/// [in] handle of the context.
13151319
ur_context_handle_t hContext,

unified-runtime/test/conformance/device/urDeviceGetGlobalTimestamps.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,39 +31,32 @@ using urDeviceGetGlobalTimestampTest = uur::urDeviceTest;
3131
UUR_INSTANTIATE_DEVICE_TEST_SUITE(urDeviceGetGlobalTimestampTest);
3232

3333
TEST_P(urDeviceGetGlobalTimestampTest, Success) {
34-
// See https://github.com/oneapi-src/unified-runtime/issues/2633
35-
UUR_KNOWN_FAILURE_ON(uur::OpenCL{"Intel(R) FPGA"});
36-
3734
uint64_t device_time = 0;
3835
uint64_t host_time = 0;
39-
ASSERT_SUCCESS(urDeviceGetGlobalTimestamps(device, &device_time, &host_time));
36+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
37+
urDeviceGetGlobalTimestamps(device, &device_time, &host_time));
4038
ASSERT_NE(device_time, 0);
4139
ASSERT_NE(host_time, 0);
4240
}
4341

4442
TEST_P(urDeviceGetGlobalTimestampTest, SuccessHostTimer) {
45-
UUR_KNOWN_FAILURE_ON(uur::OpenCL{"Intel(R) FPGA"});
46-
4743
uint64_t host_time = 0;
48-
ASSERT_SUCCESS(urDeviceGetGlobalTimestamps(device, nullptr, &host_time));
44+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
45+
urDeviceGetGlobalTimestamps(device, nullptr, &host_time));
4946
ASSERT_NE(host_time, 0);
5047
}
5148

5249
TEST_P(urDeviceGetGlobalTimestampTest, SuccessNoTimers) {
53-
UUR_KNOWN_FAILURE_ON(uur::OpenCL{"Intel(R) FPGA"});
54-
55-
ASSERT_SUCCESS(urDeviceGetGlobalTimestamps(device, nullptr, nullptr));
50+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
51+
urDeviceGetGlobalTimestamps(device, nullptr, nullptr));
5652
}
5753

5854
TEST_P(urDeviceGetGlobalTimestampTest, SuccessSynchronizedTime) {
59-
// Returns `UR_RESULT_ERROR_INVALID_OPERATION`
60-
UUR_KNOWN_FAILURE_ON(uur::OpenCL{"Intel(R) FPGA"});
61-
6255
uint64_t deviceStartTime = 0, deviceEndTime = 0;
6356
uint64_t hostStartTime = 0, hostEndTime = 0;
6457
uint64_t hostOnlyStartTime = 0, hostOnlyEndTime = 0;
6558

66-
ASSERT_SUCCESS(
59+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
6760
urDeviceGetGlobalTimestamps(device, &deviceStartTime, &hostStartTime));
6861
ASSERT_SUCCESS(
6962
urDeviceGetGlobalTimestamps(device, nullptr, &hostOnlyStartTime));

unified-runtime/test/conformance/enqueue/urEnqueueUSMFill2D.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@ struct urEnqueueUSMFill2DTestWithParam
3737
UUR_RETURN_ON_FATAL_FAILURE(urQueueTestWithParam::SetUp());
3838

3939
bool memfill2d_support = false;
40-
[[maybe_unused]] ur_result_t result = urContextGetInfo(
41-
context, UR_CONTEXT_INFO_USM_FILL2D_SUPPORT, sizeof(memfill2d_support),
42-
&memfill2d_support, nullptr);
43-
ASSERT_TRUE(result == UR_RESULT_SUCCESS ||
44-
result == UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION);
40+
ASSERT_SUCCESS(urContextGetInfo(context, UR_CONTEXT_INFO_USM_FILL2D_SUPPORT,
41+
sizeof(memfill2d_support),
42+
&memfill2d_support, nullptr));
4543
if (!memfill2d_support) {
4644
GTEST_SKIP() << "2D USM mem fill is not supported";
4745
}

0 commit comments

Comments
 (0)