diff --git a/projects/rocprofiler-sdk/CHANGELOG.md b/projects/rocprofiler-sdk/CHANGELOG.md index aba0370ffd..b4f06deace 100644 --- a/projects/rocprofiler-sdk/CHANGELOG.md +++ b/projects/rocprofiler-sdk/CHANGELOG.md @@ -198,6 +198,7 @@ Full documentation for ROCprofiler-SDK is available at [rocm.docs.amd.com/projec - SDK no longer creates a background thread when every tool returns a nullptr from `rocprofiler_configure`. - Updated disassembly.hpp's vaddr-to-file-offset mapping to use the dedicated comgr API. +- rocprofiler_uuid_t ABI is changed to hold 128 bit value. - rocprofv3 shorthand argument for `--collection-period` is now `-P` (upper-case) as `-p` (lower-case) is reserved for later use - default output format for rocprofv3 is now `rocpd` (SQLite3 database) - rocprofv3 avail tool renamed from rocprofv3_avail to rocprofv3-avail tool diff --git a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/cxx/serialization/save.hpp b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/cxx/serialization/save.hpp index d2edc5c274..5399713875 100644 --- a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/cxx/serialization/save.hpp +++ b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/cxx/serialization/save.hpp @@ -1132,7 +1132,7 @@ template void save(ArchiveT& ar, rocprofiler_uuid_t data) { - ROCP_SDK_SAVE_DATA_FIELD(value); + ROCP_SDK_SAVE_DATA_FIELD(bytes); } template diff --git a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/fwd.h b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/fwd.h index 12d1813214..d8e3705746 100644 --- a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/fwd.h +++ b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/fwd.h @@ -572,10 +572,9 @@ typedef union rocprofiler_address_t * @brief Stores UUID for devices. * */ -typedef union rocprofiler_uuid_t +typedef struct rocprofiler_uuid_t { - uint64_t value; ///< numerical value - void* bytes; ///< uuid in hexadecimal + uint8_t bytes[16]; // numerical value } rocprofiler_uuid_t; //--------------------------------------------------------------------------------------// diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/agent.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/agent.cpp index 056af77a00..821fca31f4 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/agent.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/agent.cpp @@ -503,7 +503,8 @@ update_agent_runtime_visibility(rocprofiler_agent_t& agent_info) { auto _uuid = std::strtoull(itr.substr(uuid_prefix.length()).c_str(), nullptr, 16); - if(_uuid == agent_info.uuid.value) return parse_result{true, _idx_v}; + auto uuid_view = uuid_view_t{agent_info.uuid}; + if(_uuid == uuid_view.value64[0]) return parse_result{true, _idx_v}; } else { @@ -720,7 +721,7 @@ read_topology() agent_info.name = ""; agent_info.product_name = ""; agent_info.vendor_name = ""; - agent_info.uuid = {.value = 0}; + memset(&agent_info.uuid.bytes, 0, sizeof(agent_info.uuid.bytes)); if(agent_info.type == ROCPROFILER_AGENT_TYPE_GPU) { constexpr auto workgrp_max = 1024; @@ -729,7 +730,10 @@ read_topology() constexpr auto grid_max_y = std::numeric_limits::max(); constexpr auto grid_max_z = std::numeric_limits::max(); - read_property(properties, "unique_id", agent_info.uuid.value); + auto _uuid = uuid_view_t{}; + uint64_t uuid_val = 0; + read_property(properties, "unique_id", uuid_val); + _uuid.value64[0] = uuid_val; read_property( properties, "max_engine_clk_fcompute", agent_info.max_engine_clk_fcompute); read_property(properties, "local_mem_size", agent_info.local_mem_size); @@ -744,6 +748,7 @@ read_topology() agent_info.grid_max_dim = {grid_max_x, grid_max_y, grid_max_z}; agent_info.cu_count = agent_info.simd_count / agent_info.simd_per_cu; + agent_info.uuid = static_cast(_uuid); if(int drm_fd = 0; (drm_fd = drmOpenRender(agent_info.drm_render_minor)) >= 0) { uint32_t major_version = 0; diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/agent.hpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/agent.hpp index 0edf81d62e..d1325280b3 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/agent.hpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/agent.hpp @@ -37,6 +37,45 @@ namespace rocprofiler { namespace agent { +struct uuid_view_t +{ + union + { + uint8_t bytes[16]; ///< raw bytes + uint64_t value64[2]; /// view as 64 bit chunks + }; + + constexpr uuid_view_t() + : bytes() + { + for(uint8_t& byte : bytes) + { + byte = 0; + } + } + + explicit uuid_view_t(rocprofiler_uuid_t _uuid) + { + static_assert(sizeof(bytes) == sizeof(_uuid.bytes)); + for(size_t i = 0; i < sizeof(bytes); i++) + { + bytes[i] = _uuid.bytes[i]; + } + } + + explicit constexpr operator rocprofiler_uuid_t() const + { + auto _uuid = rocprofiler_uuid_t{}; + static_assert(std::is_same_v, + std::remove_extent_t> == true); + for(size_t i = 0; i < sizeof(bytes); i++) + { + _uuid.bytes[i] = bytes[i]; + } + return _uuid; + } +}; + std::vector get_agents(); diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/queue_controller.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/queue_controller.cpp index b6742feb24..3099b06bec 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/queue_controller.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/hsa/queue_controller.cpp @@ -142,7 +142,7 @@ constexpr rocprofiler_agent_t default_agent = .logical_node_id = 0, .logical_node_type_id = 0, .runtime_visibility = {0, 0, 0, 0, 0}, - .uuid = {.value = 0}}; + .uuid = static_cast(agent::uuid_view_t{})}; } // namespace void diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/tests/agent.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/tests/agent.cpp index 42e651310f..e951160899 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/tests/agent.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/tests/agent.cpp @@ -111,7 +111,7 @@ TEST(rocprofiler_lib, agent_abi) EXPECT_EQ(offsetof(rocprofiler_agent_t, uuid), 296) << msg; // Add test for offset of new field above this. Do NOT change any existing values! - constexpr auto expected_rocp_agent_size = 304; + constexpr auto expected_rocp_agent_size = 312; // If a new field is added, increase this value by the size of the new field(s) EXPECT_EQ(sizeof(rocprofiler_agent_t), expected_rocp_agent_size) << "ABI break. If you added a new field, make sure that this is the only new check that " @@ -450,7 +450,9 @@ TEST(rocprofiler_lib, agent_visibility_multigpu) for(const auto* itr : _agents) { ordinals.emplace(itr->id, itr->logical_node_type_id); - uuids.emplace(itr->id, fmt::format("GPU-{:X}", itr->uuid.value)); + auto uuid_view = rocprofiler::agent::uuid_view_t{itr->uuid}; + auto uuid_value = uuid_view.value64[0]; + uuids.emplace(itr->id, fmt::format("GPU-{:X}", uuid_value)); ROCP_WARNING << ordinals.at(itr->id) << " :: " << uuids.at(itr->id); all_ordinals = fmt::format("{},{}", all_ordinals, ordinals.at(itr->id)); @@ -637,7 +639,10 @@ TEST(rocprofiler_lib, agent_visibility_inverted_multigpu) for(const auto* itr : _agents) { - auto _uuid = fmt::format("GPU-{:X}", itr->uuid.value); + auto uuid_view = rocprofiler::agent::uuid_view_t{itr->uuid}; + auto uuid_value = uuid_view.value64[0]; + auto _uuid = fmt::format("GPU-{:X}", uuid_value); + if(ordinals.empty()) { devices_reversed_with_ordinal_0_uuid = fmt::format("1,{}", _uuid); @@ -761,7 +766,9 @@ TEST(rocprofiler_lib, agent_visibility_inverted_multigpu) for(const auto* itr : get_gpu_agents()) { - const auto curr_uuid = fmt::format("GPU-{:X}", itr->uuid.value); + auto uuid_view = rocprofiler::agent::uuid_view_t{itr->uuid}; + auto uuid_value = uuid_view.value64[0]; + const auto curr_uuid = fmt::format("GPU-{:X}", uuid_value); if(ordinals.at(itr->id) == 0) { ASSERT_EQ(itr->runtime_visibility.hsa, 1) << "agent-" << itr->node_id;