Skip to content

Commit

Permalink
Adding python 3.12+ support using perfstubs python module.
Browse files Browse the repository at this point in the history
Former-commit-id: 48411ce96bd11e8d67058152045e673f708e7c37
  • Loading branch information
khuck committed Nov 1, 2024
1 parent 312b168 commit cf1ae38
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 11 deletions.
5 changes: 4 additions & 1 deletion Makefile.skel
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ examples/cthreads examples/fortran examples/f90 $(MPIEXAMPLES) $(PDTEXAMPLE)
# ZeroSum Support
#ZeroSum#ZeroSum=zerosum#ENDIF#

# PerfStubs Support
#PerfStubs#PerfStubs=perfstubs#ENDIF#

# Trace Reader Library
TRACEINPUT=src/TraceInput
TRACE2PROFILE=utils/trace2profile
Expand Down Expand Up @@ -154,7 +157,7 @@ SUBDIR = $(TRACEINPUT) $(BASIC) $(PCXX) $(HPCXX) $(ANSIC) $(VTFCONVERTER) \
$(PTHREAD_WRAPPER) \
$(MEMORYWRAPPER) $(TAUCUDA) $(TAU_CUPTI_AVAIL) $(TAU_ENV) $(TAUOPENCL) \
$(GPIWRAPPER) $(ARMCIWRAPPER) $(DMAPPWRAPPER) $(UGNIWRAPPER) $(CHAPELWRAPPER) $(UPCWRAPPER) \
$(GOMP_WRAPPER) $(OTF2PROFILE) $(MPC_MPI_WRAPPER) $(APEX) $(ZeroSum) \
$(GOMP_WRAPPER) $(OTF2PROFILE) $(MPC_MPI_WRAPPER) $(APEX) $(ZeroSum) $(PerfStubs) \
$(SHMEM_WRAPPER) $(PLUGINS) $(LLVM_PLUGIN) \
$(SYSCALL_WRAPPER)

