Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
03d3472
Reorganize rocprofv3 python package
jrmadsen Jun 17, 2025
479bf4e
review comments
SrirakshaNag Jul 15, 2025
705692f
Removing extra lines
SrirakshaNag Jul 15, 2025
f50c459
fix format
SrirakshaNag Jul 15, 2025
1f7d9ec
Add lib/python3/site-packages to PYTHONPATH in setup-env.sh
jrmadsen Jul 23, 2025
023afdb
Merge commit '1f7d9ecbdba3067ecebcc71021a4b2f0127fe9be' into import/d…
systems-assistant[bot] Aug 7, 2025
20d3bb3
Merge branch 'develop' into import/develop/ROCm_rocprofiler-sdk/jomad…
jrmadsen Aug 26, 2025
3dffe3d
Merge branch 'develop' into import/develop/ROCm_rocprofiler-sdk/jomad…
SrirakshaNag Sep 8, 2025
960cbfc
Merge branch 'develop' into import/develop/ROCm_rocprofiler-sdk/jomad…
SrirakshaNag Sep 9, 2025
6d3361f
rocprof-compute update rocprofv3 avail lib path
vedithal-amd Sep 15, 2025
8736394
Merge branch 'develop' into import/develop/ROCm_rocprofiler-sdk/jomad…
vedithal-amd Sep 15, 2025
cd92637
Make rocprofv3 python binding build commands consistent with other py…
vedithal-amd Sep 15, 2025
a001652
fix cmake
vedithal-amd Sep 15, 2025
7003924
fix rocprof-compute
vedithal-amd Sep 15, 2025
e25a222
revert cmake changes
vedithal-amd Sep 15, 2025
6260e40
fix rocprofv3 avail python library
vedithal-amd Sep 15, 2025
538b07a
fix cmake
vedithal-amd Sep 15, 2025
88be74d
fix cmake
vedithal-amd Sep 15, 2025
0088d6e
Merge branch 'develop' into import/develop/ROCm_rocprofiler-sdk/jomad…
SrirakshaNag Sep 16, 2025
1fb82f2
Merge branch 'develop' into import/develop/ROCm_rocprofiler-sdk/jomad…
jrmadsen Sep 22, 2025
ada28ab
Merge branch 'develop' into import/develop/ROCm_rocprofiler-sdk/jomad…
vedithal-amd Sep 24, 2025
3e12de8
Merge branch 'develop' into import/develop/ROCm_rocprofiler-sdk/jomad…
SrirakshaNag Oct 6, 2025
fac4b49
Merge branch 'develop' into import/develop/ROCm_rocprofiler-sdk/jomad…
SrirakshaNag Oct 7, 2025
ce6df68
Merge branch 'develop' into import/develop/ROCm_rocprofiler-sdk/jomad…
SrirakshaNag Oct 9, 2025
8b9c40b
Merge branch 'develop' into import/develop/ROCm_rocprofiler-sdk/jomad…
SrirakshaNag Oct 9, 2025
d7de703
Merge branch 'develop' into import/develop/ROCm_rocprofiler-sdk/jomad…
SrirakshaNag Oct 14, 2025
23473cf
Merge branch 'develop' into import/develop/ROCm_rocprofiler-sdk/jomad…
SrirakshaNag Oct 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions projects/rocprofiler-compute/src/rocprof_compute_soc/soc_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,35 +468,35 @@ def get_rocprof_supported_counters(self) -> set[str]:
f"{get_submodules('rocprof_compute_profile')}"
)

