Files
rocm-systems/projects/rocprofiler-systems/source/python/CMakeLists.txt
T
Jonathan R. Madsen 0d5f0fb9cf Support for tracing mutex locking (#52)
* Parallel overhead example with locks

* Support tracing mutex locking + more

- support wrapping pthread_mutex_lock
- support wrapping pthread_mutex_unlock
- support wrapping pthread_mutex_trylock
- get_perfetto_combined_traces setting
- OMNITRACE_TRACE_THREAD_LOCKS option
- ThreadState
- critical trace includes queue id
- enabled/disabled settings in timemory
- fix OMNITRACE_TIMEMORY_COMPONENTS
- fix reading config
- fix setting categories
- applied ThreadState::Internal in various places
- utility::get_filled_array
- utility::get_reserved_vector
- utility::get_thread_index
- fork_gotcha messages about forks
- split out some pthread_gotcha functionality into pthread_create_gotcha
- handle queue id in roctracer callbacks

* Update timemory and PTL submodules

* Misc CMake updates

- Includes fix to omnitrace-static-lib{gcc,stdcxx}

* Misc cleanup to pthread_mutex_gotcha and backtrace

* Fix to duplicate field in module_function json

* Improvement to debug messages

* omnitrace-dl and common improvements

- tweak to delimit
- common::ignore message
- common::join quoting of strings
- omnitrace_set_env ignores if inited and active
- omnitrace_set_mpi ignores if inited and active

* nsync for transpose example

* Fix to thread_deleter<void> functor invoke

* Fix thread state and HIP stream enums

[ROCm/rocprofiler-systems commit: b208047741]
2022-05-08 04:40:10 -05:00

204 خطوط
7.1 KiB
CMake

# ########################################################################################
#
# omnitrace (Python)
#
# ########################################################################################
# if set, will screw up loading library
unset(CMAKE_DEBUG_POSTFIX)
set(CMAKE_CXX_CLANG_TIDY)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME python)
# ########################################################################################
function(OMNITRACE_CONFIGURE_PYTARGET _TARGET _VERSION)
add_library(omnitrace::${_TARGET} ALIAS ${_TARGET})
target_link_libraries(${_TARGET} PRIVATE libpyomnitrace-interface)
add_dependencies(libpyomnitrace ${_TARGET})
set_target_properties(
${_TARGET}
PROPERTIES PREFIX ""
OUTPUT_NAME libpyomnitrace
LIBRARY_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/lib/python/site-packages/omnitrace
ARCHIVE_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/lib/python/site-packages/omnitrace
RUNTIME_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/lib/python/site-packages/omnitrace
PDB_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/lib/python/site-packages/omnitrace
INSTALL_RPATH_USE_LINK_PATH ON
${EXTRA_PROPERTIES})
set(_PYLIB ${CMAKE_INSTALL_PYTHONDIR}/omnitrace)
if(NOT IS_ABSOLUTE "${_PYLIB}")
set(_PYLIB ${CMAKE_INSTALL_PREFIX}/${_PYLIB})
endif()
if(SKBUILD)
set(LIB_RELPATH ../../../..)
else()
file(RELATIVE_PATH LIB_RELPATH "${_PYLIB}"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif()
set_target_properties(
${_TARGET}
PROPERTIES
INSTALL_RPATH
"\$ORIGIN:\$ORIGIN/${LIB_RELPATH}:\$ORIGIN/../../../..:${CMAKE_INSTALL_RPATH}"
)
install(
TARGETS ${_TARGET}
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/omnitrace
OPTIONAL)
endfunction()
# ########################################################################################
add_library(omnitrace-python-compile-options INTERFACE)
add_library(omnitrace::omnitrace-python-compile-options ALIAS
omnitrace-python-compile-options)
add_target_cxx_flag_if_avail(
omnitrace-python-compile-options "-Wno-unused-value" "-Wno-range-loop-analysis"
"-Wno-deprecated-declarations" "-Wno-unused-but-set-parameter"
"-ftls-model=global-dynamic")
file(GLOB pyheaders ${CMAKE_CURRENT_LIST_DIR}/libpyomnitrace*.hpp)
set(pysources ${CMAKE_CURRENT_LIST_DIR}/libpyomnitrace.cpp)
set(pybind_libs pybind11::module)
add_library(libpyomnitrace-interface INTERFACE)
target_link_libraries(
libpyomnitrace-interface
INTERFACE pybind11::module
timemory::timemory-headers
omnitrace::omnitrace-headers
omnitrace::omnitrace-compile-options
omnitrace::omnitrace-lto
omnitrace::omnitrace-dl-library
omnitrace::omnitrace-python
omnitrace::omnitrace-python-compile-options)
omnitrace_target_compile_definitions(libpyomnitrace-interface
INTERFACE OMNITRACE_PYBIND11_SOURCE)
include(PyBind11Tools)
omnitrace_watch_for_change(OMNITRACE_PYTHON_ROOT_DIRS _PYTHON_DIRS_CHANGED)
if(_PYTHON_DIRS_CHANGED)
unset(OMNITRACE_PYTHON_VERSION CACHE)
unset(OMNITRACE_PYTHON_VERSIONS CACHE)
else()
foreach(_VAR PREFIX ENVS)
omnitrace_watch_for_change(OMNITRACE_PYTHON_${_VAR} _CHANGED)
if(_CHANGED)
unset(OMNITRACE_PYTHON_ROOT_DIRS CACHE)
unset(OMNITRACE_PYTHON_VERSIONS CACHE)
break()
endif()
endforeach()
endif()
if(OMNITRACE_PYTHON_PREFIX AND OMNITRACE_PYTHON_ENVS)
omnitrace_directory(
FAIL
PREFIX ${OMNITRACE_PYTHON_PREFIX}
PATHS ${OMNITRACE_PYTHON_ENVS}
OUTPUT_VARIABLE _PYTHON_ROOT_DIRS)
set(OMNITRACE_PYTHON_ROOT_DIRS
"${_PYTHON_ROOT_DIRS}"
CACHE INTERNAL "Root directories for python")
endif()
if(NOT OMNITRACE_PYTHON_VERSIONS AND OMNITRACE_PYTHON_VERSION)
set(OMNITRACE_PYTHON_VERSIONS "${OMNITRACE_PYTHON_VERSION}")
if(NOT OMNITRACE_PYTHON_ROOT_DIRS)
omnitrace_find_python(_PY VERSION ${OMNITRACE_PYTHON_VERSION})
set(OMNITRACE_PYTHON_ROOT_DIRS
"${_PY_ROOT_DIR}"
CACHE INTERNAL "" FORCE)
endif()
unset(OMNITRACE_PYTHON_VERSION CACHE)
elseif(
NOT OMNITRACE_PYTHON_VERSIONS
AND NOT OMNITRACE_PYTHON_VERSION
AND OMNITRACE_PYTHON_ROOT_DIRS)
set(_PY_VERSIONS)
foreach(_DIR ${OMNITRACE_PYTHON_ROOT_DIRS})
omnitrace_find_python(_PY ROOT_DIR ${_DIR})
if(NOT _PY_FOUND)
continue()
endif()
if(NOT "${_PY_VERSION}" IN_LIST _PY_VERSIONS)
list(APPEND _PY_VERSIONS "${_PY_VERSION}")
endif()
endforeach()
set(OMNITRACE_PYTHON_VERSIONS
"${_PY_VERSIONS}"
CACHE INTERNAL "" FORCE)
elseif(
NOT OMNITRACE_PYTHON_VERSIONS
AND NOT OMNITRACE_PYTHON_VERSION
AND NOT OMNITRACE_PYTHON_ROOT_DIRS)
omnitrace_find_python(_PY REQUIRED)
set(OMNITRACE_PYTHON_ROOT_DIRS
"${_PY_ROOT_DIR}"
CACHE INTERNAL "" FORCE)
set(OMNITRACE_PYTHON_VERSIONS
"${_PY_VERSION}"
CACHE INTERNAL "" FORCE)
endif()
omnitrace_watch_for_change(OMNITRACE_PYTHON_ROOT_DIRS)
omnitrace_watch_for_change(OMNITRACE_PYTHON_VERSIONS)
omnitrace_check_python_dirs_and_versions(FAIL)
add_custom_target(libpyomnitrace)
file(GLOB_RECURSE PYTHON_FILES ${CMAKE_CURRENT_SOURCE_DIR}/omnitrace/*.py)
foreach(_IN ${PYTHON_FILES})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/omnitrace"
"${PROJECT_BINARY_DIR}/lib/python/site-packages/omnitrace" _OUT
"${_IN}")
configure_file(${_IN} ${_OUT} @ONLY)
install(
FILES ${_OUT}
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/omnitrace
OPTIONAL)
endforeach()
omnitrace_python_console_script("omnitrace-python" "omnitrace")
set(_INDEX 0)
foreach(_VERSION ${OMNITRACE_PYTHON_VERSIONS})
# add_library(libpyomnitrace MODULE ${pysources} ${pyheaders})
list(GET OMNITRACE_PYTHON_ROOT_DIRS ${_INDEX} Python3_ROOT_DIR)
omnitrace_pybind11_add_module(
libpyomnitrace-${_VERSION} MODULE
PYTHON_VERSION ${_VERSION}
VISIBILITY "hidden" ${pysources} ${pyheaders})
omnitrace_configure_pytarget(libpyomnitrace-${_VERSION} ${_VERSION})
if(OMNITRACE_USE_PYTHON)
omnitrace_python_console_script(
"omnitrace-python" "omnitrace"
VERSION ${_VERSION}
ROOT_DIR "${Python3_ROOT_DIR}")
endif()
math(EXPR _INDEX "${_INDEX} + 1")
endforeach()
configure_file(${CMAKE_CURRENT_LIST_DIR}/setup.py.in
${PROJECT_BINARY_DIR}/lib/python/site-packages/setup.py @ONLY)
configure_file(${CMAKE_CURRENT_LIST_DIR}/setup.cfg.in
${PROJECT_BINARY_DIR}/lib/python/site-packages/setup.cfg @ONLY)
configure_file(${CMAKE_CURRENT_LIST_DIR}/pyproject.toml
${PROJECT_BINARY_DIR}/lib/python/site-packages/pyproject.toml COPYONLY)