Skip to content

Commit a8e4955

Browse files
authored
Fix device CTS tests (#834)
1 parent 04bd987 commit a8e4955

File tree

9 files changed

+39
-15
lines changed

9 files changed

+39
-15
lines changed

include/ur_api.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,14 +1301,16 @@ typedef enum ur_device_type_t {
13011301
/// + `NULL == hPlatform`
13021302
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
13031303
/// + `::UR_DEVICE_TYPE_VPU < DeviceType`
1304+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1305+
/// + `NumEntries == 0 && phDevices != NULL`
13041306
/// - ::UR_RESULT_ERROR_INVALID_VALUE
13051307
UR_APIEXPORT ur_result_t UR_APICALL
13061308
urDeviceGet(
13071309
ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance
13081310
ur_device_type_t DeviceType, ///< [in] the type of the devices.
13091311
uint32_t NumEntries, ///< [in] the number of devices to be added to phDevices.
1310-
///< If phDevices in not NULL then NumEntries should be greater than zero,
1311-
///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE,
1312+
///< If phDevices is not NULL, then NumEntries should be greater than zero.
1313+
///< Otherwise ::UR_RESULT_ERROR_INVALID_SIZE
13121314
///< will be returned.
13131315
ur_device_handle_t *phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices.
13141316
///< If NumEntries is less than the number of devices available, then

scripts/core/device.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ params:
131131
name: NumEntries
132132
desc: |
133133
[in] the number of devices to be added to phDevices.
134-
If phDevices in not NULL then NumEntries should be greater than zero, otherwise $X_RESULT_ERROR_INVALID_VALUE,
134+
If phDevices is not NULL, then NumEntries should be greater than zero. Otherwise $X_RESULT_ERROR_INVALID_SIZE
135135
will be returned.
136136
- type: "$x_device_handle_t*"
137137
name: phDevices
@@ -144,6 +144,8 @@ params:
144144
[out][optional] pointer to the number of devices.
145145
pNumDevices will be updated with the total number of devices available.
146146
returns:
147+
- $X_RESULT_ERROR_INVALID_SIZE:
148+
- "`NumEntries == 0 && phDevices != NULL`"
147149
- $X_RESULT_ERROR_INVALID_VALUE
148150
--- #--------------------------------------------------------------------------
149151
type: enum

source/adapters/null/ur_nullddi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet(
320320
ur_device_type_t DeviceType, ///< [in] the type of the devices.
321321
uint32_t
322322
NumEntries, ///< [in] the number of devices to be added to phDevices.
323-
///< If phDevices in not NULL then NumEntries should be greater than zero,
324-
///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE,
323+
///< If phDevices is not NULL, then NumEntries should be greater than zero.
324+
///< Otherwise ::UR_RESULT_ERROR_INVALID_SIZE
325325
///< will be returned.
326326
ur_device_handle_t *
327327
phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices.

source/loader/layers/tracing/ur_trcddi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet(
357357
ur_device_type_t DeviceType, ///< [in] the type of the devices.
358358
uint32_t
359359
NumEntries, ///< [in] the number of devices to be added to phDevices.
360-
///< If phDevices in not NULL then NumEntries should be greater than zero,
361-
///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE,
360+
///< If phDevices is not NULL, then NumEntries should be greater than zero.
361+
///< Otherwise ::UR_RESULT_ERROR_INVALID_SIZE
362362
///< will be returned.
363363
ur_device_handle_t *
364364
phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices.

source/loader/layers/validation/ur_valddi.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet(
398398
ur_device_type_t DeviceType, ///< [in] the type of the devices.
399399
uint32_t
400400
NumEntries, ///< [in] the number of devices to be added to phDevices.
401-
///< If phDevices in not NULL then NumEntries should be greater than zero,
402-
///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE,
401+
///< If phDevices is not NULL, then NumEntries should be greater than zero.
402+
///< Otherwise ::UR_RESULT_ERROR_INVALID_SIZE
403403
///< will be returned.
404404
ur_device_handle_t *
405405
phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices.
@@ -422,6 +422,10 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet(
422422
if (UR_DEVICE_TYPE_VPU < DeviceType) {
423423
return UR_RESULT_ERROR_INVALID_ENUMERATION;
424424
}
425+
426+
if (NumEntries == 0 && phDevices != NULL) {
427+
return UR_RESULT_ERROR_INVALID_SIZE;
428+
}
425429
}
426430

427431
ur_result_t result =

source/loader/ur_ldrddi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet(
440440
ur_device_type_t DeviceType, ///< [in] the type of the devices.
441441
uint32_t
442442
NumEntries, ///< [in] the number of devices to be added to phDevices.
443-
///< If phDevices in not NULL then NumEntries should be greater than zero,
444-
///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE,
443+
///< If phDevices is not NULL, then NumEntries should be greater than zero.
444+
///< Otherwise ::UR_RESULT_ERROR_INVALID_SIZE
445445
///< will be returned.
446446
ur_device_handle_t *
447447
phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices.

source/loader/ur_libapi.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,14 +712,16 @@ ur_result_t UR_APICALL urPlatformGetBackendOption(
712712
/// + `NULL == hPlatform`
713713
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
714714
/// + `::UR_DEVICE_TYPE_VPU < DeviceType`
715+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
716+
/// + `NumEntries == 0 && phDevices != NULL`
715717
/// - ::UR_RESULT_ERROR_INVALID_VALUE
716718
ur_result_t UR_APICALL urDeviceGet(
717719
ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance
718720
ur_device_type_t DeviceType, ///< [in] the type of the devices.
719721
uint32_t
720722
NumEntries, ///< [in] the number of devices to be added to phDevices.
721-
///< If phDevices in not NULL then NumEntries should be greater than zero,
722-
///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE,
723+
///< If phDevices is not NULL, then NumEntries should be greater than zero.
724+
///< Otherwise ::UR_RESULT_ERROR_INVALID_SIZE
723725
///< will be returned.
724726
ur_device_handle_t *
725727
phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices.

source/ur_api.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,14 +616,16 @@ ur_result_t UR_APICALL urPlatformGetBackendOption(
616616
/// + `NULL == hPlatform`
617617
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
618618
/// + `::UR_DEVICE_TYPE_VPU < DeviceType`
619+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
620+
/// + `NumEntries == 0 && phDevices != NULL`
619621
/// - ::UR_RESULT_ERROR_INVALID_VALUE
620622
ur_result_t UR_APICALL urDeviceGet(
621623
ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance
622624
ur_device_type_t DeviceType, ///< [in] the type of the devices.
623625
uint32_t
624626
NumEntries, ///< [in] the number of devices to be added to phDevices.
625-
///< If phDevices in not NULL then NumEntries should be greater than zero,
626-
///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE,
627+
///< If phDevices is not NULL, then NumEntries should be greater than zero.
628+
///< Otherwise ::UR_RESULT_ERROR_INVALID_SIZE
627629
///< will be returned.
628630
ur_device_handle_t *
629631
phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices.

test/conformance/device/urDeviceGetInfo.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,14 @@ INSTANTIATE_TEST_SUITE_P(
240240
return ss.str();
241241
});
242242

243+
bool doesReturnArray(ur_device_info_t info_type) {
244+
if (info_type == UR_DEVICE_INFO_SUPPORTED_PARTITIONS ||
245+
info_type == UR_DEVICE_INFO_PARTITION_TYPE) {
246+
return true;
247+
}
248+
return false;
249+
}
250+
243251
TEST_P(urDeviceGetInfoTest, Success) {
244252
ur_device_info_t info_type = GetParam();
245253
for (auto device : devices) {
@@ -248,7 +256,11 @@ TEST_P(urDeviceGetInfoTest, Success) {
248256
urDeviceGetInfo(device, info_type, 0, nullptr, &size);
249257

250258
if (result == UR_RESULT_SUCCESS) {
259+
if (doesReturnArray(info_type) && size == 0) {
260+
return;
261+
}
251262
ASSERT_NE(size, 0);
263+
252264
if (const auto expected_size = device_info_size_map.find(info_type);
253265
expected_size != device_info_size_map.end()) {
254266
ASSERT_EQ(expected_size->second, size);

0 commit comments

Comments
 (0)