Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ option(BUILD_CODE_COVERAGE "Build with code coverage enabled" OFF)
option(BUILD_ADDRESS_SANITIZER "Build with address sanitizer enabled" OFF)
option(BUILD_DOCS "Build documentation" OFF)
option(USE_CUDA "Build hipGRAPH using CUDA backend" OFF)
option(BUILD_CODE_COVERAGE "Build with code coverage flags (clang only)" OFF)
# If CUGRAPH_BUILD_DIR is not set, look at CUGRAPH_SOURCE_DIR/cpp/build.
cmake_dependent_option(CUGRAPH_SOURCE_DIR "Point at a cugraph source directory" "" USE_CUDA "")
cmake_dependent_option(CUGRAPH_BUILD_DIR "Point at a cugraph build directory (often cpp/build)" "" USE_CUDA "")
Expand Down
38 changes: 38 additions & 0 deletions clients/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,44 @@ if(USE_CUDA)
target_link_libraries(hipgraph-test PRIVATE ${CUDA_LIBRARIES})
endif()

if(BUILD_CODE_COVERAGE)
add_custom_target(
code_cov_tests
DEPENDS hipgraph-test
COMMAND ${CMAKE_COMMAND} -E rm -rf ./coverage-report
COMMAND ${CMAKE_COMMAND} -E make_directory ./coverage-report/profraw
COMMAND ${CMAKE_COMMAND} -E env LLVM_PROFILE_FILE="./coverage-report/profraw/hipgraph-coverage_%p.profraw" $<TARGET_FILE:hipgraph-test>
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)

find_program(
LLVM_PROFDATA
llvm-profdata
REQUIRED
HINTS ${ROCM_PATH}/llvm/bin
PATHS /opt/rocm/llvm/bin
)

find_program(
LLVM_COV
llvm-cov
REQUIRED
HINTS ${ROCM_PATH}/llvm/bin
PATHS /opt/rocm/llvm/bin
)

add_custom_target(
coverage
DEPENDS code_cov_tests
COMMAND ${LLVM_PROFDATA} merge -sparse ./coverage-report/profraw/hipgraph-coverage_*.profraw -o ./coverage-report/hipgraph.profdata
COMMAND ${LLVM_COV} report -object ./library/src/libhipgraph.so -instr-profile=./coverage-report/hipgraph.profdata
COMMAND ${LLVM_COV} show -object ./library/src/libhipgraph.so -instr-profile=./coverage-report/hipgraph.profdata -format=html -output-dir=coverage-report
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)

endif()


set_target_properties(hipgraph-test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/staging")

rocm_install(TARGETS hipgraph-test COMPONENT tests)
Expand Down
5 changes: 5 additions & 0 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ if(NOT BUILD_SHARED_LIBS)
set_target_properties(hipgraph PROPERTIES PREFIX "lib")
endif()

if(BUILD_CODE_COVERAGE)
target_compile_options( hipgraph PRIVATE -g -O0 -fprofile-instr-generate -fcoverage-mapping )
target_link_options( hipgraph PUBLIC -fprofile-instr-generate )
endif()

# Include sources
add_subdirectory(src)

Expand Down