# Point to counter definition
old_rocprofiler_metrics_path = os.environ.get("ROCPROFILER_METRICS_PATH")
os.environ["ROCPROFILER_METRICS_PATH"] = str(
config.rocprof_compute_home / "rocprof_compute_soc" / "profile_configs"
)
sys.path.append(
str(
Path(self.get_args().rocprofiler_sdk_library_path).parent.parent / "bin"
# Point to counter definition
old_rocprofiler_metrics_path = os.environ.get("ROCPROFILER_METRICS_PATH")
os.environ["ROCPROFILER_METRICS_PATH"] = str(
config.rocprof_compute_home / "rocprof_compute_soc" / "profile_configs"
)
)
from rocprofv3_avail_module import avail
sys.path.append(
str(
Path(self.get_args().rocprofiler_sdk_library_path).parent
/ "python3/site-packages"
)
)
from rocprofv3 import avail

avail.loadLibrary.libname = str(
Path(self.get_args().rocprofiler_sdk_library_path).parent.parent
/ "lib"
/ "rocprofiler-sdk"
/ "librocprofv3-list-avail.so"
)
counters = avail.get_counters()
rocprof_counters = {
counter.name
for counter in counters[list(counters.keys())[0]]
if hasattr(counter, "block") or hasattr(counter, "expression")
}
# Reset env. var.
if old_rocprofiler_metrics_path is None:
del os.environ["ROCPROFILER_METRICS_PATH"]
else:
os.environ["ROCPROFILER_METRICS_PATH"] = old_rocprofiler_metrics_path
avail.loadLibrary.libname = str(
Path(args.rocprofiler_sdk_library_path).parent
/ "rocprofiler-sdk"
/ "librocprofv3-list-avail.so"
)
counters = avail.get_counters()
rocprof_counters = {
counter.name
for counter in counters[list(counters.keys())[0]]
if hasattr(counter, "block") or hasattr(counter, "expression")
}
# Reset env. var.
if old_rocprofiler_metrics_path is None:
del os.environ["ROCPROFILER_METRICS_PATH"]
else:
os.environ["ROCPROFILER_METRICS_PATH"] = old_rocprofiler_metrics_path

return rocprof_counters

Expand Down
2 changes: 1 addition & 1 deletion projects/rocprofiler-sdk/cmake/Templates/modulefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ setenv @PACKAGE_NAME_UNDERSCORED@_ROOT "${ROOT}"
prepend-path CMAKE_PREFIX_PATH "${ROOT}"
prepend-path PATH "${ROOT}/bin"
prepend-path LD_LIBRARY_PATH "${ROOT}/@CMAKE_INSTALL_LIBDIR@"
prepend-path PYTHONPATH "${ROOT}/@CMAKE_INSTALL_PYTHONDIR@"
prepend-path PYTHONPATH "${ROOT}/@CMAKE_INSTALL_LIBDIR@/python3/site-packages"
setenv @PACKAGE_NAME_UNDERSCORED@_DIR "${ROOT}/@CMAKE_INSTALL_LIBDIR@/cmake/@PACKAGE_NAME@"
4 changes: 2 additions & 2 deletions projects/rocprofiler-sdk/cmake/Templates/setup-env.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ LD_LIBRARY_PATH=${BASEDIR}/@CMAKE_INSTALL_LIBDIR@:${LD_LIBRARY_PATH}
CMAKE_PREFIX_PATH=${BASEDIR}:${CMAKE_PREFIX_PATH}

if [ -z "@CMAKE_INSTALL_PYTHONDIR@" ]; then
PYTHONPATH=$(@PACKAGE_NAME_UNDERSCORED@_get_python3_path):${PYTHONPATH}
PYTHONPATH=$(@PACKAGE_NAME_UNDERSCORED@_get_python3_path):${BASEDIR}/@CMAKE_INSTALL_LIBDIR@/python3/site-packages:${PYTHONPATH}
else
PYTHONPATH=${BASEDIR}/@CMAKE_INSTALL_PYTHONDIR@:${PYTHONPATH}
PYTHONPATH=${BASEDIR}/@CMAKE_INSTALL_PYTHONDIR@:${BASEDIR}/@CMAKE_INSTALL_LIBDIR@/python3/site-packages:${PYTHONPATH}
fi

unset @PACKAGE_NAME_UNDERSCORED@_get_python3_path
Expand Down
2 changes: 0 additions & 2 deletions projects/rocprofiler-sdk/source/bin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

rocprofiler_activate_clang_tidy()

add_subdirectory(rocprofv3_avail_module)

# Adding main rocprofv3
configure_file(rocprofv3.py ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/rocprofv3 @ONLY)

Expand Down
27 changes: 25 additions & 2 deletions projects/rocprofiler-sdk/source/bin/rocprofv3-avail.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import os
import argparse
import sys
from rocprofv3_avail_module import avail


def format_help(formatter, w=120, h=40):
Expand Down Expand Up @@ -126,7 +125,7 @@ def add_parser_bool_argument(gparser, *args, **kwargs):

# Create the parser
parser = argparse.ArgumentParser(
description="ROCProfilerV3-avail Run Script",
description="rocprofv3 query tool for agents, counters, pc-sampling, and more",
usage="%(prog)s [options] ",
epilog=usage_examples,
formatter_class=format_help(argparse.RawTextHelpFormatter),
Expand Down Expand Up @@ -196,6 +195,8 @@ def get_number_columns(max_name_len):


def list_basic_agent(args, list_counters):
from rocprofv3 import avail

def print_agent_counter(counters):
names_len = [len(counter.name) for counter in counters]
names = [
Expand Down Expand Up @@ -235,6 +236,8 @@ def print_basic_info(info):


def list_pc_sampling(args):
from rocprofv3 import avail

sampling_agents = avail.get_pc_sample_configs()
agent_info_map = avail.get_agent_info_map()
print("Agents supporting PC Sampling\n")
Expand All @@ -249,6 +252,8 @@ def list_pc_sampling(args):


def info_pc_sampling(args):
from rocprofv3 import avail

sampling_agents = avail.get_pc_sample_configs()
agent_info_map = avail.get_agent_info_map()
for agent, configs in dict(sorted(sampling_agents.items())).items():
Expand All @@ -267,6 +272,8 @@ def info_pc_sampling(args):


def listing(args):
from rocprofv3 import avail

def print_agent_counter(counters):
names_len = [len(counter.name) for counter in counters]
names = [
Expand Down Expand Up @@ -306,6 +313,8 @@ def print_agent_counter(counters):


def info_pmc(args):
from rocprofv3 import avail

agent_counters = avail.get_counters()
agent_info_map = avail.get_agent_info_map()

Expand Down Expand Up @@ -367,6 +376,8 @@ def process_list(args):


def process_pmc_check(args):
from rocprofv3 import avail

def get_device_agent(device_id):
for agent, info in agent_info_map.items():
if info["type"] == 2 and info["logical_node_type_id"] == device_id:
Expand Down Expand Up @@ -469,6 +480,18 @@ def main(argv=None):
f"{ROCM_DIR}/lib/rocprofiler-sdk/librocprofv3-list-avail.so"
)
os.environ["ROCPROFILER_METRICS_PATH"] = f"{ROCM_DIR}/share/rocprofiler-sdk"
try:
# try to import rocprofv3 normally
from rocprofv3 import avail
except (ImportError, ModuleNotFoundError):
# if failed, find the python package for this python version
ROCPROFV3_AVAIL_PACKAGE = (
f"{ROCM_DIR}/lib/python{sys.version_info[0]}/site-packages"
Comment thread
vedithal-amd marked this conversation as resolved.
)
sys.path.append(ROCPROFV3_AVAIL_PACKAGE)

from rocprofv3 import avail

avail.loadLibrary.libname = os.environ.get(
"ROCPROF_LIST_AVAIL_TOOL_LIBRARY", ROCPROF_LIST_AVAIL_TOOL_LIBRARY
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ endif()

add_subdirectory(roctx)
add_subdirectory(rocpd)
add_subdirectory(rocprofv3)
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

set(PACKAGE_OUTPUT_DIR
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/rocprofv3_avail_module)
set(rocprofv3_PYTHON_SOURCES __init__.py avail.py)
rocprofiler_rocprofv3_python(${rocprofv3_PYTHON_SOURCES})

set(ROCPROFV3_AVAIL_SOURCES __init__.py avail.py)

foreach(_FILE ${ROCPROFV3_AVAIL_SOURCES})
configure_file(${CMAKE_CURRENT_LIST_DIR}/${_FILE} ${PACKAGE_OUTPUT_DIR}/${_FILE}
COPYONLY)
install(
FILES ${PACKAGE_OUTPUT_DIR}/${_FILE}
DESTINATION ${CMAKE_INSTALL_BINDIR}/rocprofv3_avail_module
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
COMPONENT tools)
endforeach()
rocprofiler_reset_python3_cache()
20 changes: 20 additions & 0 deletions projects/rocprofiler-sdk/source/lib/python/utilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,23 @@ function(rocprofiler_rocpd_python_bindings _VERSION)
DESTINATION ${rocpd_PYTHON_INSTALL_DIRECTORY}
COMPONENT rocpd)
endfunction()

function(rocprofiler_rocprofv3_python)
set(rocprofv3_PYTHON_INSTALL_DIRECTORY
${CMAKE_INSTALL_LIBDIR}/python3/site-packages/rocprofv3)
set(rocprofv3_PYTHON_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/${rocprofv3_PYTHON_INSTALL_DIRECTORY})
set(rocprofv3_PYTHON_SOURCES ${ARGN})
if(NOT rocprofv3_PYTHON_SOURCES)
message(
FATAL_ERROR "rocprofiler_rocprofv3_python requires specifying source files")
endif()
foreach(_SOURCE ${rocprofv3_PYTHON_SOURCES})
configure_file(${CMAKE_CURRENT_LIST_DIR}/${_SOURCE}
${rocprofv3_PYTHON_OUTPUT_DIRECTORY}/${_SOURCE} COPYONLY)
install(
FILES ${rocprofv3_PYTHON_OUTPUT_DIRECTORY}/${_SOURCE}
DESTINATION ${rocprofv3_PYTHON_INSTALL_DIRECTORY}
COMPONENT tools)
endforeach()
endfunction()
40 changes: 16 additions & 24 deletions projects/rocprofiler-sdk/tests/rocprofv3-avail/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,21 @@ set_tests_properties(
PROPERTIES TIMEOUT 45 LABELS "integration-tests" ENVIRONMENT
"${test-rocprofv3-avail-env}" DISABLED "${IS_DISABLED}")

if(TARGET rocprofv3-list-avail)
add_test(NAME rocprofv3-avail-test-validate
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py
--rocm-path ${rocprofiler-sdk_ROOT_DIR})

add_test(NAME rocprofv3-avail-test-validate
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py
--rocm-path ${CMAKE_BINARY_DIR})
set(test-rocprofv3-avail-validate-env "${PRELOAD_ENV}" "PYTHONPATH=$ENV{PYTHONPATH}")

# for validate, explicitly set ROCPROF_LIST_AVAIL_TOOL_LIBRARY since we copy
# rocprofv3-avail to directory
set(test-rocprofv3-avail-validate-env
"${PRELOAD_ENV}" "PYTHONPATH=$ENV{PYTHONPATH}:${CMAKE_BINARY_DIR}/bin/")

set_tests_properties(
rocprofv3-avail-test-validate
PROPERTIES TIMEOUT
45
LABELS
"integration-tests"
ENVIRONMENT
"${test-rocprofv3-avail-validate-env}"
FAIL_REGULAR_EXPRESSION
"${ROCPROFILER_DEFAULT_FAIL_REGEX}"
DEPENDS
rocprofv3-avail-test-copy-module
DISABLED
"${IS_DISABLED}")
endif()
set_tests_properties(
rocprofv3-avail-test-validate
PROPERTIES TIMEOUT
45
LABELS
"integration-tests"
ENVIRONMENT
"${test-rocprofv3-avail-validate-env}"
FAIL_REGULAR_EXPRESSION
"${ROCPROFILER_DEFAULT_FAIL_REGEX}"
DISABLED
"${IS_DISABLED}")
15 changes: 13 additions & 2 deletions projects/rocprofiler-sdk/tests/rocprofv3-avail/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import pandas as pd
import sys
import os
import pytest
from rocprofv3_avail_module import avail
import ctypes


def test_validate_metrics(rocm_path):
set_library(rocm_path)

from rocprofv3 import avail

lib = avail.get_library()

agent_counters_dict = avail.get_counters()
Expand All @@ -54,6 +55,9 @@ def test_validate_metrics(rocm_path):

def test_validate_list_pc_sample_config(rocm_path):
set_library(rocm_path)

from rocprofv3 import avail

lib = avail.get_library()

pc_sample_configs_dict = avail.get_pc_sample_configs()
Expand All @@ -73,6 +77,8 @@ def test_validate_list_pc_sample_config(rocm_path):
def test_counter_set(capsys, rocm_path):
set_library(rocm_path)

from rocprofv3 import avail

def get_counter_names(counter_ids):

counter_names = []
Expand Down Expand Up @@ -109,6 +115,11 @@ def get_agent_name(agent_id):


def set_library(rocm_path):
ROCPROFV3_AVAIL_PACKAGE = f"{rocm_path}/lib/python{sys.version_info[0]}/site-packages"
sys.path.append(ROCPROFV3_AVAIL_PACKAGE)

from rocprofv3 import avail

ROCPROF_LIST_AVAIL_TOOL_LIBRARY = (
f"{rocm_path}/lib/rocprofiler-sdk/librocprofv3-list-avail.so"
)
Expand Down
Loading