Skip to content

Commit 15e6e6d

Browse files
authored
Fix setup-env + hsa/rocm/ompt serialization + testing + misc (#156)
- Fix setup-env.sh - Closes #149 - omnitrace exe color - test-install.sh script - if config variable is updated in config or env, include in generated config - metadata for hsa, rocm, and ompt - Closes #153 - Closes #154
1 parent 4ed8f8f commit 15e6e6d

File tree

17 files changed

+499
-113
lines changed

17 files changed

+499
-113
lines changed

.github/workflows/ubuntu-focal.yml

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ jobs:
214214
wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - &&
215215
echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${{ matrix.rocm_version }}/ ubuntu main" | tee /etc/apt/sources.list.d/rocm.list &&
216216
apt-get update &&
217-
apt-get install -y build-essential m4 autoconf libtool python3-pip clang libomp-dev ${{ matrix.compiler }} libudev-dev libnuma1 rocm-dev rocm-utils rocm-smi-lib roctracer-dev rocprofiler-dev hip-base hsa-amd-aqlprofile hsa-rocr-dev hsakmt-roct-dev libpapi-dev curl libopenmpi-dev openmpi-bin libfabric-dev &&
217+
apt-get install -y build-essential m4 autoconf libtool python3-pip clang libomp-dev ${{ matrix.compiler }} libudev1 libnuma1 rocm-dev rocm-utils rocm-smi-lib roctracer-dev rocprofiler-dev hip-base hsa-amd-aqlprofile hsa-rocr-dev hsakmt-roct-dev libpapi-dev curl libopenmpi-dev openmpi-bin libfabric-dev &&
218218
python3 -m pip install --upgrade pip &&
219219
python3 -m pip install 'cmake==3.21.4' &&
220220
for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done
@@ -423,12 +423,19 @@ jobs:
423423
timeout-minutes: 10
424424
run:
425425
sudo apt-get update &&
426-
sudo apt-get install -y build-essential m4 autoconf libtool python3-pip ${{ matrix.deps }} clang libomp-dev ${{ matrix.compiler }} ${{ matrix.mpi }} &&
426+
sudo apt-get install -y build-essential m4 autoconf libtool python3-pip clang libomp-dev environment-modules ${{ matrix.deps }} ${{ matrix.compiler }} ${{ matrix.mpi }} &&
427427
python3 -m pip install --upgrade pip &&
428428
python3 -m pip install numpy &&
429429
python3 -m pip install perfetto &&
430430
python3 -m pip install 'cmake==3.16.3'
431431

432+
- name: Test Environment Modules
433+
timeout-minutes: 15
434+
run: |
435+
set -v
436+
source /usr/share/modules/init/$(basename ${SHELL})
437+
module avail
438+
432439
- name: Configure Env
433440
run:
434441
echo "CC=$(echo '${{ matrix.compiler }}' | sed 's/+/c/g')" >> $GITHUB_ENV &&
@@ -461,6 +468,21 @@ jobs:
461468
-DDYNINST_ELFUTILS_DOWNLOAD_VERSION=${{ env.ELFUTILS_DOWNLOAD_VERSION }}
462469
-DOMNITRACE_MAX_THREADS=32
463470

471+
- name: Test Build-Tree Env
472+
timeout-minutes: 60
473+
run:
474+
source /usr/share/modules/init/$(basename ${SHELL})
475+
module use ${{ github.workspace }}/build/share/modulefiles
476+
module avail
477+
module load omnitrace
478+
module list
479+
env
480+
module unload omnitrace
481+
module list
482+
env
483+
source ${{ github.workspace }}/build/share/omnitrace/setup-env.sh
484+
env
485+
464486
- name: Build
465487
timeout-minutes: 60
466488
run:
@@ -480,41 +502,21 @@ jobs:
480502
mkdir -p /opt/omnitrace
481503
./omnitrace-*.sh --prefix=/opt/omnitrace --exclude-subdir --skip-license
482504
483-
- name: Test Install
505+
- name: Test Install with setup-env.sh
484506
timeout-minutes: 15
485507
run: |
486508
set -v
487509
source /opt/omnitrace/share/omnitrace/setup-env.sh
488-
cat << EOF > ${HOME}/.omnitrace.cfg
489-
OMNITRACE_VERBOSE = 2
490-
OMNITRACE_USE_TIMEMORY = ON
491-
OMNITRACE_USE_PERFETTO = ON
492-
OMNITRACE_USE_SAMPLING = ON
493-
OMNITRACE_USE_PROCESS_SAMPLING = ON
494-
OMNITRACE_OUTPUT_PATH = omnitrace-tests-output
495-
OMNITRACE_OUTPUT_PREFIX = %tag%/
496-
OMNITRACE_SAMPLING_FREQ = 50
497-
OMNITRACE_SAMPLING_DELAY = 0.05
498-
EOF
499-
which omnitrace-avail
500-
ldd $(which omnitrace-avail)
501-
omnitrace-avail --help
502-
omnitrace-avail -a
503-
which omnitrace-critical-trace
504-
ldd $(which omnitrace-critical-trace)
505-
which omnitrace-python
506-
omnitrace-python --help
507-
omnitrace-python -b -- ${{ github.workspace }}/examples/python/builtin.py
508-
which omnitrace
509-
ldd $(which omnitrace)
510-
omnitrace --help
511-
omnitrace -e -v 1 -o ls.inst --simulate -- ls
512-
for i in $(find omnitrace-tests-output/ls.inst -type f); do echo -e "\n\n --> ${i} \n\n"; cat ${i}; done
513-
omnitrace -e -v 1 -o ls.inst -- ls
514-
./ls.inst
515-
omnitrace -e -v 1 --simulate -- ls
516-
for i in $(find omnitrace-tests-output/ls -type f); do echo -e "\n\n --> ${i} \n\n"; cat ${i}; done
517-
omnitrace -e -v 1 -- ls
510+
${{ github.workspace }}/scripts/test-install.sh --test-omnitrace{,-avail,-python,-rewrite,-runtime,-critical-trace}=1
511+
512+
- name: Test Install with Modulefile
513+
timeout-minutes: 15
514+
run: |
515+
set -v
516+
source /usr/share/modules/init/$(basename ${SHELL})
517+
module use /opt/omnitrace/share/modulefiles
518+
module load omnitrace
519+
${{ github.workspace }}/scripts/test-install.sh --test-omnitrace{,-avail,-python,-rewrite,-runtime,-critical-trace}=1
518520
519521
- name: Test User API
520522
timeout-minutes: 10

cmake/BuildSettings.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ add_flag_if_avail(
8383
"-Wno-attributes" "-Wno-missing-field-initializers")
8484

8585
if(OMNITRACE_BUILD_DEBUG)
86-
add_flag_if_avail("-g" "-gdwarf-3" "-fno-omit-frame-pointer")
86+
add_flag_if_avail("-g3" "-gdwarf-3" "-fno-omit-frame-pointer")
8787
endif()
8888

8989
if(WIN32)

cmake/Modules/Findroctracer.cmake

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,47 @@ find_library(
7070
PATHS ${roctracer_ROOT_DIR} ${_ROCM_ROCTRACER_PATHS}
7171
PATH_SUFFIXES lib lib64)
7272

73+
# try not to directly use the hsakmt::hsakmt target because it hardcodes the
74+
# INTERFACE_LINK_LIBRARIES used when it was built
7375
find_package(hsakmt HINTS ${_ROCM_ROCTRACER_PATHS} PATHS ${_ROCM_ROCTRACER_PATHS})
7476

7577
if(hsakmt_FOUND)
76-
set(roctracer_hsakmt_LIBRARY
77-
hsakmt::hsakmt
78-
CACHE STRING "Imported hsakmt target")
78+
add_library(roctracer::hsakmt INTERFACE IMPORTED)
79+
get_target_property(hsakmt_INCLUDE_DIR hsakmt::hsakmt INTERFACE_INCLUDE_DIRECTORIES)
80+
target_include_directories(roctracer::hsakmt INTERFACE ${hsakmt_INCLUDE_DIR})
81+
set(hsakmt_FOUND_LIBS ON)
82+
foreach(_LIB drm drm_amdgpu rt c numa udev)
83+
set(_LIB_NAMES ${_LIB})
84+
foreach(_EXT 2 1)
85+
list(
86+
APPEND
87+
_LIB_NAMES
88+
${CMAKE_SHARED_LIBRARY_PREFIX}${_LIB}${CMAKE_SHARED_LIBRARY_SUFFIX}.${_EXT}
89+
)
90+
endforeach()
91+
find_library(
92+
hsakmt_${_LIB}_LIBRARY
93+
NAMES ${_LIB_NAMES}
94+
HINTS ${_ROCM_ROCTRACER_PATHS}
95+
PATHS ${_ROCM_ROCTRACER_PATHS}
96+
PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} lib lib64)
97+
if(NOT hsakmt_${_LIB}_LIBRARY)
98+
set(hsakmt_FOUND_LIBS OFF)
99+
else()
100+
target_link_libraries(roctracer::hsakmt INTERFACE ${hsakmt_${_LIB}_LIBRARY})
101+
endif()
102+
endforeach()
103+
if(hsakmt_FOUND_LIBS)
104+
find_package(Threads REQUIRED)
105+
target_link_libraries(roctracer::hsakmt INTERFACE Threads::Threads)
106+
set(roctracer_hsakmt_LIBRARY
107+
roctracer::hsakmt
108+
CACHE STRING "Generated hsakmt target for roctracer")
109+
else()
110+
set(roctracer_hsakmt_LIBRARY
111+
hsakmt::hsakmt
112+
CACHE STRING "Imported hsakmt target")
113+
endif()
79114
else()
80115
find_library(
81116
roctracer_hsakmt_LIBRARY

cmake/Templates/setup-env.sh.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
BASEDIR=$(dirname ${BASH_SOURCE[0]})
4-
BASEDIR=$(cd ${BASEDIR}/../.. && pwd)
4+
command -v realpath &> /dev/null && BASEDIR=$(realpath ${BASEDIR}/../..) || BASEDIR=$(cd ${BASEDIR}/../.. && pwd)
55

66
if [ ! -d "${BASEDIR}" ]; then
77
echo "${BASEDIR} does not exist"

docker/Dockerfile.ubuntu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ENV PATH ${HOME}/.local/bin:${PATH}
2222

2323
RUN apt-get update && \
2424
apt-get dist-upgrade -y && \
25-
apt-get install -y build-essential cmake libnuma1 wget gnupg2 m4 bash-completion git-core autoconf libtool autotools-dev python3-pip lsb-release libpapi-dev libpfm4-dev libudev-dev libopenmpi-dev rpm librpm-dev curl && \
25+
apt-get install -y build-essential cmake libnuma1 wget gnupg2 m4 bash-completion git-core autoconf libtool autotools-dev python3-pip lsb-release libpapi-dev libpfm4-dev libudev1 libopenmpi-dev rpm librpm-dev curl && \
2626
python3 -m pip install 'cmake==3.21.4' && \
2727
wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - && \
2828
echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${ROCM_REPO_VERSION}/ ${ROCM_REPO_DIST} main" | tee /etc/apt/sources.list.d/rocm.list && \

scripts/test-install.sh

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
#!/bin/bash -e
2+
3+
SCRIPT_DIR=$(realpath $(dirname ${BASH_SOURCE[0]}))
4+
cd $(dirname ${SCRIPT_DIR})
5+
echo -e "Working directory: $(pwd)"
6+
7+
: ${SLEEP_TIME:=0}
8+
9+
error-message()
10+
{
11+
echo -e "\nError! ${@}\n"
12+
exit -1
13+
}
14+
15+
verbose-run()
16+
{
17+
echo -e "\n##### Executing \"${@}\"... #####\n"
18+
sleep ${SLEEP_TIME}
19+
eval $@
20+
}
21+
22+
if [ -d "$(realpath /tmp)" ]; then
23+
: ${TMPDIR:=/tmp}
24+
export TMPDIR
25+
fi
26+
27+
: ${CONFIG_DIR:=$(mktemp -t -d omnitrace-test-install-XXXX)}
28+
: ${SOURCE_DIR:=$(dirname ${SCRIPT_DIR})}
29+
: ${ENABLE_OMNITRACE:=1}
30+
: ${ENABLE_OMNITRACE_AVAIL:=1}
31+
: ${ENABLE_OMNITRACE_PYTHON:=0}
32+
: ${ENABLE_OMNITRACE_REWRITE:=1}
33+
: ${ENABLE_OMNITRACE_RUNTIME:=1}
34+
: ${ENABLE_OMNITRACE_CRITICAL_TRACE:=1}
35+
36+
usage()
37+
{
38+
print_option() { printf " --%-10s %-24s %s (default: %s)\n" "${1}" "${2}" "${3}" "${4}"; }
39+
echo "Options:"
40+
print_option source-dir "<PATH>" "Location of source directory" "${SOURCE_DIR}"
41+
print_option test-omnitrace "0|1" "Enable testing omnitrace exe" "${ENABLE_OMNITRACE}"
42+
print_option test-omnitrace-avail "0|1" "Enable testing omnitrace-avail" "${ENABLE_OMNITRACE_AVAIL}"
43+
print_option test-omnitrace-python "0|1" "Enable testing omnitrace-python" "${ENABLE_OMNITRACE_PYTHON}"
44+
print_option test-omnitrace-rewrite "0|1" "Enable testing omnitrace binary rewrite" "${ENABLE_OMNITRACE_REWRITE}"
45+
print_option test-omnitrace-runtime "0|1" "Enable testing omnitrace runtime instrumentation" "${ENABLE_OMNITRACE_RUNTIME}"
46+
print_option test-omnitrace-critial-trace "0|1" "Enable testing omnitrace critical trace" "${ENABLE_OMNITRACE_CRITICAL_TRACE}"
47+
}
48+
49+
cat << EOF > ${CONFIG_DIR}/omnitrace.cfg
50+
OMNITRACE_VERBOSE = 2
51+
OMNITRACE_USE_TIMEMORY = ON
52+
OMNITRACE_USE_PERFETTO = ON
53+
OMNITRACE_USE_SAMPLING = ON
54+
OMNITRACE_USE_PROCESS_SAMPLING = ON
55+
OMNITRACE_OUTPUT_PATH = %env{CONFIG_DIR}%/omnitrace-tests-output
56+
OMNITRACE_OUTPUT_PREFIX = %tag%/
57+
OMNITRACE_SAMPLING_FREQ = 100
58+
OMNITRACE_SAMPLING_DELAY = 0.05
59+
OMNITRACE_COUT_OUTPUT = ON
60+
OMNITRACE_TIME_OUTPUT = OFF
61+
OMNITRACE_USE_PID = OFF
62+
EOF
63+
64+
export CONFIG_DIR
65+
export OMNITRACE_CONFIG_FILE=${CONFIG_DIR}/omnitrace.cfg
66+
verbose-run cat ${OMNITRACE_CONFIG_FILE}
67+
68+
while [[ $# -gt 0 ]]
69+
do
70+
ARG=${1}
71+
shift
72+
73+
VAL="$(echo ${ARG} | sed 's/=/ /1' | awk '{print $2}')"
74+
if [ -z "${VAL}" ]; then
75+
while [[ $# -gt 0 ]]
76+
do
77+
VAL=${1}
78+
shift
79+
break
80+
done
81+
else
82+
ARG="$(echo ${ARG} | sed 's/=/ /1' | awk '{print $1}')"
83+
fi
84+
85+
if [ -z "${VAL}" ]; then
86+
echo "Error! Missing value for argument \"${ARG}\""
87+
usage
88+
exit -1
89+
fi
90+
91+
case "${ARG}" in
92+
--test-omnitrace)
93+
ENABLE_OMNITRACE=${VAL}
94+
continue
95+
;;
96+
--test-omnitrace-avail)
97+
ENABLE_OMNITRACE_AVAIL=${VAL}
98+
continue
99+
;;
100+
--test-omnitrace-python)
101+
ENABLE_OMNITRACE_PYTHON=${VAL}
102+
continue
103+
;;
104+
--test-omnitrace-rewrite)
105+
ENABLE_OMNITRACE_REWRITE=${VAL}
106+
continue
107+
;;
108+
--test-omnitrace-runtime)
109+
ENABLE_OMNITRACE_RUNTIME=${VAL}
110+
continue
111+
;;
112+
--test-omnitrace-critical-trace)
113+
ENABLE_OMNITRACE_CRITICAL_TRACE=${VAL}
114+
continue
115+
;;
116+
--source-dir)
117+
SOURCE_DIR=${VAL}
118+
continue
119+
;;
120+
*)
121+
echo -e "Error! Unknown option : ${ARG}"
122+
usage
123+
exit -1
124+
;;
125+
esac
126+
done
127+
128+
test-omnitrace()
129+
{
130+
verbose-run which omnitrace
131+
verbose-run ldd $(which omnitrace)
132+
verbose-run omnitrace --help
133+
}
134+
135+
test-omnitrace-avail()
136+
{
137+
verbose-run which omnitrace-avail
138+
verbose-run ldd $(which omnitrace-avail)
139+
verbose-run omnitrace-avail --help
140+
verbose-run omnitrace-avail -a
141+
}
142+
143+
test-omnitrace-python()
144+
{
145+
verbose-run which omnitrace-python
146+
verbose-run omnitrace-python --help
147+
verbose-run omnitrace-python -b -- ${SOURCE_DIR}/examples/python/builtin.py -n 5 -v 5
148+
verbose-run omnitrace-python -b -- ${SOURCE_DIR}/examples/python/noprofile.py -n 5 -v 5
149+
verbose-run omnitrace-python -- ${SOURCE_DIR}/examples/python/external.py -n 5 -v 5
150+
verbose-run python3 ${SOURCE_DIR}/examples/python/source.py -n 5 -v 5
151+
}
152+
153+
test-omnitrace-rewrite()
154+
{
155+
verbose-run omnitrace -e -v 1 -o ${CONFIG_DIR}/ls.inst --simulate -- ls
156+
for i in $(find ${CONFIG_DIR}/omnitrace-tests-output/ls.inst -type f); do verbose-run ls ${i}; done
157+
verbose-run omnitrace -e -v 1 -o ${CONFIG_DIR}/ls.inst -- ls
158+
verbose-run ${CONFIG_DIR}/ls.inst
159+
}
160+
161+
test-omnitrace-runtime()
162+
{
163+
verbose-run omnitrace -e -v 1 --simulate -- ls
164+
for i in $(find ${CONFIG_DIR}/omnitrace-tests-output/ls -type f); do verbose-run ls ${i}; done
165+
verbose-run omnitrace -e -v 1 -- ls
166+
}
167+
168+
test-omnitrace-critical-trace()
169+
{
170+
which omnitrace-critical-trace
171+
ldd $(which omnitrace-critical-trace)
172+
}
173+
174+
if [ "${ENABLE_OMNITRACE}" -ne 0 ]; then verbose-run test-omnitrace; fi
175+
if [ "${ENABLE_OMNITRACE_AVAIL}" -ne 0 ]; then verbose-run test-omnitrace-avail; fi
176+
if [ "${ENABLE_OMNITRACE_PYTHON}" -ne 0 ]; then verbose-run test-omnitrace-python; fi
177+
if [ "${ENABLE_OMNITRACE_REWRITE}" -ne 0 ]; then verbose-run test-omnitrace-rewrite; fi
178+
if [ "${ENABLE_OMNITRACE_RUNTIME}" -ne 0 ]; then verbose-run test-omnitrace-runtime; fi
179+
if [ "${ENABLE_OMNITRACE_CRITICAL_TRACE}" -ne 0 ]; then verbose-run test-omnitrace-critical-trace; fi

source/bin/omnitrace-avail/avail.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,11 @@ write_settings_info(std::ostream& os, const array_t<bool, N>& opts,
802802
if(category_view.count(citr) > 0) _found = true;
803803
}
804804
if(!print_advanced && _categories.count("settings::advanced") > 0)
805-
_not_in_category_view.emplace(_name);
805+
{
806+
if(!sitr->second->get_config_updated() &&
807+
!sitr->second->get_environ_updated())
808+
_not_in_category_view.emplace(_name);
809+
}
806810
if(!_found)
807811
{
808812
_not_in_category_view.emplace(_name);

source/bin/omnitrace-avail/generate_config.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ ignore_setting(const Tp& _v)
6262
{
6363
if(_v->get_hidden()) return true;
6464
if(exclude_setting(_v->get_env_name())) return true;
65+
if(_v->get_config_updated() || _v->get_environ_updated()) return false;
6566
if(!is_selected(_v->get_env_name()) && !is_selected(_v->get_name())) return true;
6667
if(available_only && !_v->get_enabled()) return true;
6768
if(!category_view.empty())

0 commit comments

Comments
 (0)