Expand Down
51 changes: 45 additions & 6 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -11668,12 +11668,12 @@ build_apex() {
build_zerosum() {
cd ${START_DIR}
#check_cmake 3 20 "ZeroSum"
#result=$?
#if [ $result -eq 1 ]; then
# echo 'ERROR: cmake version 3.20 or higher required to build ZeroSum.'
# exit 1;
#fi
check_cmake 3 20 "ZeroSum"
result=$?
if [ $result -eq 1 ]; then
echo 'ERROR: cmake version 3.20 or higher required to build ZeroSum.'
exit 1;
fi
echo "NOTE: Building ZeroSum"
if [ ! -d zerosum ] ; then
git submodule update --init --recursive zerosum
Expand Down Expand Up @@ -11707,6 +11707,35 @@ build_zerosum() {
make -C zerosum
}
build_perfstubs() {
cd ${START_DIR}
check_cmake 3 20 "ZeroSum"
result=$?
if [ $result -eq 1 ]; then
echo 'ERROR: cmake version 3.20 or higher required to build ZeroSum.'
exit 1;
fi
echo "NOTE: Building PerfStubs with Python3.12+ support"
if [ ! -d perfstubs ] ; then
git submodule update --init --recursive perfstubs
fi
perfstubs_include_file=perfstubs/perfstubs.mk
Python3_BIN_DIR=`dirname ${pythonintv}`
Python3_ROOT_DIR=`dirname ${Python3_BIN_DIR}`
rm -f ${perfstubs_include_file}
touch ${perfstubs_include_file}
echo "CC=${c_compiler}" >> ${perfstubs_include_file}
echo "CXX=${cxx_compiler}" >> ${perfstubs_include_file}
echo "PREFIX=${targetdir}" >> ${perfstubs_include_file}
echo "TAUARCH=${architecture}" >> ${perfstubs_include_file}
echo "TAUOPTIONS=${tauoptions}" >> ${perfstubs_include_file}
echo "TAUPYTHON=-DPERFSTUBS_WITH_PYTHON=TRUE -DPython3_ROOT_DIR=${Python3_ROOT_DIR} -DPython3_VERSION_MINOR=${Python3_VERSION_MINOR}" >> ${perfstubs_include_file}
cp etc/Makefile.perfstubs perfstubs/Makefile
fixmakeargs="$fixmakeargs PerfStubs "
make -C perfstubs clean
make -C perfstubs
}
if [ $java = yes ] ; then
fixmakeargs="$fixmakeargs JAVA jdkdir=$jdkdir"
fi
Expand Down Expand Up @@ -13559,6 +13588,16 @@ fi
if [ $zerosum = yes ] ; then
build_zerosum
fi
if [ $python3 = yes ] ; then
python_version=`${pythonintv} --version | awk '{print $NF}'`
version_array=( ${python_version//./ } )
if [ "${version_array[0]}" == 3 ] ; then
if [ "${version_array[1]}" -gt 11 ] ; then
Python3_VERSION_MINOR=${version_array[1]}
build_perfstubs
fi
fi
fi
# Save the FixMakefile args
# Clear any old data
Expand Down
14 changes: 14 additions & 0 deletions etc/Makefile.perfstubs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include perfstubs.mk

build/CMakeCache.txt:
cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DCMAKE_INSTALL_PREFIX=$(PREFIX)/$(TAUARCH) $(TAUPYTHON) $(TAUCFLAGS) $(TAUCXXFLAGS)

all : build/CMakeCache.txt
$(MAKE) -C build all

install: all
$(MAKE) -C build install

clean:
rm -rf build

14 changes: 14 additions & 0 deletions etc/Makefile.zerosum
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include zerosum.mk

build/CMakeCache.txt:
cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DZeroSum_BUILD_TESTS=FALSE -DCMAKE_INSTALL_PREFIX=$(PREFIX)/$(TAUARCH) $(TAUOMPT) $(TAUCFLAGS) $(TAUCXXFLAGS) $(TAUCUDA) $(TAUHIP) $(TAUSYCL)

all : build/CMakeCache.txt
$(MAKE) -C build all

install: all
$(MAKE) -C build install

clean:
rm -rf build

17 changes: 17 additions & 0 deletions examples/python/python_event_filter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"exclude_timers comment":
"Use this entry as an array of regular expression strings for timers to exclude (all others will be included). Remove the '_disabled' part of the name to enable it.",
"exclude_timers_disabled": ["_find_and_load.*"],

"exclude_files comment":
"Use this entry as an array of regular expression strings for files/paths to exclude (all others will be included). Remove the '_disabled' part of the name to enable it.",
"exclude_files": ["<frozen.*", "/usr/lib/python.*"],

"exclude_timers comment":
"Use this entry as an array of regular expression strings for timers to include (all others will be excluded). Remove the '_disabled' part of the name to enable it.",
"include_timers_disabled": ["firstPrimeAfter.*"],

"exclude_files comment":
"Use this entry as an array of regular expression strings for files/paths to include (all others will be excluded). Remove the '_disabled' part of the name to enable it.",
"include_files_disabled": ["/path/to/included/file"]
}
29 changes: 25 additions & 4 deletions tools/src/tau_exec
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ if tau-config | grep -q 'PYTHONINT=python3' 2>/dev/null ; then
python_interpreter=python3
fi

python_module_name=tau_python_wrapper
python_version=`${python_interpreter} --version | awk '{print $NF}'`
version_array=( ${python_version//./ } )
if [ "${version_array[0]}" == 3 ] ; then
if [ "${version_array[1]}" -gt 11 ] ; then
python_module_name=pstubs
fi
fi

if [ "$scriptname" == "tau_python" ] ; then
python_wrapper=true
Expand Down Expand Up @@ -106,6 +114,8 @@ usage()
if [ $python_wrapper = "true" ] ; then
echo " -tau-python-args=<\"arguments\"> Arguments to the python interpreter"
echo " -tau-python-interpreter=<\"python\"> name of python interpreter (e.g, python, python3.6)"
echo " -tau-python-filter=<\"filename\"> name of selective measurement JSON file"
fi
echo " -adios2 Write output to ADIOS2 archive"
echo " -adios2_trace Write trace output to ADIOS2 archive"
echo " -monitoring Periodically read available OS/HW monitoring counters"
Expand All @@ -115,7 +125,6 @@ if [ $python_wrapper = "true" ] ; then
echo " -disable-kokkos Disable Kokkos profiling (removes fences that hurt performance)"
echo " -ugni Track Cray UGNI network library functions."
echo " -chapel Track Cray Chapel network atomics library functions."
fi
echo ""
echo "Notes:"
echo " Defaults if unspecified: -T $default_tags"
Expand Down Expand Up @@ -695,6 +704,18 @@ for arg in "$@" ; do
exit 1
fi
;;
-tau-python-filter=*)
if [ $python_wrapper = "true" ] ; then
myarg=`echo $arg | sed 's/-tau-python-filter=//'`
python_filter="$myarg"
export PERFSTUBS_PYTHON_FILTER_FILENAME=$python_filter
save_arg $arg
shift
else
echo "Unknown option: $arg" >&2
exit 1
fi
;;
-ugni)
track_ugni=true
save_arg $arg
Expand Down Expand Up @@ -837,7 +858,7 @@ else
fi

python_bindings=`echo $theBinding | sed -e 's/shared/bindings/'`
export PYTHONPATH=$BASEDIR/lib/$python_bindings:$PYTHONPATH
export PYTHONPATH=${BASEDIR}/lib:$BASEDIR/lib/$python_bindings:$PYTHONPATH

if [ "x$LD_LIBRARY_PATH" = "x" ] ; then
TAUEX_LD_LIBRARY_PATH=$BASEDIR/lib/$theBinding:$BASEDIR/lib
Expand Down Expand Up @@ -1416,9 +1437,9 @@ else
$dryrun $python_interpreter $py_interp_args -m tau_pyspark_wrapper "$@"
elif $python_wrapper ; then
if [ $python_launch_module = "true" ] ; then
$dryrun $python_interpreter $py_interp_args -m tau_python_wrapper -m $python_m_arg "$@"
$dryrun $python_interpreter $py_interp_args -m ${python_module_name} -m $python_m_arg "$@"
else
$dryrun $python_interpreter $py_interp_args -m tau_python_wrapper "$@"
$dryrun $python_interpreter $py_interp_args -m ${python_module_name} "$@"
fi
retval=$?
elif $use_ptts ; then
Expand Down
3 changes: 3 additions & 0 deletions utils/FixMakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2159,6 +2159,9 @@ case $1 in
ZeroSum)
echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
;;
PerfStubs)
echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
;;
BOOST)
echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
;;
Expand Down

0 comments on commit cf1ae38

Please sign in to comment.