Updates/fixes for CI, docs, tests, samples, and common library (#528)
- .github/workflows/continuous_integration.yml
- apt-get update before apt-get install
- remove libgtest-dev
- actions-comment-pull-request: v2.4.3 -> v2.5.0
- .github/workflows/formatting.yml
- create-pull-request: v5 -> v6
- cmake/rocprofiler_options.cmake
- remove unused ROCPROFILER_DEBUG_TRACE and ROCPROFILER_LD_AQLPROFILE options
- samples/counter_collection/callback_client.cpp
- corr_id field renamed to correlation_id
- samples/counter_collection/client.cpp
- corr_id field renamed to correlation_id
- include/rocprofiler-sdk/fwd.h
- In rocprofiler_record_counter_t: rename corr_id field to correlation_id
- doxygen fixes
- lib/common/utility.*
- remove get_accurate_clock_id_impl
- timestamp_ns() defaults to CLOCK_BOOTTIME
- lib/rocprofiler-sdk/counters/core.cpp
- fix spelling mistake: extrenal -> external
- corr_id field renamed to correlation_id
- lib/rocprofiler-sdk-tool/tool.cpp
- fix destruction of static tool::output_file before finalization
- scripts/update-docs.sh
- define PROJECT_NAME
- tests/async-copy-tracing/validate.py
- init_time and fini_time checks
- hip_api_traces, marker_api_tracing
- tests/common/serialization.hpp
- fix save function for rocprofiler_record_counter_t following rename of corr_id to correlation_id
- tests/kernel-tracing/validate.py
- init_time and fini_time checks
- relax test_total_runtime range
- tests/rocprofv3/tracing/CMakeLists.txt
- remove -M from rocprofv3-test-systrace-execute
- exclude test_hsa_api_trace in rocprofv3-test-systrace-validate due to HIP API tracing
- tests/rocprofv3/tracing/validate.py
- update test_kernel_trace to accept mangled or demangled
- tests/tools/json-tool.cpp
- remove use of GLOG
- include init_time and fini_time
- write_json(...) function
[ROCm/rocprofiler-sdk commit: 0d939edbba]
This commit is contained in:
committed by
GitHub
parent
2d9779ad96
commit
f760a3ceaa
@@ -8,7 +8,8 @@ import pytest
|
||||
def node_exists(name, data, min_len=1):
|
||||
assert name in data
|
||||
assert data[name] is not None
|
||||
assert len(data[name]) >= min_len
|
||||
if isinstance(data[name], (list, tuple, dict, set)):
|
||||
assert len(data[name]) >= min_len
|
||||
|
||||
|
||||
def test_data_structure(input_data):
|
||||
@@ -19,6 +20,12 @@ def test_data_structure(input_data):
|
||||
|
||||
sdk_data = data["rocprofiler-sdk-json-tool"]
|
||||
|
||||
node_exists("metadata", sdk_data)
|
||||
node_exists("pid", sdk_data["metadata"])
|
||||
node_exists("main_tid", sdk_data["metadata"])
|
||||
node_exists("init_time", sdk_data["metadata"])
|
||||
node_exists("fini_time", sdk_data["metadata"])
|
||||
|
||||
node_exists("agents", sdk_data)
|
||||
node_exists("call_stack", sdk_data)
|
||||
node_exists("callback_records", sdk_data)
|
||||
@@ -28,11 +35,15 @@ def test_data_structure(input_data):
|
||||
node_exists("code_objects", sdk_data["callback_records"])
|
||||
node_exists("kernel_symbols", sdk_data["callback_records"])
|
||||
node_exists("hsa_api_traces", sdk_data["callback_records"])
|
||||
node_exists("hip_api_traces", sdk_data["callback_records"], 0)
|
||||
node_exists("marker_api_traces", sdk_data["callback_records"])
|
||||
|
||||
node_exists("names", sdk_data["buffer_records"])
|
||||
node_exists("kernel_dispatches", sdk_data["buffer_records"])
|
||||
node_exists("memory_copies", sdk_data["buffer_records"], 4)
|
||||
node_exists("hsa_api_traces", sdk_data["buffer_records"])
|
||||
node_exists("hip_api_traces", sdk_data["buffer_records"], 0)
|
||||
node_exists("marker_api_traces", sdk_data["buffer_records"])
|
||||
|
||||
|
||||
def test_timestamps(input_data):
|
||||
@@ -41,7 +52,7 @@ def test_timestamps(input_data):
|
||||
|
||||
cb_start = {}
|
||||
cb_end = {}
|
||||
for titr in ["hsa_api_traces", "marker_api_traces"]:
|
||||
for titr in ["hsa_api_traces", "marker_api_traces", "hip_api_traces"]:
|
||||
for itr in sdk_data["callback_records"][titr]:
|
||||
cid = itr["record"]["correlation_id"]["internal"]
|
||||
phase = itr["record"]["phase"]
|
||||
@@ -56,18 +67,20 @@ def test_timestamps(input_data):
|
||||
for itr in sdk_data["buffer_records"][titr]:
|
||||
assert itr["start_timestamp"] <= itr["end_timestamp"]
|
||||
|
||||
for itr in sdk_data["buffer_records"]["memory_copies"]:
|
||||
assert itr["start_timestamp"] <= itr["end_timestamp"]
|
||||
for titr in ["kernel_dispatches", "memory_copies"]:
|
||||
for itr in sdk_data["buffer_records"][titr]:
|
||||
assert itr["start_timestamp"] < itr["end_timestamp"]
|
||||
assert itr["correlation_id"]["internal"] > 0
|
||||
assert itr["correlation_id"]["external"] > 0
|
||||
assert sdk_data["metadata"]["init_time"] < itr["start_timestamp"]
|
||||
assert sdk_data["metadata"]["init_time"] < itr["end_timestamp"]
|
||||
assert sdk_data["metadata"]["fini_time"] > itr["start_timestamp"]
|
||||
assert sdk_data["metadata"]["fini_time"] > itr["end_timestamp"]
|
||||
|
||||
for itr in sdk_data["buffer_records"]["kernel_dispatches"]:
|
||||
assert itr["start_timestamp"] < itr["end_timestamp"]
|
||||
assert itr["correlation_id"]["internal"] > 0
|
||||
assert itr["correlation_id"]["external"] > 0
|
||||
|
||||
api_start = cb_start[itr["correlation_id"]["internal"]]
|
||||
api_end = cb_end[itr["correlation_id"]["internal"]]
|
||||
assert api_start < itr["start_timestamp"]
|
||||
assert api_end <= itr["end_timestamp"]
|
||||
api_start = cb_start[itr["correlation_id"]["internal"]]
|
||||
api_end = cb_end[itr["correlation_id"]["internal"]]
|
||||
assert api_start < itr["start_timestamp"]
|
||||
assert api_end <= itr["end_timestamp"]
|
||||
|
||||
|
||||
def test_internal_correlation_ids(input_data):
|
||||
@@ -75,7 +88,7 @@ def test_internal_correlation_ids(input_data):
|
||||
sdk_data = data["rocprofiler-sdk-json-tool"]
|
||||
|
||||
api_corr_ids = []
|
||||
for titr in ["hsa_api_traces", "marker_api_traces"]:
|
||||
for titr in ["hsa_api_traces", "marker_api_traces", "hip_api_traces"]:
|
||||
for itr in sdk_data["callback_records"][titr]:
|
||||
api_corr_ids.append(itr["record"]["correlation_id"]["internal"])
|
||||
|
||||
@@ -101,7 +114,7 @@ def test_external_correlation_ids(input_data):
|
||||
sdk_data = data["rocprofiler-sdk-json-tool"]
|
||||
|
||||
extern_corr_ids = []
|
||||
for titr in ["hsa_api_traces", "marker_api_traces"]:
|
||||
for titr in ["hsa_api_traces", "marker_api_traces", "hip_api_traces"]:
|
||||
for itr in sdk_data["callback_records"][titr]:
|
||||
assert itr["record"]["correlation_id"]["external"] > 0
|
||||
assert (
|
||||
@@ -110,7 +123,7 @@ def test_external_correlation_ids(input_data):
|
||||
extern_corr_ids.append(itr["record"]["correlation_id"]["external"])
|
||||
|
||||
extern_corr_ids = list(set(sorted(extern_corr_ids)))
|
||||
for titr in ["hsa_api_traces", "marker_api_traces"]:
|
||||
for titr in ["hsa_api_traces", "marker_api_traces", "hip_api_traces"]:
|
||||
for itr in sdk_data["buffer_records"][titr]:
|
||||
assert itr["correlation_id"]["external"] > 0
|
||||
assert itr["thread_id"] == itr["correlation_id"]["external"]
|
||||
|
||||
@@ -205,9 +205,9 @@ save(ArchiveT& ar, rocprofiler_callback_tracing_record_t data)
|
||||
{
|
||||
SAVE_DATA_FIELD(context_id);
|
||||
SAVE_DATA_FIELD(thread_id);
|
||||
SAVE_DATA_FIELD(correlation_id);
|
||||
SAVE_DATA_FIELD(kind);
|
||||
SAVE_DATA_FIELD(operation);
|
||||
SAVE_DATA_FIELD(correlation_id);
|
||||
SAVE_DATA_FIELD(phase);
|
||||
}
|
||||
|
||||
@@ -217,8 +217,8 @@ save_buffer_tracing_api_record(ArchiveT& ar, Tp data)
|
||||
{
|
||||
SAVE_DATA_FIELD(size);
|
||||
SAVE_DATA_FIELD(kind);
|
||||
SAVE_DATA_FIELD(correlation_id);
|
||||
SAVE_DATA_FIELD(operation);
|
||||
SAVE_DATA_FIELD(correlation_id);
|
||||
SAVE_DATA_FIELD(start_timestamp);
|
||||
SAVE_DATA_FIELD(end_timestamp);
|
||||
SAVE_DATA_FIELD(thread_id);
|
||||
@@ -237,7 +237,7 @@ save(ArchiveT& ar, rocprofiler_record_counter_t data)
|
||||
{
|
||||
SAVE_DATA_FIELD(id);
|
||||
SAVE_DATA_FIELD(counter_value);
|
||||
SAVE_DATA_FIELD(corr_id);
|
||||
SAVE_DATA_FIELD(correlation_id);
|
||||
}
|
||||
|
||||
template <typename ArchiveT>
|
||||
@@ -278,8 +278,8 @@ save(ArchiveT& ar, rocprofiler_buffer_tracing_memory_copy_record_t data)
|
||||
{
|
||||
SAVE_DATA_FIELD(size);
|
||||
SAVE_DATA_FIELD(kind);
|
||||
SAVE_DATA_FIELD(correlation_id);
|
||||
SAVE_DATA_FIELD(operation);
|
||||
SAVE_DATA_FIELD(correlation_id);
|
||||
SAVE_DATA_FIELD(start_timestamp);
|
||||
SAVE_DATA_FIELD(end_timestamp);
|
||||
SAVE_DATA_FIELD(dst_agent_id);
|
||||
|
||||
@@ -8,7 +8,8 @@ import pytest
|
||||
def node_exists(name, data, min_len=1):
|
||||
assert name in data
|
||||
assert data[name] is not None
|
||||
assert len(data[name]) >= min_len
|
||||
if isinstance(data[name], (list, tuple, dict, set)):
|
||||
assert len(data[name]) >= min_len
|
||||
|
||||
|
||||
def test_data_structure(input_data):
|
||||
@@ -19,6 +20,12 @@ def test_data_structure(input_data):
|
||||
|
||||
sdk_data = data["rocprofiler-sdk-json-tool"]
|
||||
|
||||
node_exists("metadata", sdk_data)
|
||||
node_exists("pid", sdk_data["metadata"])
|
||||
node_exists("main_tid", sdk_data["metadata"])
|
||||
node_exists("init_time", sdk_data["metadata"])
|
||||
node_exists("fini_time", sdk_data["metadata"])
|
||||
|
||||
node_exists("agents", sdk_data)
|
||||
node_exists("call_stack", sdk_data)
|
||||
node_exists("callback_records", sdk_data)
|
||||
@@ -60,18 +67,20 @@ def test_timestamps(input_data):
|
||||
for itr in sdk_data["buffer_records"][titr]:
|
||||
assert itr["start_timestamp"] <= itr["end_timestamp"]
|
||||
|
||||
for itr in sdk_data["buffer_records"]["memory_copies"]:
|
||||
assert itr["start_timestamp"] <= itr["end_timestamp"]
|
||||
for titr in ["kernel_dispatches", "memory_copies"]:
|
||||
for itr in sdk_data["buffer_records"][titr]:
|
||||
assert itr["start_timestamp"] < itr["end_timestamp"]
|
||||
assert itr["correlation_id"]["internal"] > 0
|
||||
assert itr["correlation_id"]["external"] > 0
|
||||
assert sdk_data["metadata"]["init_time"] < itr["start_timestamp"]
|
||||
assert sdk_data["metadata"]["init_time"] < itr["end_timestamp"]
|
||||
assert sdk_data["metadata"]["fini_time"] > itr["start_timestamp"]
|
||||
assert sdk_data["metadata"]["fini_time"] > itr["end_timestamp"]
|
||||
|
||||
for itr in sdk_data["buffer_records"]["kernel_dispatches"]:
|
||||
assert itr["start_timestamp"] < itr["end_timestamp"]
|
||||
assert itr["correlation_id"]["internal"] > 0
|
||||
assert itr["correlation_id"]["external"] > 0
|
||||
|
||||
api_start = cb_start[itr["correlation_id"]["internal"]]
|
||||
api_end = cb_end[itr["correlation_id"]["internal"]]
|
||||
assert api_start < itr["start_timestamp"]
|
||||
assert api_end <= itr["end_timestamp"]
|
||||
api_start = cb_start[itr["correlation_id"]["internal"]]
|
||||
api_end = cb_end[itr["correlation_id"]["internal"]]
|
||||
assert api_start < itr["start_timestamp"]
|
||||
assert api_end <= itr["end_timestamp"]
|
||||
|
||||
|
||||
def test_total_runtime(input_data):
|
||||
@@ -84,8 +93,8 @@ def test_total_runtime(input_data):
|
||||
|
||||
expected_runtime = 1.0e3 # one second in milliseconds
|
||||
|
||||
assert (sum(runtime_data) * 1.0e-6) >= (0.9 * expected_runtime)
|
||||
assert (sum(runtime_data) * 1.0e-6) <= (1.1 * expected_runtime)
|
||||
assert (sum(runtime_data) * 1.0e-6) >= (0.8 * expected_runtime)
|
||||
assert (sum(runtime_data) * 1.0e-6) <= (1.2 * expected_runtime)
|
||||
|
||||
|
||||
def test_internal_correlation_ids(input_data):
|
||||
|
||||
@@ -84,7 +84,7 @@ set_tests_properties(
|
||||
add_test(
|
||||
NAME rocprofv3-test-systrace-execute
|
||||
COMMAND
|
||||
$<TARGET_FILE:rocprofiler-sdk::rocprofv3> -M --sys-trace -d
|
||||
$<TARGET_FILE:rocprofiler-sdk::rocprofv3> --sys-trace -d
|
||||
${CMAKE_CURRENT_BINARY_DIR}/%argt%-systrace -o out
|
||||
$<TARGET_FILE:simple-transpose>)
|
||||
|
||||
@@ -102,7 +102,8 @@ set_tests_properties(
|
||||
add_test(
|
||||
NAME rocprofv3-test-systrace-validate
|
||||
COMMAND
|
||||
${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py --hsa-input
|
||||
${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py -k
|
||||
"not test_hsa_api_trace" --hsa-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace/out_hsa_api_trace.csv
|
||||
--kernel-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-systrace/out_kernel_trace.csv
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import sys
|
||||
import pytest
|
||||
import re
|
||||
|
||||
|
||||
def test_hsa_api_trace(hsa_input_data):
|
||||
@@ -37,13 +36,18 @@ def test_hsa_api_trace(hsa_input_data):
|
||||
|
||||
|
||||
def test_kernel_trace(kernel_input_data):
|
||||
mangled_kernel_name = "_Z15matrixTransposePfS_i.kd"
|
||||
valid_kernel_names = (
|
||||
"_Z15matrixTransposePfS_i.kd",
|
||||
"matrixTranspose(float*, float*, int)",
|
||||
)
|
||||
|
||||
assert len(kernel_input_data) == 1
|
||||
for row in kernel_input_data:
|
||||
assert row["Kind"] == "KERNEL_DISPATCH"
|
||||
assert int(row["Agent_Id"]) > 0
|
||||
assert int(row["Queue_Id"]) > 0
|
||||
assert int(row["Kernel_Id"]) > 0
|
||||
assert row["Kernel_Name"] == mangled_kernel_name
|
||||
assert row["Kernel_Name"] in valid_kernel_names
|
||||
assert int(row["Correlation_Id"]) > 0
|
||||
assert int(row["Workgroup_Size_X"]) == 4
|
||||
assert int(row["Workgroup_Size_Y"]) == 4
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
#include <rocprofiler-sdk/registration.h>
|
||||
#include <rocprofiler-sdk/rocprofiler.h>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
@@ -432,7 +430,7 @@ dispatch_callback(rocprofiler_queue_id_t, /*queue_id*/
|
||||
// Counters we want to collect (here its SQ_WAVES_sum)
|
||||
auto* counters_env = getenv("ROCPROF_COUNTERS");
|
||||
if(std::string(counters_env) != "SQ_WAVES_sum")
|
||||
LOG(FATAL) << "Counter not supported in the test tool";
|
||||
throw std::runtime_error{"Counter not supported in the test tool"};
|
||||
|
||||
std::set<std::string> counters_to_collect = {"SQ_WAVES_sum"};
|
||||
// GPU Counter IDs
|
||||
@@ -728,9 +726,16 @@ auto buffers = std::array<rocprofiler_buffer_id_t*, 6>{&hsa_api_buffered_buffer,
|
||||
|
||||
auto agents = std::vector<rocprofiler_agent_t>{};
|
||||
|
||||
rocprofiler_timestamp_t init_time = 0;
|
||||
rocprofiler_timestamp_t fini_time = 0;
|
||||
rocprofiler_thread_id_t main_tid = 0;
|
||||
|
||||
int
|
||||
tool_init(rocprofiler_client_finalize_t fini_func, void* tool_data)
|
||||
{
|
||||
rocprofiler_get_timestamp(&init_time);
|
||||
rocprofiler_get_thread_id(&main_tid);
|
||||
|
||||
assert(tool_data != nullptr);
|
||||
|
||||
rocprofiler_available_agents_cb_t iterate_cb =
|
||||
@@ -997,6 +1002,9 @@ tool_init(rocprofiler_client_finalize_t fini_func, void* tool_data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
write_json(call_stack_t* _call_stack);
|
||||
|
||||
void
|
||||
tool_fini(void* tool_data)
|
||||
{
|
||||
@@ -1006,6 +1014,8 @@ tool_fini(void* tool_data)
|
||||
stop();
|
||||
flush();
|
||||
|
||||
rocprofiler_get_timestamp(&fini_time);
|
||||
|
||||
std::cerr << "[" << getpid() << "][" << __FUNCTION__
|
||||
<< "] Finalizing... agents=" << agents.size()
|
||||
<< ", code_object_callback_records=" << code_object_records.size()
|
||||
@@ -1027,6 +1037,17 @@ tool_fini(void* tool_data)
|
||||
_call_stack->emplace_back(source_location{__FUNCTION__, __FILE__, __LINE__, ""});
|
||||
}
|
||||
|
||||
write_json(_call_stack);
|
||||
|
||||
std::cerr << "[" << getpid() << "][" << __FUNCTION__ << "] Finalization complete.\n"
|
||||
<< std::flush;
|
||||
|
||||
delete _call_stack;
|
||||
}
|
||||
|
||||
void
|
||||
write_json(call_stack_t* _call_stack)
|
||||
{
|
||||
auto ofname = std::string{"rocprofiler-tool-results.json"};
|
||||
if(auto* eofname = getenv("ROCPROFILER_TOOL_OUTPUT_FILE")) ofname = eofname;
|
||||
|
||||
@@ -1068,6 +1089,14 @@ tool_fini(void* tool_data)
|
||||
json_ar.setNextName("rocprofiler-sdk-json-tool");
|
||||
json_ar.startNode();
|
||||
|
||||
json_ar.setNextName("metadata");
|
||||
json_ar.startNode();
|
||||
json_ar(cereal::make_nvp("pid", getpid()));
|
||||
json_ar(cereal::make_nvp("main_tid", main_tid));
|
||||
json_ar(cereal::make_nvp("init_time", init_time));
|
||||
json_ar(cereal::make_nvp("fini_time", fini_time));
|
||||
json_ar.finishNode();
|
||||
|
||||
json_ar(cereal::make_nvp("agents", agents));
|
||||
if(_call_stack) json_ar(cereal::make_nvp("call_stack", *_call_stack));
|
||||
|
||||
@@ -1114,11 +1143,6 @@ tool_fini(void* tool_data)
|
||||
*ofs << std::flush;
|
||||
|
||||
if(cleanup) cleanup(ofs);
|
||||
|
||||
std::cerr << "[" << getpid() << "][" << __FUNCTION__ << "] Finalization complete.\n"
|
||||
<< std::flush;
|
||||
|
||||
delete _call_stack;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user