Skip to content

Commit

Permalink
Adding python support with perfstubs 3.12+ support.
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed Oct 7, 2024
1 parent 4f82053 commit 5e91f3d
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[submodule "kokkos"]
path = kokkos
url = https://github.com/kokkos/kokkos
[submodule "perfstubs"]
branch = python-3.12
67 changes: 37 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -903,25 +903,50 @@ else()
"Try manually check out https://github.com/cameron314/concurrentqueue.git to ${PROJECT_SOURCE_DIR}")
endif()

### Set up perfstubs stuff
git_external(perfstubs
https://github.com/khuck/perfstubs.git
### Set up rapidjson stuff - before perfstubs, it is a dependency there, too
git_external(rapidjson
https://github.com/miloyip/rapidjson.git
master
VERBOSE)

find_file(
PERFSTUBS_HEADER
NAMES perfstubs_api/tool.h
PATHS ${PROJECT_SOURCE_DIR}/perfstubs)
find_path(
RAPIDJSON_INCLUDE_DIR
NAMES rapidjson
PATHS ${PROJECT_SOURCE_DIR}/rapidjson/include)

if(PERFSTUBS_HEADER)
message(INFO " Found perfstubs at ${PROJECT_SOURCE_DIR}/perfstubs")
include_directories(${PROJECT_SOURCE_DIR}/perfstubs)
if(RAPIDJSON_INCLUDE_DIR)
message(INFO " Found rapidjson at ${RAPIDJSON_INCLUDE_DIR}")
include_directories(${RAPIDJSON_INCLUDE_DIR})
else()
message(FATAL_ERROR " perfstubs not found. This should have been checked out automatically. "
"Try manually check out https://github.com/khuck/perfstubs.git to ${PROJECT_SOURCE_DIR}")
message(FATAL_ERROR " rapidjson not found. This should have been checked out automatically. "
"Try manually check out https://github.com/miloyip/rapidjson.git to ${PROJECT_SOURCE_DIR}")
endif()

### Set up perfstubs stuff
git_external(perfstubs
https://github.com/khuck/perfstubs.git
python-3.12
VERBOSE)

if(APEX_WITH_PYTHON)
set(PERFSTUBS_WITH_PYTHON ON CACHE BOOL "Enable Python Support" FORCE)
add_subdirectory(perfstubs)
include_directories(${PROJECT_SOURCE_DIR}/perfstubs)
else(APEX_WITH_PYTHON)
find_file(
PERFSTUBS_HEADER
NAMES perfstubs_api/tool.h
PATHS ${PROJECT_SOURCE_DIR}/perfstubs)

if(PERFSTUBS_HEADER)
message(INFO " Found perfstubs at ${PROJECT_SOURCE_DIR}/perfstubs")
include_directories(${PROJECT_SOURCE_DIR}/perfstubs)
else()
message(FATAL_ERROR " perfstubs not found. This should have been checked out automatically. "
"Try manually check out https://github.com/khuck/perfstubs.git to ${PROJECT_SOURCE_DIR}")
endif()
endif(APEX_WITH_PYTHON)

### Set up taskStubs stuff
git_external(taskStubs
https://github.com/khuck/taskStubs.git
Expand All @@ -947,24 +972,6 @@ if(APEX_WITH_PLUGINS)
add_definitions("-DAPEX_WITH_PLUGINS")
endif()

git_external(rapidjson
https://github.com/miloyip/rapidjson.git
master
VERBOSE)

find_path(
RAPIDJSON_INCLUDE_DIR
NAMES rapidjson
PATHS ${PROJECT_SOURCE_DIR}/rapidjson/include)

if(RAPIDJSON_INCLUDE_DIR)
message(INFO " Found rapidjson at ${RAPIDJSON_INCLUDE_DIR}")
include_directories(${RAPIDJSON_INCLUDE_DIR})
else()
message(FATAL_ERROR " rapidjson not found. This should have been checked out automatically. "
"Try manually check out https://github.com/miloyip/rapidjson.git to ${PROJECT_SOURCE_DIR}")
endif()

################################################################################
# Standard Library configuration
################################################################################
Expand Down
1 change: 1 addition & 0 deletions cmake/Modules/APEX_DefaultOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ option (APEX_WITH_PAPI "Enable PAPI support" FALSE)
option (APEX_WITH_PERFETTO "Enable native Perfetto trace support" FALSE)
option (APEX_WITH_PHIPROF "Enable APEX PhiProf support" FALSE)
option (APEX_WITH_PLUGINS "Enable APEX policy plugin support" TRUE)
option (APEX_WITH_PYTHON "Enable APEX Python support through perfstubs module" FALSE)
option (APEX_WITH_STARPU "Enable APEX StarPU support" FALSE)
option (APEX_WITH_TCMALLOC "Enable TCMalloc heap management" FALSE)
option (APEX_USE_PEDANTIC "Enable pedantic compiler flags" FALSE)
Expand Down
28 changes: 28 additions & 0 deletions src/scripts/apex_exec
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ where APEX options are zero or more of:
--apex:hip-details enable per-kernel statistics where available (default: off)
--apex:monitor-gpu enable GPU monitoring services (CUDA NVML, ROCm SMI)
--apex:level0 enable OneAPI Level0 measurement (default: off)
--apex:python enable Python profiling support (requires configuration support)
--apex:python-filter <filename> enable Python profiling support of Python internals
--apex:cpuinfo enable sampling of /proc/cpuinfo (Linux only)
--apex:meminfo enable sampling of /proc/meminfo (Linux only)
--apex:net enable sampling of /proc/net/dev (Linux only)
Expand Down Expand Up @@ -112,6 +114,8 @@ raja=no
otf2=no
gtrace=no
pftrace=no
python=no
python_internals=no
scatter=no
taskgraph=no
tasktree=no
Expand Down Expand Up @@ -191,6 +195,21 @@ while (( "$#" )); do
raja=yes
shift
;;
--apex:python)
python=yes
shift
;;
--apex:python-filter)
python=yes
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
filter_file=$2
export PERFSTUBS_PYTHON_FILTER_FILENAME=${filter_file}
shift 2
else
echo "Error: Argument for $1 is missing" >&2
usage
fi
;;
--apex:debug)
debug=yes
if [ "$debugger" == "" ] ; then
Expand Down Expand Up @@ -762,6 +781,15 @@ fi
if [ ${raja} = yes ] ; then
export RAJA_PLUGINS=${BASEDIR}/${LIBDIR}/${APEX_LIBRARY_NAME}${SHLIBX}
fi
if [ ${python} = yes ] ; then
export PYTHONPATH=${BASEDIR}/${LIBDIR}:${PYTHONPATH}
# kind of abusing this label, maybe rename it to "wrapper executable?"
if [ ${debug} = yes ] ; then
debugger="python3 -m pdb -m pstubs"
else
debugger="python3 -m pstubs"
fi
fi
if [ ${openacc} = yes ] ; then
export ACC_PROFLIB=${BASEDIR}/${LIBDIR}/${APEX_LIBRARY_NAME}${SHLIBX}
fi
Expand Down

0 comments on commit 5e91f3d

Please sign in to comment.