diff --git a/src/inference/include/openvino/runtime/properties.hpp b/src/inference/include/openvino/runtime/properties.hpp index 6712126cef2849..b392c012f8ac92 100644 --- a/src/inference/include/openvino/runtime/properties.hpp +++ b/src/inference/include/openvino/runtime/properties.hpp @@ -10,6 +10,8 @@ */ #pragma once +#include +#include #include #include #include @@ -611,6 +613,45 @@ static constexpr Property full_name{"FULL_D */ static constexpr Property architecture{"DEVICE_ARCHITECTURE"}; +/** + * @brief Structure which defines format of UUID. + * @ingroup ov_runtime_cpp_prop_api + */ +struct UUID { + static const uint64_t MAX_UUID_SIZE = 16; //!< Max size of uuid array (128 bits) + std::array uuid; //!< Array with uuid for a device +}; + +/** @cond INTERNAL */ +inline std::ostream& operator<<(std::ostream& os, const UUID& device_uuid) { + std::stringstream s; + for (auto& c : device_uuid.uuid) { + s << std::hex << std::setw(2) << std::setfill('0') << +c; + } + return os << s.str(); +} + +inline std::istream& operator>>(std::istream& is, UUID& device_uuid) { + std::string s; + auto flags = is.flags(); + for (size_t i = 0; i < UUID::MAX_UUID_SIZE; i++) { + is >> std::setw(2) >> s; + std::istringstream ss2(s); + int val; + ss2 >> std::hex >> val; + device_uuid.uuid[i] = static_cast(val); + } + is.flags(flags); + return is; +} +/** @endcond */ + +/** + * @brief Read-only property which defines the UUID of the device. + * @ingroup ov_runtime_cpp_prop_api + */ +static constexpr Property uuid{"DEVICE_UUID"}; + /** * @brief Enum to define possible device types * @ingroup ov_runtime_cpp_prop_api diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/device_info.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/device_info.hpp index 1e92f752ee952a..47b0d8d221ff98 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/runtime/device_info.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/device_info.hpp @@ -7,6 +7,7 @@ #include #include #include +#include namespace cldnn { /// @addtogroup cpp_api C++ API @@ -21,6 +22,12 @@ enum class device_type { discrete_gpu = 1 }; +/// @brief Structure to represent gpu device UUID +struct device_uuid { + static const constexpr size_t max_uuid_size = 16; + std::array val; +}; + /// @brief Defines version of GFX IP struct gfx_version { uint16_t major; @@ -74,6 +81,8 @@ struct device_info { uint32_t num_sub_slices_per_slice; ///< Number of subslices in a slice uint32_t num_eus_per_sub_slice; ///< Number of execution units per subslice uint32_t num_threads_per_eu; ///< Number of hardware threads per execution unit + + device_uuid uuid; ///< UUID of the gpu device }; /// @} diff --git a/src/plugins/intel_gpu/src/plugin/plugin.cpp b/src/plugins/intel_gpu/src/plugin/plugin.cpp index cc87261c3e05d8..6d600c631a561f 100644 --- a/src/plugins/intel_gpu/src/plugin/plugin.cpp +++ b/src/plugins/intel_gpu/src/plugin/plugin.cpp @@ -708,6 +708,7 @@ Parameter Plugin::GetMetric(const std::string& name, const std::map(); + } else { + std::fill_n(std::begin(info.uuid.val), device_uuid::max_uuid_size, 0); + } + bool device_attr_supported = extensions.find("cl_intel_device_attribute_query") != std::string::npos; if (device_attr_supported) { info.gfx_ver = parse_version(device.getInfo()); info.device_id = device.getInfo(); diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_ext.hpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_ext.hpp index d69305f36e1b08..54156a805a38a6 100644 --- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_ext.hpp +++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_ext.hpp @@ -8,6 +8,7 @@ #pragma once #include +#include #define NOMINMAX #ifdef _WIN32 #include diff --git a/src/tests/functional/plugin/gpu/shared_tests_instances/behavior/ov_plugin/core_integration.cpp b/src/tests/functional/plugin/gpu/shared_tests_instances/behavior/ov_plugin/core_integration.cpp index c7ac29c8c736ad..d37bf149e88b1f 100644 --- a/src/tests/functional/plugin/gpu/shared_tests_instances/behavior/ov_plugin/core_integration.cpp +++ b/src/tests/functional/plugin/gpu/shared_tests_instances/behavior/ov_plugin/core_integration.cpp @@ -47,6 +47,10 @@ INSTANTIATE_TEST_SUITE_P(nightly_OVClassGetMetricTest, OVClassGetMetricTest_FULL_DEVICE_NAME, ::testing::Values("GPU", "MULTI", "HETERO", "AUTO", "BATCH")); +INSTANTIATE_TEST_SUITE_P(nightly_OVClassGetMetricTest, + OVClassGetMetricTest_DEVICE_UUID, + ::testing::Values("GPU")); + INSTANTIATE_TEST_SUITE_P(nightly_OVClassGetMetricTest, OVClassGetMetricTest_OPTIMIZATION_CAPABILITIES, ::testing::Values("GPU")); diff --git a/src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_integration.hpp b/src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_integration.hpp index 79e9521b8722a5..73224572c0d18a 100644 --- a/src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_integration.hpp +++ b/src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_integration.hpp @@ -81,6 +81,7 @@ using OVClassGetMetricTest_SUPPORTED_CONFIG_KEYS = OVClassBaseTestP; using OVClassGetMetricTest_AVAILABLE_DEVICES = OVClassBaseTestP; using OVClassGetMetricTest_FULL_DEVICE_NAME = OVClassBaseTestP; using OVClassGetMetricTest_FULL_DEVICE_NAME_with_DEVICE_ID = OVClassBaseTestP; +using OVClassGetMetricTest_DEVICE_UUID = OVClassBaseTestP; using OVClassGetMetricTest_OPTIMIZATION_CAPABILITIES = OVClassBaseTestP; using OVClassGetMetricTest_DEVICE_GOPS = OVClassBaseTestP; using OVClassGetMetricTest_DEVICE_TYPE = OVClassBaseTestP; @@ -639,6 +640,16 @@ TEST_P(OVClassGetMetricTest_FULL_DEVICE_NAME_with_DEVICE_ID, GetMetricAndPrintNo } } +TEST_P(OVClassGetMetricTest_DEVICE_UUID, GetMetricAndPrintNoThrow) { + ov::Core ie = createCoreWithTemplate(); + ov::device::UUID t; + + OV_ASSERT_NO_THROW(t = ie.get_property(deviceName, ov::device::uuid)); + std::cout << "Device uuid: " << std::endl << t << std::endl; + + OV_ASSERT_PROPERTY_SUPPORTED(ov::device::uuid); +} + TEST_P(OVClassGetMetricTest_OPTIMIZATION_CAPABILITIES, GetMetricAndPrintNoThrow) { ov::Core ie = createCoreWithTemplate(); std::vector t;