2918251d9c
* Add external/cereal submodule
- used for integration testing
* Update lib/common/container/small_vector.hpp
- documentation notes
* Update tests/apps
- update transpose app (fix build)
- add reproducible-runtime app
* Update include/rocprofiler/fwd.h
- rocprofiler_service_callback_phase_t -> rocprofiler_callback_phase_t
* Update PTL submodule
- fix for task group: submitting tasks from different thread
* Update lib/rocprofiler/hsa/queue.cpp
- CHECK_NOTNULL(_buffer)
* Update lib/rocprofiler/hsa/hsa.cpp
- use buffer::get_buffer instead of manually looking for buffer
* Update lib/rocprofiler/internal_threading.cpp
- use buffer::get_buffer instead of manually looking for buffer
* Update lib/rocprofiler/buffer.cpp
- offset the buffer id
- properly handle rocprofiler_create_buffer reusing rocprofiler_buffer_id_t on a different context
* Update tests
- kernel tracing library for integration testing
* Add cereal submodule
* Update lib/rocprofiler/registration.*
- OnUnload
- Support ROCP_TOOL_LIBRARIES for python usage
- improve finalize function
- remove calling hsa_shut_down in finalize function
* Update lib/rocprofiler/buffer.*
- allocate_buffer sets the buffer id value
- expose (internally) is_valid_buffer_id
- update test
* Update tests/kernel-tracing
- installation
- better organization of JSON groups
- improved messaging
* Update lib/rocprofiler/registration.cpp
- add workaround for hsa-runtime supporting rocprofiler-register
* Update tests/kernel-tracing/kernel-tracing.cpp
- fix memory leaks
* cereal support for minimal JSON
- update cereal submodule to rocprofiler branch
- change REPO_BRANCH in rocprofiler_checkout_git_submodule for cereal
- update tests/kernel-tracing/kernel-tracing.cpp
- use minimal json
- slight tweak putting giving contexts name in storing name + context pointer pair in map
* Update tests/kernel-tracing/kernel-tracing.cpp
- support runtime selection of contexts via KERNEL_TRACING_CONTEXTS environment variable
* Update tests
- tests/CMakeLists.txt
- find_package(Python3 REQUIRED)
- tests/kernel-tracing
- pytest validation
* Update CI workflow
- install pytest
- add checks for test labels
* Update scripts/run-ci.py
- change --coverage options
- replace 'unittests' with 'tests'
- replace test label regex '-L unittests' with '-L tests'
* Update requirements.txt
- this is now an empty file since none of the packages are required for this repo
[ROCm/rocprofiler-sdk commit: cf5e4b4b1b]
118 lines
4.3 KiB
Python
118 lines
4.3 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
import pytest
|
|
|
|
|
|
# helper function
|
|
def node_exists(name, data, min_len=1):
|
|
assert name in data
|
|
assert data[name] is not None
|
|
assert len(data[name]) >= min_len
|
|
|
|
|
|
def test_data_structure(input_data):
|
|
"""verify minimum amount of expected data is present"""
|
|
data = input_data
|
|
|
|
node_exists("kernel-tracing-test-tool", data)
|
|
node_exists("agents", data["kernel-tracing-test-tool"])
|
|
node_exists("call_stack", data["kernel-tracing-test-tool"])
|
|
node_exists("callback_records", data["kernel-tracing-test-tool"])
|
|
node_exists("buffer_records", data["kernel-tracing-test-tool"])
|
|
|
|
node_exists("names", data["kernel-tracing-test-tool"]["callback_records"])
|
|
node_exists("code_objects", data["kernel-tracing-test-tool"]["callback_records"])
|
|
node_exists("kernel_symbols", data["kernel-tracing-test-tool"]["callback_records"])
|
|
node_exists("hsa_api_traces", data["kernel-tracing-test-tool"]["callback_records"])
|
|
|
|
node_exists("names", data["kernel-tracing-test-tool"]["buffer_records"])
|
|
node_exists("kernel_dispatches", data["kernel-tracing-test-tool"]["buffer_records"])
|
|
node_exists("memory_copies", data["kernel-tracing-test-tool"]["buffer_records"], 0)
|
|
node_exists("hsa_api_traces", data["kernel-tracing-test-tool"]["buffer_records"])
|
|
|
|
|
|
def test_timestamps(input_data):
|
|
data = input_data
|
|
|
|
cb_start = {}
|
|
cb_end = {}
|
|
for itr in data["kernel-tracing-test-tool"]["callback_records"]["hsa_api_traces"]:
|
|
cid = itr["record"]["correlation_id"]["internal"]
|
|
phase = itr["record"]["phase"]
|
|
if phase == 1:
|
|
cb_start[cid] = itr["timestamp"]
|
|
elif phase == 2:
|
|
cb_end[cid] = itr["timestamp"]
|
|
assert cb_start[cid] <= itr["timestamp"]
|
|
else:
|
|
assert phase == 1 or phase == 2
|
|
|
|
for itr in data["kernel-tracing-test-tool"]["buffer_records"]["hsa_api_traces"]:
|
|
assert itr["start_timestamp"] <= itr["end_timestamp"]
|
|
|
|
for itr in data["kernel-tracing-test-tool"]["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"]
|
|
|
|
|
|
def test_internal_correlation_ids(input_data):
|
|
data = input_data
|
|
|
|
api_corr_ids = []
|
|
for itr in data["kernel-tracing-test-tool"]["callback_records"]["hsa_api_traces"]:
|
|
api_corr_ids.append(itr["record"]["correlation_id"]["internal"])
|
|
|
|
for itr in data["kernel-tracing-test-tool"]["buffer_records"]["hsa_api_traces"]:
|
|
api_corr_ids.append(itr["correlation_id"]["internal"])
|
|
|
|
api_corr_ids_sorted = sorted(api_corr_ids)
|
|
api_corr_ids_unique = list(set(api_corr_ids))
|
|
|
|
len_corr_id_unq = len(api_corr_ids_unique)
|
|
assert len(api_corr_ids) != len_corr_id_unq
|
|
assert max(api_corr_ids_sorted) == len_corr_id_unq
|
|
|
|
|
|
def test_external_correlation_ids(input_data):
|
|
data = input_data
|
|
|
|
for itr in data["kernel-tracing-test-tool"]["callback_records"]["hsa_api_traces"]:
|
|
assert itr["record"]["thread_id"] == itr["record"]["correlation_id"]["external"]
|
|
|
|
for itr in data["kernel-tracing-test-tool"]["buffer_records"]["hsa_api_traces"]:
|
|
assert itr["thread_id"] == itr["correlation_id"]["external"]
|
|
|
|
|
|
def test_kernel_ids(input_data):
|
|
data = input_data
|
|
|
|
symbol_info = {}
|
|
for itr in data["kernel-tracing-test-tool"]["callback_records"]["kernel_symbols"]:
|
|
phase = itr["record"]["phase"]
|
|
payload = itr["payload"]
|
|
kern_id = payload["kernel_id"]
|
|
|
|
assert phase == 1 or phase == 2
|
|
assert kern_id > 0
|
|
if phase == 1:
|
|
assert len(payload["kernel_name"]) > 0
|
|
symbol_info[kern_id] = payload
|
|
elif phase == 2:
|
|
assert payload["kernel_id"] in symbol_info.keys()
|
|
assert payload["kernel_name"] == symbol_info[kern_id]["kernel_name"]
|
|
|
|
for itr in data["kernel-tracing-test-tool"]["buffer_records"]["kernel_dispatches"]:
|
|
assert itr["kernel_id"] in symbol_info.keys()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
exit_code = pytest.main(["-x", __file__] + sys.argv[1:])
|
|
sys.exit(exit_code)
|