Skip to content

Commit

Permalink
ANN-benchmarks: switch to use gbench
Browse files Browse the repository at this point in the history
  • Loading branch information
achirkin committed Aug 9, 2023
1 parent 692e9c2 commit 8cfd2ae
Show file tree
Hide file tree
Showing 31 changed files with 2,370 additions and 3,890 deletions.
2 changes: 1 addition & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ if(BUILD_TESTS)
include(cmake/thirdparty/get_gtest.cmake)
endif()

if(BUILD_PRIMS_BENCH)
if(BUILD_PRIMS_BENCH OR BUILD_ANN_BENCH)
include(${rapids-cmake-dir}/cpm/gbench.cmake)
rapids_cpm_gbench()
endif()
Expand Down
55 changes: 50 additions & 5 deletions cpp/bench/ann/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ function(ConfigureAnnBench)

set(BENCH_NAME ${ConfigureAnnBench_NAME}_ANN_BENCH)

add_executable(
${BENCH_NAME} ${ConfigureAnnBench_PATH} bench/ann/src/common/conf.cpp
bench/ann/src/common/util.cpp
)
add_library(${BENCH_NAME} SHARED ${ConfigureAnnBench_PATH})

string(TOLOWER ${BENCH_NAME} BENCH_LIB_NAME)
set_target_properties(${BENCH_NAME} PROPERTIES OUTPUT_NAME ${BENCH_LIB_NAME})

target_link_libraries(
${BENCH_NAME}
PRIVATE raft::raft
Expand All @@ -91,18 +92,21 @@ function(ConfigureAnnBench)
${RAFT_CTK_MATH_DEPENDENCIES}
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
$<TARGET_NAME_IF_EXISTS:conda_env>
-static-libgcc
-static-libstdc++
)

set_target_properties(
${BENCH_NAME}
PROPERTIES # set target compile options
INSTALL_RPATH "\$ORIGIN/../../../lib"
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON
INTERFACE_POSITION_INDEPENDENT_CODE ON
BUILD_RPATH "\$ORIGIN"
INSTALL_RPATH "\$ORIGIN"
)

set(${ConfigureAnnBench_CXXFLAGS} ${RAFT_CXX_FLAGS} ${ConfigureAnnBench_CXXFLAGS})
Expand Down Expand Up @@ -200,3 +204,44 @@ if(RAFT_ANN_BENCH_USE_GGNN)
${CMAKE_CURRENT_BINARY_DIR}/_deps/ggnn-src/include LINKS glog::glog
)
endif()

# ##################################################################################################
# * Dynamically-loading ANN_BENCH executable -------------------------------------------------------

add_executable(ANN_BENCH bench/ann/src/common/benchmark.cpp)

# Build and link static version of the GBench to keep ANN_BENCH self-contained.
get_target_property(TMP_PROP benchmark::benchmark SOURCES)
add_library(benchmark_static STATIC ${TMP_PROP})
get_target_property(TMP_PROP benchmark::benchmark INCLUDE_DIRECTORIES)
target_include_directories(benchmark_static PUBLIC ${TMP_PROP})
get_target_property(TMP_PROP benchmark::benchmark LINK_LIBRARIES)
target_link_libraries(benchmark_static PUBLIC ${TMP_PROP})

target_include_directories(ANN_BENCH PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})

target_link_libraries(
ANN_BENCH PRIVATE nlohmann_json::nlohmann_json benchmark_static dl -static-libgcc
-static-libstdc++ CUDA::nvtx3
)
set_target_properties(
ANN_BENCH
PROPERTIES # set target compile options
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON
INTERFACE_POSITION_INDEPENDENT_CODE ON
BUILD_RPATH "\$ORIGIN"
INSTALL_RPATH "\$ORIGIN"
)

target_link_options(ANN_BENCH PRIVATE -export-dynamic)

install(
TARGETS ANN_BENCH
COMPONENT ann_bench
DESTINATION bin/ann
EXCLUDE_FROM_ALL
)
Loading

0 comments on commit 8cfd2ae

Please sign in to comment.