diff --git a/level_zero/api/core/ze_device.cpp b/level_zero/api/core/ze_device.cpp index 6c397177b7..963b72097f 100644 --- a/level_zero/api/core/ze_device.cpp +++ b/level_zero/api/core/ze_device.cpp @@ -102,4 +102,12 @@ zeDeviceSetLastLevelCacheConfig( return L0::Device::fromHandle(hDevice)->setLastLevelCacheConfig(cacheConfig); } +ZE_APIEXPORT ze_result_t ZE_APICALL +zeDeviceGetCommandQueueGroupProperties( + ze_device_handle_t hDevice, + uint32_t *pCount, + ze_command_queue_group_properties_t *pCommandQueueGroupProperties) { + return L0::Device::fromHandle(hDevice)->getCommandQueueGroupProperties(pCount, pCommandQueueGroupProperties); +} + } // extern "C" diff --git a/level_zero/core/source/device/device.h b/level_zero/core/source/device/device.h index 66a3382ca6..4c398b09c6 100644 --- a/level_zero/core/source/device/device.h +++ b/level_zero/core/source/device/device.h @@ -19,6 +19,8 @@ #include #include +#include "third_party/level_zero/ze_api_ext.h" + struct _ze_device_handle_t {}; namespace NEO { class Device; @@ -54,8 +56,7 @@ struct Device : _ze_device_handle_t { ze_sampler_handle_t *phSampler) = 0; virtual ze_result_t evictImage(ze_image_handle_t hImage) = 0; virtual ze_result_t evictMemory(void *ptr, size_t size) = 0; - virtual ze_result_t - getComputeProperties(ze_device_compute_properties_t *pComputeProperties) = 0; + virtual ze_result_t getComputeProperties(ze_device_compute_properties_t *pComputeProperties) = 0; virtual ze_result_t getP2PProperties(ze_device_handle_t hPeerDevice, ze_device_p2p_properties_t *pP2PProperties) = 0; virtual ze_result_t getKernelProperties(ze_device_kernel_properties_t *pKernelProperties) = 0; @@ -71,6 +72,8 @@ struct Device : _ze_device_handle_t { virtual ze_result_t imageGetProperties(const ze_image_desc_t *desc, ze_image_properties_t *pImageProperties) = 0; virtual ze_result_t getDeviceImageProperties(ze_device_image_properties_t *pDeviceImageProperties) = 0; + virtual ze_result_t getCommandQueueGroupProperties(uint32_t *pCount, + ze_command_queue_group_properties_t *pCommandQueueGroupProperties) = 0; virtual ze_result_t systemBarrier() = 0; virtual ze_result_t registerCLMemory(cl_context context, cl_mem mem, void **ptr) = 0; diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index 6e59e14805..d90443f0aa 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -146,6 +146,11 @@ ze_result_t DeviceImp::createCommandQueue(const ze_command_queue_desc_t *desc, return ZE_RESULT_SUCCESS; } +ze_result_t DeviceImp::getCommandQueueGroupProperties(uint32_t *pCount, + ze_command_queue_group_properties_t *pCommandQueueGroupProperties) { + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + ze_result_t DeviceImp::createImage(const ze_image_desc_t *desc, ze_image_handle_t *phImage) { auto productFamily = neoDevice->getHardwareInfo().platform.eProductFamily; *phImage = Image::create(productFamily, this, desc); diff --git a/level_zero/core/source/device/device_imp.h b/level_zero/core/source/device/device_imp.h index c0d612cff1..655c201359 100644 --- a/level_zero/core/source/device/device_imp.h +++ b/level_zero/core/source/device/device_imp.h @@ -46,6 +46,8 @@ struct DeviceImp : public Device { ze_result_t getCacheProperties(ze_device_cache_properties_t *pCacheProperties) override; ze_result_t imageGetProperties(const ze_image_desc_t *desc, ze_image_properties_t *pImageProperties) override; ze_result_t getDeviceImageProperties(ze_device_image_properties_t *pDeviceImageProperties) override; + ze_result_t getCommandQueueGroupProperties(uint32_t *pCount, + ze_command_queue_group_properties_t *pCommandQueueGroupProperties) override; ze_result_t systemBarrier() override; void *getExecEnvironment() override; BuiltinFunctionsLib *getBuiltinFunctionsLib() override; diff --git a/level_zero/core/test/unit_tests/mocks/mock_device.h b/level_zero/core/test/unit_tests/mocks/mock_device.h index 2dc7a4810c..fc3ecb7610 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_device.h +++ b/level_zero/core/test/unit_tests/mocks/mock_device.h @@ -75,6 +75,11 @@ struct Mock : public Device { MOCK_METHOD2(imageGetProperties, ze_result_t(const ze_image_desc_t *desc, ze_image_properties_t *pImageProperties)); + MOCK_METHOD(ze_result_t, + getCommandQueueGroupProperties, + (uint32_t * pCount, + ze_command_queue_group_properties_t *pCommandQueueGroupProperties), + (override)); MOCK_METHOD1(getDeviceImageProperties, ze_result_t(ze_device_image_properties_t *pDeviceImageProperties)); MOCK_METHOD0(systemBarrier, ze_result_t()); diff --git a/level_zero/core/test/unit_tests/sources/device/test_device.cpp b/level_zero/core/test/unit_tests/sources/device/test_device.cpp index ff63f145e2..b021473dc3 100644 --- a/level_zero/core/test/unit_tests/sources/device/test_device.cpp +++ b/level_zero/core/test/unit_tests/sources/device/test_device.cpp @@ -156,6 +156,14 @@ TEST_F(DeviceTest, givenDevicePropertiesStructureWhenDevicePropertiesCalledThenA EXPECT_NE(0, memcmp(&deviceProperties.name, &devicePropertiesBefore.name, sizeof(devicePropertiesBefore.name))); } +TEST_F(DeviceTest, givenCommandQueuePropertiesCallThenUnsupportedIsReturned) { + uint32_t count; + ze_command_queue_group_properties_t queueProperties = {}; + + ze_result_t res = device->getCommandQueueGroupProperties(&count, &queueProperties); + EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, res); +} + struct DeviceHasNoDoubleFp64Test : public ::testing::Test { void SetUp() override { DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices); diff --git a/third_party/level_zero/ze_api_ext.h b/third_party/level_zero/ze_api_ext.h index fb33ef76ec..79e4a89103 100644 --- a/third_party/level_zero/ze_api_ext.h +++ b/third_party/level_zero/ze_api_ext.h @@ -175,6 +175,72 @@ zeModuleDynamicLinkExt( ze_module_build_log_handle_t *phLinkLog ///< [out][optional] pointer to handle of dynamic link log. ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Supported command queue group property flags +typedef uint32_t ze_command_queue_group_property_flags_t; +typedef enum _ze_command_queue_group_property_flag_t { + ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE = ZE_BIT(0), ///< Command queue group supports enqueing compute commands. + ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY = ZE_BIT(1), ///< Command queue group supports enqueing copy commands. + ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS = ZE_BIT(2), ///< Command queue group supports cooperative kernels. + ///< See ::zeCommandListAppendLaunchCooperativeKernel for more details. + ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_METRICS = ZE_BIT(3), ///< Command queue groups supports metric streamers and queries. + ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_FORCE_UINT32 = 0x7fffffff + +} ze_command_queue_group_property_flag_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Command queue group properties queried using +/// ::zeDeviceGetCommandQueueGroupProperties +typedef struct _ze_command_queue_group_properties_t { + void *pNext; ///< [in,out][optional] pointer to extension-specific structure + ze_command_queue_group_property_flags_t flags; ///< [out] 0 (none) or a valid combination of + ///< ::ze_command_queue_group_property_flag_t + size_t maxMemoryFillPatternSize; ///< [out] maximum `pattern_size` supported by command queue group. + ///< See ::zeCommandListAppendMemoryFill for more details. + uint32_t numQueues; ///< [out] the number of physical command queues within the group. + +} ze_command_queue_group_properties_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves command queue group properties of the device. +/// +/// @details +/// - Properties are reported for each physical command queue type supported +/// by the device. +/// - Multiple calls to this function will return properties in the same +/// order. +/// - The order in which the properties are returned defines the command +/// queue group's ordinal. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @remarks +/// _Analogues_ +/// - **vkGetPhysicalDeviceQueueFamilyProperties** +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +ZE_APIEXPORT ze_result_t ZE_APICALL +zeDeviceGetCommandQueueGroupProperties( + ze_device_handle_t hDevice, ///< [in] handle of the device + uint32_t *pCount, ///< [in,out] pointer to the number of command queue group properties. + ///< if count is zero, then the driver will update the value with the total + ///< number of command queue group properties available. + ///< if count is non-zero, then driver will only retrieve that number of + ///< command queue group properties. + ///< if count is larger than the number of command queue group properties + ///< available, then the driver will update the value with the correct + ///< number of command queue group properties available. + ze_command_queue_group_properties_t *pCommandQueueGroupProperties ///< [in,out][optional][range(0, *pCount)] array of query results for + ///< command queue group properties +); + } //extern C #endif // _ZE_API_EXT_H