ae8f72fa79
* Use native tool for counter collection
* Add native counter collection tool which uses rocprofiler-sdk C++
library public API to get counter collection data
* This is enabled by default, unless --no-native-tool option is
provided or ROCPROF=rocprofv3 env. var. is provided
* This tool is only supported for ROCm version >=7.x.x
* This tool is not supported for attach/detach scenario
* Build native tool shared object during build time
* If using rocprof-compute without building then runtime compilation of
t push native tool shared object is performed
* rocprofiler-sdk tools is still used for services other than counter
collection and data collected by native tool is merged into the
rocpd/csv output of rocprofiler-sdk tool
* Make `rocpd` choice the default choice for `--format-rocprof-output`
option
* If `rocpd` public API from rocprofiler-sdk library is not present,
then fallback to `csv` choice
* In this case only `pmc_perf.csv` is written in workload folder
instead of multiple `csv` files for each profiling run
* Remove `json` choice from `--format-rocprof-output` option since it
functions identical to `csv` option
* Rename option `--rocprofiler-sdk-library-path` to
`--rocprofiler-sdk-tool-path` since we LD_PRELOAD the
rocprofiler-sdk tool shared object and not the rocprofiler-sdk library
shared object
* Fix the meaning of `--dispatch` option in `profile` mode to mention
dispatch iteration filtering instead of dispatch id filtering
* --dispatch option in analyze mode does dispatch id filtering
* Move standalone binary creation logic from cmake file to docker file
* fix native counter collection tool during attach/detach
* improve logging
* fix attach detach with native tool
* fix attach detach with native tool
* do not support attach/detach in native tool
* Update changelog
* add standalone binary creation functionality in cmake
* address review comments
* address review comments
* fix formatting
* address review comments
* Adding paths for cmake to search. Also updated min. cmake requirement to 3.21 as this was when hip was supported.
Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>
* Update hip compiler ID check, sometimes comes up as Clang, sometimes ROCMClang- depends on setup.
Updated formatting.
Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>
* RHEL8.10 unable to compile due to defaulting to old c++ version, need to force c++17
Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>
* Updating changelog per docs team recommendations
Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>
* Apply suggestions from code review to changelog
Co-authored-by: Pratik Basyal <pratik.basyal@amd.com>
* Do not required HIP complier to build native counter collection tool
* fix cmake
* gersemi formatting on latest cmake change
Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>
* ex ci updated dependencies to include rocprofiler-sdk, but cmake was still not capturing the path- there was a commit that added to the cmake_prefix_path entry that specified rocprof-sdk's cmake location ut was too specific for the search paths in find_package's config mode.
removing the cmake_prefix_path var and adding hints to find_package call instead, and specifying config mode so it knows how to construct the search paths
Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>
* gersemi run for formatting
Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>
* Still need prefix path, should not have been removed in last commit but does need to be shortened to just the rocm path to allow for find_package config mode to do the job
Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>
* include cstdint for uint32_t
* Run formatting on helper.cpp
Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>
* Remove rocm 7.2 release stuff from version and changelog and handle it in separate pr
* fix version
* fix changelog
* fix changelog
* run ruff formatter
Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>
* fix rocprofiler-sdk attach so path
---------
Signed-off-by: Carrie Fallows <Carrie.Fallows@amd.com>
Co-authored-by: Carrie Fallows <Carrie.Fallows@amd.com>
Co-authored-by: Pratik Basyal <pratik.basyal@amd.com>
177 lines
5.9 KiB
Python
177 lines
5.9 KiB
Python
##############################################################################
|
|
# MIT License
|
|
#
|
|
# Copyright (c) 2025 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 os
|
|
import subprocess
|
|
import sys
|
|
from importlib.machinery import SourceFileLoader
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
ROOT = os.path.dirname(os.path.dirname(__file__))
|
|
SRC = os.path.join(ROOT, "src")
|
|
if SRC not in sys.path:
|
|
sys.path.insert(0, SRC)
|
|
|
|
rocprof_compute = SourceFileLoader(
|
|
"rocprof-compute", "src/rocprof-compute"
|
|
).load_module()
|
|
|
|
|
|
def pytest_addoption(parser):
|
|
parser.addoption(
|
|
"--call-binary",
|
|
action="store_true",
|
|
default=False,
|
|
help="Call standalone binary instead of main function during tests",
|
|
)
|
|
|
|
parser.addoption(
|
|
"--rocprofiler-sdk-tool-path",
|
|
type=str,
|
|
default=str(
|
|
Path(os.getenv("ROCM_PATH", "/opt/rocm"))
|
|
/ "lib/rocprofiler-sdk/librocprofiler-sdk-tool.so"
|
|
),
|
|
help="Path to the rocprofiler-sdk tool",
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def binary_handler_profile_rocprof_compute(request):
|
|
def _handler(
|
|
config,
|
|
workload_dir,
|
|
options=[],
|
|
check_success=True,
|
|
roof=False,
|
|
app_name="app_1",
|
|
attach_detach_para=None,
|
|
):
|
|
if request.config.getoption("--rocprofiler-sdk-tool-path"):
|
|
options.extend(
|
|
[
|
|
"--rocprofiler-sdk-tool-path",
|
|
request.config.getoption("--rocprofiler-sdk-tool-path"),
|
|
],
|
|
)
|
|
if request.config.getoption("--call-binary"):
|
|
baseline_opts = [
|
|
"build/rocprof-compute.bin",
|
|
"profile",
|
|
"-n",
|
|
app_name,
|
|
"-VVV",
|
|
]
|
|
if not roof:
|
|
baseline_opts.append("--no-roof")
|
|
|
|
command_rocprof_compute = baseline_opts + options + ["--path", workload_dir]
|
|
if not attach_detach_para:
|
|
command_rocprof_compute = (
|
|
command_rocprof_compute + ["--"] + config[app_name]
|
|
)
|
|
else:
|
|
command_rocprof_compute = command_rocprof_compute + [
|
|
"--attach-pid",
|
|
str(attach_detach_para["attach_pid"]),
|
|
]
|
|
if attach_detach_para["attach-duration-msec"]:
|
|
command_rocprof_compute = command_rocprof_compute + [
|
|
"--attach-duration-msec",
|
|
str(attach_detach_para["attach-duration-msec"]),
|
|
]
|
|
|
|
process = subprocess.run(
|
|
command_rocprof_compute,
|
|
text=True,
|
|
)
|
|
# verify run status
|
|
if check_success:
|
|
assert process.returncode == 0
|
|
return process.returncode
|
|
else:
|
|
baseline_opts = [
|
|
"install/bin/rocprof-compute",
|
|
"profile",
|
|
"-n",
|
|
app_name,
|
|
"-VVV",
|
|
]
|
|
if not roof:
|
|
baseline_opts.append("--no-roof")
|
|
|
|
command_rocprof_compute = baseline_opts + options + ["--path", workload_dir]
|
|
if not attach_detach_para:
|
|
command_rocprof_compute = (
|
|
command_rocprof_compute + ["--"] + config[app_name]
|
|
)
|
|
else:
|
|
command_rocprof_compute = command_rocprof_compute + [
|
|
"--attach-pid",
|
|
str(attach_detach_para["attach_pid"]),
|
|
]
|
|
if attach_detach_para["attach-duration-msec"]:
|
|
command_rocprof_compute = command_rocprof_compute + [
|
|
"--attach-duration-msec",
|
|
str(attach_detach_para["attach-duration-msec"]),
|
|
]
|
|
|
|
with pytest.raises(SystemExit) as e:
|
|
with patch(
|
|
"sys.argv",
|
|
command_rocprof_compute,
|
|
):
|
|
rocprof_compute.main()
|
|
# verify run status
|
|
if check_success:
|
|
assert e.value.code == 0
|
|
return e.value.code
|
|
|
|
return _handler
|
|
|
|
|
|
@pytest.fixture
|
|
def binary_handler_analyze_rocprof_compute(request):
|
|
def _handler(arguments):
|
|
if request.config.getoption("--call-binary"):
|
|
process = subprocess.run(
|
|
["build/rocprof-compute.bin", *arguments],
|
|
text=True,
|
|
)
|
|
return process.returncode
|
|
else:
|
|
with pytest.raises(SystemExit) as e:
|
|
with patch(
|
|
"sys.argv",
|
|
["rocprof-compute", *arguments],
|
|
):
|
|
rocprof_compute.main()
|
|
return e.value.code
|
|
|
|
return _handler
|