Files
rocm-systems/cmake/rocprofiler_memcheck.cmake
T
Jonathan R. Madsen b12ef4a75e Buffering: initial implementation and tests (#20)
* Update source/lib/common

- CMakeLists.txt
  - less verbose
  - rocprofiler-common-library uses rocprofiler-headers target
- mpl.hpp
  - metaprogramming header with type_list, size_of, index_of, and is_one_of
- record_header_buffer.{hpp,cpp}
  - wrapper class around atomic_ring_buffer and vector of rocprofiler_record_header_t
- atomic_ring_buffer.{hpp,cpp}
  - request function accepts wrap param when overwritting is not desirable
  - can_clear member function
  - clear member function for rewinding write pointer to start of buffer
- containers/CMakeLists.txt
  - include record_header_buffer.{hpp,cpp} in build target

* Update source/lib/tests: Buffering tests

- Added buffering tests. See comments in code for description

* atomic_ring_buffer -> ring_buffer

- remove ring_buffer implementation
- rename atomic_ring_buffer to ring_buffer

* atomic_ring_buffer -> ring_buffer

- remove ring_buffer implementation
- rename atomic_ring_buffer to ring_buffer

* Update record_header_buffer

- lock, unlock, is_locked, clear, save, and load member functions

* Buffering tests

- add buffer test for save/load capability

* Update rocprofiler_memcheck.cmake

- fix erroneous spaces causing incorrect string evaluation

* Update ring_buffer

- fix exception message

* undef HIP_PROF_API

- make sure HIP_PROF_API is undefined before including hip_runtime.h
- avoid directly including hip/hip_runtime.h

* Update rocprofiler_config_interfaces

- remove stale preprocessor defines that are from old rocprofiler/roctracer
  - HIP_PROF_HIP_API_STRING=1
  - PROF_API_IMPL=1

* Update run-ci.py

- fix paths to suppression files
- improve printing logs to console in github actions

* Update buffering implementation

- remove support for using malloc instead of mmap in ring_buffer
- provide some info functions in record_header_buffer
- improve the testing of the save-load buffer test

* Update run-ci.py

- fix CTEST_CUSTOM_COVERAGE_EXCLUDE

* Update hip/api_args.h

- remove undef HIP_PROF_API

* Update buffering-save-load.cpp

- updated comments

* Update record_header_buffer

- default ctor
- allocate member function
- is_allocated member function

* Update buffering-save-load.cpp

- tweaked usage of record_header_buffer to delay allocation
2023-08-30 11:34:03 -05:00

70 lines
2.6 KiB
CMake

#
#
#
set(ROCPROFILER_MEMCHECK_TYPES "ThreadSanitizer" "AddressSanitizer" "LeakSanitizer"
"MemorySanitizer" "UndefinedBehaviorSanitizer")
if(ROCPROFILER_MEMCHECK AND NOT ROCPROFILER_MEMCHECK IN_LIST ROCPROFILER_MEMCHECK_TYPES)
message(
FATAL_ERROR
"Unsupported memcheck type '${ROCPROFILER_MEMCHECK}'. Options: ${ROCPROFILER_MEMCHECK_TYPES}"
)
endif()
set_property(CACHE ROCPROFILER_MEMCHECK PROPERTY STRINGS "${ROCPROFILER_MEMCHECK_TYPES}")
function(rocprofiler_add_memcheck_flags _TYPE)
target_compile_options(
rocprofiler-memcheck
INTERFACE $<BUILD_INTERFACE:-g3 -Og -fno-omit-frame-pointer
-fno-optimize-sibling-calls -fno-inline-functions -fsanitize=${_TYPE}>)
target_link_options(rocprofiler-memcheck INTERFACE
$<BUILD_INTERFACE:-fsanitize=${_TYPE} -Wl,--no-undefined>)
endfunction()
function(rocprofiler_set_memcheck_env _TYPE _LIB_BASE)
set(_LIBS ${_LIB_BASE})
foreach(_N 6 5 4 3 2 1 0)
list(
APPEND _LIBS
${CMAKE_SHARED_LIBRARY_PREFIX}${_LIB_BASE}${CMAKE_SHARED_LIBRARY_SUFFIX}.${_N}
)
endforeach()
foreach(_LIB ${_LIBS})
if(NOT ${_TYPE}_LIBRARY)
find_library(${_TYPE}_LIBRARY NAMES ${_LIB} ${ARGN})
endif()
endforeach()
target_link_libraries(rocprofiler-memcheck INTERFACE ${_LIB_BASE})
if(${_TYPE}_LIBRARY)
set(ROCPROFILER_MEMCHECK_PRELOAD_ENV
"LD_PRELOAD=${${_TYPE}_LIBRARY}"
CACHE INTERNAL "LD_PRELOAD env variable for tests " FORCE)
endif()
endfunction()
# always unset so that it doesn't preload if memcheck disabled
unset(ROCPROFILER_MEMCHECK_PRELOAD_ENV CACHE)
if(ROCPROFILER_MEMCHECK STREQUAL "AddressSanitizer")
rocprofiler_add_memcheck_flags("address")
rocprofiler_set_memcheck_env("${ROCPROFILER_MEMCHECK}" "asan")
elseif(ROCPROFILER_MEMCHECK STREQUAL "LeakSanitizer")
rocprofiler_add_memcheck_flags("leak")
rocprofiler_set_memcheck_env("${ROCPROFILER_MEMCHECK}" "lsan")
elseif(ROCPROFILER_MEMCHECK STREQUAL "MemorySanitizer")
rocprofiler_add_memcheck_flags("memory")
elseif(ROCPROFILER_MEMCHECK STREQUAL "ThreadSanitizer")
rocprofiler_add_memcheck_flags("thread")
rocprofiler_set_memcheck_env("${ROCPROFILER_MEMCHECK}" "tsan")
elseif(ROCPROFILER_MEMCHECK STREQUAL "UndefinedBehaviorSanitizer")
rocprofiler_add_memcheck_flags("undefined")
rocprofiler_set_memcheck_env("${ROCPROFILER_MEMCHECK}" "ubsan")
elseif(NOT ROCPROFILER_MEMCHECK STREQUAL "")
message(FATAL_ERROR "Unsupported ROCPROFILER_MEMCHECK type: ${ROCPROFILER_MEMCHECK}")
endif()