From e64e15aba4e8400809bf90089f0f955ac093f1f6 Mon Sep 17 00:00:00 2001 From: Giovanni LB Date: Tue, 16 Apr 2024 17:04:45 -0300 Subject: [PATCH] Re-enabling ATT tests Change-Id: Ied23410d40eecbbfb8972d36ed065289f74aaa0c [ROCm/rocprofiler commit: 97c6b0b867fed000a4e583589a6236f52660228f] --- projects/rocprofiler/bin/att_to_out.py | 45 ------------------- projects/rocprofiler/plugin/att/att.cpp | 4 +- .../core/hsa/packets/packets_generator.cpp | 20 +++++++++ .../featuretests/profiler/profiler_gtest.cpp | 4 +- 4 files changed, 24 insertions(+), 49 deletions(-) delete mode 100755 projects/rocprofiler/bin/att_to_out.py diff --git a/projects/rocprofiler/bin/att_to_out.py b/projects/rocprofiler/bin/att_to_out.py deleted file mode 100755 index 6bfcd7fdf7..0000000000 --- a/projects/rocprofiler/bin/att_to_out.py +++ /dev/null @@ -1,45 +0,0 @@ -################################################################################ -# Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -################################################################################ - -import numpy as np -import sys - -BYTE_MAP = [str(k) for k in range(10)] + ["a", "b", "c", "d", "e", "f"] - - -def map8(c): - return BYTE_MAP[(c // 16) % 16] + BYTE_MAP[c % 16] - - -def map16(c): - return map8(c >> 8) + map8(c) - - -in_filename = sys.argv[1] -out_filename = in_filename.split(".att")[0] + ".out" - -in_bytes = np.fromfile(in_filename, dtype=np.uint16) -offset = 4 if in_bytes[0] >= 0xC000 else 0 -out_bytes = [map16(c) + "\n" for c in in_bytes[offset:]] - -with open(out_filename, "w") as f: - [f.write(b) for b in out_bytes] diff --git a/projects/rocprofiler/plugin/att/att.cpp b/projects/rocprofiler/plugin/att/att.cpp index 98c0e0bedc..86b14e1409 100644 --- a/projects/rocprofiler/plugin/att/att.cpp +++ b/projects/rocprofiler/plugin/att/att.cpp @@ -170,7 +170,7 @@ class att_plugin_t { << '\n'; // iterate over each shader engine att trace - header.navi = !att_tracer_record->intercept_list.userdata & 0x1; + header.navi = !(att_tracer_record->intercept_list.userdata & 0x1); int se_num = att_tracer_record->shader_engine_data_count; for (int i = 0; i < se_num; i++) { @@ -188,7 +188,7 @@ class att_plugin_t { std::cerr << "ATT Failed to open file: " << outfilepath << "_se" << i << ".att\n"; return ROCPROFILER_STATUS_ERROR; } - if (header.enable) + if (header.enable && !header.navi) out.write((const char*)&header, sizeof(header.raw)); out.write(data_buffer_ptr, se_att_trace->buffer_size); } diff --git a/projects/rocprofiler/src/core/hsa/packets/packets_generator.cpp b/projects/rocprofiler/src/core/hsa/packets/packets_generator.cpp index 0a2447bbb6..ef8080cfc2 100644 --- a/projects/rocprofiler/src/core/hsa/packets/packets_generator.cpp +++ b/projects/rocprofiler/src/core/hsa/packets/packets_generator.cpp @@ -62,6 +62,16 @@ } \ } while (0) +typedef void(*aqlprofile_att_parser_iterate_event_cb_t)( + int trace_event_id, + const char* trace_event_metadata, + void* userdata +); +extern "C" void aqlprofile_att_parser_iterate_event_list( + aqlprofile_att_parser_iterate_event_cb_t callback, + void* userdata +); + namespace Packet { static const size_t MEM_PAGE_BYTES = 0x1000; static const size_t MEM_PAGE_MASK = MEM_PAGE_BYTES - 1; @@ -529,6 +539,12 @@ uint8_t* AllocateLocalMemory(size_t size, hsa_amd_memory_pool_t* gpu_pool) { return ptr; } +void check_wave_event(int, const char* event_name, void* userdata) +{ + if (std::string_view(event_name).find("waves") == 0) + *reinterpret_cast(userdata) = true; +} + hsa_status_t Allocate(hsa_agent_t gpu_agent, hsa_ven_amd_aqlprofile_profile_t* profile, size_t att_buffer_size) { rocprofiler::HSAAgentInfo& agentInfo = @@ -536,6 +552,10 @@ hsa_status_t Allocate(hsa_agent_t gpu_agent, hsa_ven_amd_aqlprofile_profile_t* p profile->command_buffer.ptr = AllocateSysMemory(gpu_agent, profile->command_buffer.size, &agentInfo.cpu_pool_); profile->output_buffer.size = att_buffer_size; + + g_output_buffer_local = false; + aqlprofile_att_parser_iterate_event_list(check_wave_event, &g_output_buffer_local); + profile->output_buffer.ptr = (g_output_buffer_local) ? AllocateLocalMemory(profile->output_buffer.size, &agentInfo.gpu_pool_) : AllocateSysMemory(gpu_agent, profile->output_buffer.size, &agentInfo.cpu_pool_); diff --git a/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.cpp b/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.cpp index dc2a9d543c..9808b3875f 100644 --- a/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.cpp +++ b/projects/rocprofiler/tests-v2/featuretests/profiler/profiler_gtest.cpp @@ -740,7 +740,7 @@ class ATTCollection : public ::testing::Test { }; bool ATTCollection::bCollected = false; -TEST_F(ATTCollection, DISABLED_WhenRunningATTItCollectsTraceDataWithOldAPI) { +TEST_F(ATTCollection, WhenRunningATTItCollectsTraceDataWithOldAPI) { int result = ROCPROFILER_STATUS_ERROR; // inititalize ROCProfiler @@ -806,7 +806,7 @@ TEST_F(ATTCollection, DISABLED_WhenRunningATTItCollectsTraceDataWithOldAPI) { } // New API -TEST_F(ATTCollection, DISABLED_WhenRunningATTItCollectsTraceDataWithNewAPI) { +TEST_F(ATTCollection, WhenRunningATTItCollectsTraceDataWithNewAPI) { int result = ROCPROFILER_STATUS_ERROR; // inititalize ROCProfiler result = rocprofiler_initialize();