diff --git a/include/ur_api.h b/include/ur_api.h index 1508dcf86b..258ea85e7a 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -1301,14 +1301,16 @@ typedef enum ur_device_type_t { /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_DEVICE_TYPE_VPU < DeviceType` +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `NumEntries == 0 && phDevices != NULL` /// - ::UR_RESULT_ERROR_INVALID_VALUE UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet( ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance ur_device_type_t DeviceType, ///< [in] the type of the devices. uint32_t NumEntries, ///< [in] the number of devices to be added to phDevices. - ///< If phDevices in not NULL then NumEntries should be greater than zero, - ///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE, + ///< If phDevices is not NULL, then NumEntries should be greater than zero. + ///< Otherwise ::UR_RESULT_ERROR_INVALID_SIZE ///< will be returned. ur_device_handle_t *phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices. ///< If NumEntries is less than the number of devices available, then diff --git a/scripts/core/device.yml b/scripts/core/device.yml index 27f2100feb..4d304dc12f 100644 --- a/scripts/core/device.yml +++ b/scripts/core/device.yml @@ -131,7 +131,7 @@ params: name: NumEntries desc: | [in] the number of devices to be added to phDevices. - If phDevices in not NULL then NumEntries should be greater than zero, otherwise $X_RESULT_ERROR_INVALID_VALUE, + If phDevices is not NULL, then NumEntries should be greater than zero. Otherwise $X_RESULT_ERROR_INVALID_SIZE will be returned. - type: "$x_device_handle_t*" name: phDevices @@ -144,6 +144,8 @@ params: [out][optional] pointer to the number of devices. pNumDevices will be updated with the total number of devices available. returns: + - $X_RESULT_ERROR_INVALID_SIZE: + - "`NumEntries == 0 && phDevices != NULL`" - $X_RESULT_ERROR_INVALID_VALUE --- #-------------------------------------------------------------------------- type: enum diff --git a/source/adapters/null/ur_nullddi.cpp b/source/adapters/null/ur_nullddi.cpp index 29d2faef98..cb87343945 100644 --- a/source/adapters/null/ur_nullddi.cpp +++ b/source/adapters/null/ur_nullddi.cpp @@ -320,8 +320,8 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet( ur_device_type_t DeviceType, ///< [in] the type of the devices. uint32_t NumEntries, ///< [in] the number of devices to be added to phDevices. - ///< If phDevices in not NULL then NumEntries should be greater than zero, - ///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE, + ///< If phDevices is not NULL, then NumEntries should be greater than zero. + ///< Otherwise ::UR_RESULT_ERROR_INVALID_SIZE ///< will be returned. ur_device_handle_t * phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices. diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index dee41bc1c1..64702ebed5 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -357,8 +357,8 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet( ur_device_type_t DeviceType, ///< [in] the type of the devices. uint32_t NumEntries, ///< [in] the number of devices to be added to phDevices. - ///< If phDevices in not NULL then NumEntries should be greater than zero, - ///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE, + ///< If phDevices is not NULL, then NumEntries should be greater than zero. + ///< Otherwise ::UR_RESULT_ERROR_INVALID_SIZE ///< will be returned. ur_device_handle_t * phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices. diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index efcc2cd9c3..2e36eeeb2c 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -398,8 +398,8 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet( ur_device_type_t DeviceType, ///< [in] the type of the devices. uint32_t NumEntries, ///< [in] the number of devices to be added to phDevices. - ///< If phDevices in not NULL then NumEntries should be greater than zero, - ///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE, + ///< If phDevices is not NULL, then NumEntries should be greater than zero. + ///< Otherwise ::UR_RESULT_ERROR_INVALID_SIZE ///< will be returned. ur_device_handle_t * phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices. @@ -422,6 +422,10 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet( if (UR_DEVICE_TYPE_VPU < DeviceType) { return UR_RESULT_ERROR_INVALID_ENUMERATION; } + + if (NumEntries == 0 && phDevices != NULL) { + return UR_RESULT_ERROR_INVALID_SIZE; + } } ur_result_t result = diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index 7776758069..7094cb0304 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -440,8 +440,8 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet( ur_device_type_t DeviceType, ///< [in] the type of the devices. uint32_t NumEntries, ///< [in] the number of devices to be added to phDevices. - ///< If phDevices in not NULL then NumEntries should be greater than zero, - ///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE, + ///< If phDevices is not NULL, then NumEntries should be greater than zero. + ///< Otherwise ::UR_RESULT_ERROR_INVALID_SIZE ///< will be returned. ur_device_handle_t * phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices. diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index a61caf39ec..5d0b64d922 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -712,14 +712,16 @@ ur_result_t UR_APICALL urPlatformGetBackendOption( /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_DEVICE_TYPE_VPU < DeviceType` +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `NumEntries == 0 && phDevices != NULL` /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urDeviceGet( ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance ur_device_type_t DeviceType, ///< [in] the type of the devices. uint32_t NumEntries, ///< [in] the number of devices to be added to phDevices. - ///< If phDevices in not NULL then NumEntries should be greater than zero, - ///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE, + ///< If phDevices is not NULL, then NumEntries should be greater than zero. + ///< Otherwise ::UR_RESULT_ERROR_INVALID_SIZE ///< will be returned. ur_device_handle_t * phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices. diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 5dde244596..1d6371781b 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -616,14 +616,16 @@ ur_result_t UR_APICALL urPlatformGetBackendOption( /// + `NULL == hPlatform` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION /// + `::UR_DEVICE_TYPE_VPU < DeviceType` +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// + `NumEntries == 0 && phDevices != NULL` /// - ::UR_RESULT_ERROR_INVALID_VALUE ur_result_t UR_APICALL urDeviceGet( ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance ur_device_type_t DeviceType, ///< [in] the type of the devices. uint32_t NumEntries, ///< [in] the number of devices to be added to phDevices. - ///< If phDevices in not NULL then NumEntries should be greater than zero, - ///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE, + ///< If phDevices is not NULL, then NumEntries should be greater than zero. + ///< Otherwise ::UR_RESULT_ERROR_INVALID_SIZE ///< will be returned. ur_device_handle_t * phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices. diff --git a/test/conformance/device/urDeviceGetInfo.cpp b/test/conformance/device/urDeviceGetInfo.cpp index e5e9f7c310..757e09b6fa 100644 --- a/test/conformance/device/urDeviceGetInfo.cpp +++ b/test/conformance/device/urDeviceGetInfo.cpp @@ -240,6 +240,14 @@ INSTANTIATE_TEST_SUITE_P( return ss.str(); }); +bool doesReturnArray(ur_device_info_t info_type) { + if (info_type == UR_DEVICE_INFO_SUPPORTED_PARTITIONS || + info_type == UR_DEVICE_INFO_PARTITION_TYPE) { + return true; + } + return false; +} + TEST_P(urDeviceGetInfoTest, Success) { ur_device_info_t info_type = GetParam(); for (auto device : devices) { @@ -248,7 +256,11 @@ TEST_P(urDeviceGetInfoTest, Success) { urDeviceGetInfo(device, info_type, 0, nullptr, &size); if (result == UR_RESULT_SUCCESS) { + if (doesReturnArray(info_type) && size == 0) { + return; + } ASSERT_NE(size, 0); + if (const auto expected_size = device_info_size_map.find(info_type); expected_size != device_info_size_map.end()) { ASSERT_EQ(expected_size->second, size);