Files
rocm-systems/examples/transpose/CMakeLists.txt
T
Jonathan R. Madsen 1f15b3070f Improved analysis of functions to instrument + MPI support + timemory support (#2)
* various tweaks
* build updates + cleanup + overlap guard + min addr range
* Library source reorg + miscellaneous tweaks
* Removed unnecessary fwd decls
* Print address range in --print-X pair mode

- hosttrace modifications
  - disable instrumenting functions with overlapping sections or multiple entry points by default (control via --allow-overlapping option)
  - disable instrumenting functions whose address range < 512 bytes unless a loop is present by default (control via --min-address-range option)
  - disable instrumenting functions w/ loops whose address range < 64 bytes (control via --min-loop-address-range)
- Support for wrapping MPI function calls even in binary rewrite mode
  - e.g. use gotcha to wrap MPI functions with hosttrace_push_trace and hosttrace_pop_trace
- New timemory only mode --> HOSTTRACE_USE_TIMEMORY=ON
- New timemory + perfetto mode --> HOSTTRACE_USE_PERFETTO=ON + HOSTTRACE_USE_TIMEMORY=ON
- Full support for all timemory components
- parallel-overhead example for measuring the overhead in a MT-parallelized application with very small instrumentation functions
- improvements to output directories for hosttrace exe
- improvements to output directories for hosttrace library
- new hosttrace options
  - --print-instrumented <type> prints out the instrumented entities and exits
  - --print-available <type> prints out the available instrumentation entities and exits
  - --print-overlapping <type> prints out the overlapping entities and exits
  - NOTE: <type> above refers to the information printed out, e.g. module name vs. function name vs. module and function name, etc.
2021-09-02 11:38:39 -05:00

107 lines
4.2 KiB
CMake

cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
# uses make to avoid CMAKE_CXX_COMPILER issues
project(transpose
LANGUAGES CXX)
find_program(MAKE_EXECUTABLE NAMES make gmake)
find_program(HIPCC_EXECUTABLE NAMES hipcc)
if(NOT MAKE_EXECUTABLE)
message(AUTHOR_WARNING "make/gmake could not be found. Cannot build transpose target")
return()
endif()
if(NOT HIPCC_EXECUTABLE)
message(AUTHOR_WARNING "hipcc could not be found. Cannot build transpose target")
return()
endif()
string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE)
set(transpose_CXX_FLAGS "-W -Wall ${CMAKE_CXX_FLAGS_${BUILD_TYPE}} ${CMAKE_CXX_FLAGS}")
set(transpose_LINK_FLAGS "")
if(CMAKE_CXX_COMPILER_IS_CLANG AND TARGET hosttrace::hosttrace-compile-options)
set(transpose_CXX_FLAGS "${transpose_CXX_FLAGS} ${hosttrace_CXX_FLAGS}")
get_target_property(COMPILE_OPTS hosttrace::hosttrace-compile-options INTERFACE_COMPILE_OPTIONS)
set(transpose_CXX_FLAGS "${transpose_CXX_FLAGS} ${COMPILE_OPTS}")
endif()
option(TRANSPOSE_USE_MPI "Enable MPI support in transpose exe" ${TIMEMORY_USE_MPI})
if(TRANSPOSE_USE_MPI)
find_package(MPI REQUIRED)
endif()
if(TARGET MPI::MPI_C)
set(transpose_CXX_FLAGS "${transpose_CXX_FLAGS} -DUSE_MPI")
get_target_property(COMPILE_OPTS MPI::MPI_C INTERFACE_COMPILE_OPTIONS)
foreach(_COPT ${COMPILE_OPTS})
if(NOT "${_COPT}" MATCHES "COMPILE_LANG")
set(transpose_CXX_FLAGS "${transpose_CXX_FLAGS} ${_COPT}")
endif()
endforeach()
get_target_property(INCLUDE_DIRS MPI::MPI_C INTERFACE_INCLUDE_DIRECTORIES)
foreach(_IDIR ${INCLUDE_DIRS})
set(transpose_CXX_FLAGS "${transpose_CXX_FLAGS} -I${_IDIR}")
endforeach()
if(MPI_C_LINK_FLAGS)
set(transpose_LINK_FLAGS "${transpose_LINK_FLAGS} ${MPI_C_LINK_FLAGS}")
endif()
set(_LINK_LIBS "")
foreach(_LIB ${MPI_C_LIB_NAMES})
string(APPEND _LINK_LIBS "-l${_LIB} ")
endforeach()
foreach(_IDIR ${INCLUDE_DIRS} ${MPI_mpich_LIBRARY} ${MPI_mpi_LIBRARY} ${MPI_LIBRARY_DIRS})
get_filename_component(_LIBDIR "${_IDIR}" DIRECTORY)
if(EXISTS "${_IDIR}/libmpi${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(transpose_LINK_FLAGS "${transpose_LINK_FLAGS} -L${_IDIR} ${_LINK_LIBS}")
endif()
if(EXISTS "${_LIBDIR}/libmpi${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(transpose_LINK_FLAGS "${transpose_LINK_FLAGS} -L${_LIBDIR} ${_LINK_LIBS}")
endif()
foreach(_LDIR lib lib64)
set(_LIBDIR_SAVE "${_LIBDIR}")
if(NOT EXISTS "${_LIBDIR}/${_LDIR}")
get_filename_component(_LIBDIR "${_LIBDIR}" DIRECTORY)
endif()
if(EXISTS "${_LIBDIR}/${_LDIR}")
set(transpose_LINK_FLAGS "${transpose_LINK_FLAGS} -L${_LIBDIR}/${_LDIR} ${_LINK_LIBS}")
endif()
set(_LIBDIR "${_LIBDIR_SAVE}")
endforeach()
endforeach()
endif()
# remove generator expressions
string(REPLACE "$<" "" transpose_CXX_FLAGS "${transpose_CXX_FLAGS}")
string(REPLACE ">:" ":" transpose_CXX_FLAGS "${transpose_CXX_FLAGS}")
string(REPLACE ">" "" transpose_CXX_FLAGS "${transpose_CXX_FLAGS}")
string(REPLACE "COMPILE_LANGUAGE:CXX:" "" transpose_CXX_FLAGS "${transpose_CXX_FLAGS}")
# remove double spaces
string(REPLACE " " " " transpose_CXX_FLAGS "${transpose_CXX_FLAGS}")
# convert to list
string(REPLACE " " ";" transpose_CXX_FLAGS "${transpose_CXX_FLAGS}")
# remove duplicate args
list(REMOVE_DUPLICATES transpose_CXX_FLAGS)
# make single string
string(REPLACE ";" " " transpose_CXX_FLAGS "${transpose_CXX_FLAGS}")
# configure files in build directory
configure_file(${PROJECT_SOURCE_DIR}/transpose.cpp
${CMAKE_BINARY_DIR}/transpose/transpose.cpp COPYONLY)
configure_file(${PROJECT_SOURCE_DIR}/Makefile.in
${CMAKE_BINARY_DIR}/transpose/Makefile @ONLY)
# touch the file when cmake re-runs to ensure rebuilt
execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/transpose/transpose.cpp)
# target for adding a dependency to libpytimemory target
add_custom_target(transpose ALL
COMMAND ${MAKE_EXECUTABLE}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/transpose
BYPRODUCTS ${CMAKE_BINARY_DIR}/transpose/transpose
SOURCES ${CMAKE_BINARY_DIR}/transpose/transpose.cpp)