diff --git a/.gitmodules b/.gitmodules index 5ba1764e..cc5cfece 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,5 @@ [submodule "kokkos"] path = kokkos url = https://github.com/kokkos/kokkos +[submodule "perfstubs"] + branch = python-3.12 diff --git a/CMakeLists.txt b/CMakeLists.txt index 3682df8e..55b0cc9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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 ################################################################################ diff --git a/cmake/Modules/APEX_DefaultOptions.cmake b/cmake/Modules/APEX_DefaultOptions.cmake index 5c5e6207..1a6f0c5c 100644 --- a/cmake/Modules/APEX_DefaultOptions.cmake +++ b/cmake/Modules/APEX_DefaultOptions.cmake @@ -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) diff --git a/src/scripts/apex_exec b/src/scripts/apex_exec index d624fcbd..91ab00e4 100755 --- a/src/scripts/apex_exec +++ b/src/scripts/apex_exec @@ -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 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) @@ -112,6 +114,8 @@ raja=no otf2=no gtrace=no pftrace=no +python=no +python_internals=no scatter=no taskgraph=no tasktree=no @@ -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 @@ -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