Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion 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 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 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 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 @@ -464,6 +475,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"
)
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
1 change: 1 addition & 0 deletions source/lib/python/CMakeLists.txt
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 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 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 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