-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LD_PRELOAD librocprofiler-sdk-roctx.so when marker-trace enabled (#1057)
* LD_PRELOAD librocprofiler-sdk-roctx.so when marker-trace enabled - this enables apps to link against old ROCTx (libroctx64.so) but get marker tracing in rocprofv3 * Update CHANGELOG * Validation test for app linked to old (roctracer) ROCTx library * Tweak scope of tool_counter_info - causing "signal-unsafe call inside of a signal" error for ThreadSanitizer on mi200 * Fix handling of missing transpose-roctracer-roctx * Disable rocprofv3 aborted-app test (ThreadSanitizer) - ThreadSanitizer + mi200/mi300 + aborted-app results in a signal-unsafe call inside a signal that cannot be specifically suppressed as usual via rocprofv3_error_signal_handler for some unknown reason * Add UndefinedBehaviorSanitizer job
- Loading branch information
Showing
13 changed files
with
266 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# | ||
# rocprofv3 tool test | ||
# | ||
cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR) | ||
|
||
project( | ||
rocprofiler-tests-roctracer-roctx-tracing | ||
LANGUAGES CXX | ||
VERSION 0.0.0) | ||
|
||
find_package(rocprofiler-sdk REQUIRED) | ||
|
||
string(REPLACE "LD_PRELOAD=" "ROCPROF_PRELOAD=" PRELOAD_ENV | ||
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV}") | ||
|
||
set(tracing-env "${PRELOAD_ENV}") | ||
|
||
rocprofiler_configure_pytest_files(CONFIG pytest.ini roctracer-roctx-input.yml | ||
COPY validate.py conftest.py) | ||
|
||
add_test( | ||
NAME rocprofv3-test-roctracer-roctx-trace-execute | ||
COMMAND | ||
$<TARGET_FILE:rocprofiler-sdk::rocprofv3> -i roctracer-roctx-input.yml -- | ||
$<IF:$<TARGET_EXISTS:transpose-roctracer-roctx>,$<TARGET_FILE:transpose-roctracer-roctx>,> | ||
) | ||
|
||
set_tests_properties( | ||
rocprofv3-test-roctracer-roctx-trace-execute | ||
PROPERTIES TIMEOUT 45 LABELS "integration-tests" ENVIRONMENT "${tracing-env}" | ||
DISABLED "$<IF:$<TARGET_EXISTS:transpose-roctracer-roctx>,OFF,ON>") | ||
|
||
add_test( | ||
NAME rocprofv3-test-roctracer-roctx-trace-validate | ||
COMMAND | ||
${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py --json-input | ||
${CMAKE_CURRENT_BINARY_DIR}/roctracer-roctx-trace/out_results.json | ||
--pftrace-input | ||
${CMAKE_CURRENT_BINARY_DIR}/roctracer-roctx-trace/out_results.pftrace | ||
--otf2-input ${CMAKE_CURRENT_BINARY_DIR}/roctracer-roctx-trace/out_results.otf2) | ||
|
||
set(VALIDATION_FILES | ||
${CMAKE_CURRENT_BINARY_DIR}/roctracer-roctx-trace/out_results.pftrace | ||
${CMAKE_CURRENT_BINARY_DIR}/roctracer-roctx-trace/out_results.json | ||
${CMAKE_CURRENT_BINARY_DIR}/roctracer-roctx-trace/out_results.otf2) | ||
|
||
set_tests_properties( | ||
rocprofv3-test-roctracer-roctx-trace-validate | ||
PROPERTIES TIMEOUT | ||
45 | ||
LABELS | ||
"integration-tests" | ||
DEPENDS | ||
"rocprofv3-test-roctracer-roctx-trace-execute" | ||
DISABLED | ||
"$<IF:$<TARGET_EXISTS:transpose-roctracer-roctx>,OFF,ON>" | ||
FAIL_REGULAR_EXPRESSION | ||
"AssertionError" | ||
ATTACHED_FILES_ON_FAIL | ||
"${VALIDATION_FILES}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import json | ||
import pytest | ||
|
||
from rocprofiler_sdk.pytest_utils.dotdict import dotdict | ||
from rocprofiler_sdk.pytest_utils import collapse_dict_list | ||
from rocprofiler_sdk.pytest_utils.perfetto_reader import PerfettoReader | ||
from rocprofiler_sdk.pytest_utils.otf2_reader import OTF2Reader | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--json-input", | ||
action="store", | ||
help="Path to JSON file.", | ||
) | ||
parser.addoption( | ||
"--pftrace-input", | ||
action="store", | ||
help="Path to Perfetto trace file.", | ||
) | ||
parser.addoption( | ||
"--otf2-input", | ||
action="store", | ||
help="Path to OTF2 trace file.", | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def json_data(request): | ||
filename = request.config.getoption("--json-input") | ||
with open(filename, "r") as inp: | ||
return dotdict(collapse_dict_list(json.load(inp))) | ||
|
||
|
||
@pytest.fixture | ||
def pftrace_data(request): | ||
filename = request.config.getoption("--pftrace-input") | ||
return PerfettoReader(filename).read()[0] | ||
|
||
|
||
@pytest.fixture | ||
def otf2_data(request): | ||
filename = request.config.getoption("--otf2-input") | ||
if not os.path.exists(filename): | ||
raise FileExistsError(f"{filename} does not exist") | ||
return OTF2Reader(filename).read()[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
[pytest] | ||
addopts = --durations=20 -rA -s -vv | ||
testpaths = validate.py | ||
pythonpath = @ROCPROFILER_SDK_TESTS_BINARY_DIR@/pytest-packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
jobs: | ||
- hsa_trace: False | ||
hip_trace: False | ||
kernel_trace: True | ||
memory_copy_trace: True | ||
marker_trace: True | ||
output_directory: "@CMAKE_CURRENT_BINARY_DIR@/roctracer-roctx-trace" | ||
output_file: out | ||
output_format: [pftrace, json, otf2] | ||
log_level: env | ||
kernel_rename: False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import pytest | ||
|
||
|
||
def test_marker_api_trace(json_data): | ||
data = json_data["rocprofiler-sdk-tool"] | ||
|
||
def get_kind_name(kind_id): | ||
return data["strings"]["buffer_records"][kind_id]["kind"] | ||
|
||
def get_region_name(corr_id): | ||
for itr in data["strings"]["marker_api"]: | ||
if itr.key == corr_id: | ||
return itr.value | ||
return None | ||
|
||
valid_domain = ("MARKER_CORE_API", "MARKER_CONTROL_API", "MARKER_NAME_API") | ||
|
||
buffer_records = data["buffer_records"] | ||
marker_data = buffer_records["marker_api"] | ||
tot_data = {} | ||
thr_data = {} | ||
for marker in marker_data: | ||
assert get_kind_name(marker["kind"]) in valid_domain | ||
assert marker.thread_id >= data["metadata"]["pid"] | ||
assert marker.end_timestamp >= marker.start_timestamp | ||
|
||
if marker.thread_id not in thr_data.keys(): | ||
thr_data[marker.thread_id] = {} | ||
|
||
corr_id = marker.correlation_id.internal | ||
assert corr_id > 0, f"{marker}" | ||
name = get_region_name(corr_id) | ||
if not name.startswith("roctracer/roctx"): | ||
assert "run" in name, f"{marker}" | ||
if name not in thr_data[marker.thread_id].keys(): | ||
thr_data[marker.thread_id][name] = 1 | ||
else: | ||
thr_data[marker.thread_id][name] += 1 | ||
|
||
if name not in tot_data.keys(): | ||
tot_data[name] = 1 | ||
else: | ||
tot_data[name] += 1 | ||
|
||
assert tot_data["roctracer/roctx v4.1"] == 1 | ||
assert tot_data["run"] == 2 | ||
assert tot_data["run/iteration"] == 1000 | ||
assert tot_data["run/iteration/sync"] == 100 | ||
assert tot_data["run/rank-0/thread-0/device-0/begin"] == 1 | ||
assert tot_data["run/rank-0/thread-0/device-0/end"] == 1 | ||
assert len(tot_data.keys()) >= 8 | ||
|
||
for tid, titr in thr_data.items(): | ||
assert titr["run"] == 1 | ||
assert titr["run/iteration"] == 500 | ||
assert titr["run/iteration/sync"] == 50 | ||
assert len(titr.keys()) >= 5 | ||
|
||
|
||
def test_perfetto_data(pftrace_data, json_data): | ||
import rocprofiler_sdk.tests.rocprofv3 as rocprofv3 | ||
|
||
rocprofv3.test_perfetto_data(pftrace_data, json_data, ("memory_copy", "marker")) | ||
|
||
|
||
def test_otf2_data(otf2_data, json_data): | ||
import rocprofiler_sdk.tests.rocprofv3 as rocprofv3 | ||
|
||
rocprofv3.test_otf2_data(otf2_data, json_data, ("memory_copy", "marker")) | ||
|
||
|
||
if __name__ == "__main__": | ||
exit_code = pytest.main(["-x", __file__] + sys.argv[1:]) | ||
sys.exit(exit_code) |
Oops, something went wrong.