| 1 |
# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 |
# |
| 3 |
# This source code is licensed under the MIT license found in the |
| 4 |
# LICENSE file in the root directory of this source tree. |
| 5 |
|
| 6 |
# @lint-ignore-every LINEWRAP |
| 7 |
project(faiss_perf_tests) |
| 8 |
set(BENCHMARK_ENABLE_TESTING OFF) |
| 9 |
set(BENCHMARK_INSTALL_DOCS OFF) |
| 10 |
|
| 11 |
include(FetchContent) |
| 12 |
FetchContent_Declare(googlebenchmark |
| 13 |
GIT_REPOSITORY https://github.com/google/benchmark.git |
| 14 |
GIT_TAG main) # need main for benchmark::benchmark |
| 15 |
FetchContent_MakeAvailable( |
| 16 |
googlebenchmark) |
| 17 |
|
| 18 |
|
| 19 |
find_package(Threads REQUIRED) |
| 20 |
find_package(OpenMP REQUIRED) |
| 21 |
find_package(gflags REQUIRED) |
| 22 |
|
| 23 |
add_library(faiss_perf_tests_utils |
| 24 |
utils.cpp |
| 25 |
) |
| 26 |
# `#include <faiss/perf_tests/utils.h>` or any other headers |
| 27 |
target_include_directories(faiss_perf_tests_utils PRIVATE |
| 28 |
${PROJECT_SOURCE_DIR}/../..) |
| 29 |
|
| 30 |
include(../cmake/link_to_faiss_lib.cmake) |
| 31 |
|
| 32 |
link_to_faiss_lib(faiss_perf_tests_utils) |
| 33 |
|
| 34 |
set(FAISS_PERF_TEST_SRC |
| 35 |
bench_no_multithreading_rcq_search.cpp |
| 36 |
bench_scalar_quantizer_accuracy.cpp |
| 37 |
bench_scalar_quantizer_decode.cpp |
| 38 |
bench_scalar_quantizer_distance.cpp |
| 39 |
bench_scalar_quantizer_encode.cpp |
| 40 |
) |
| 41 |
foreach(bench ${FAISS_PERF_TEST_SRC}) |
| 42 |
get_filename_component(bench_exec ${bench} NAME_WE) |
| 43 |
add_executable(${bench_exec} ${bench}) |
| 44 |
link_to_faiss_lib(${bench_exec}) |
| 45 |
target_link_libraries(${bench_exec} PRIVATE faiss_perf_tests_utils OpenMP::OpenMP_CXX benchmark::benchmark gflags) |
| 46 |
# `#include <faiss/perf_tests/utils.h>` or any other headers |
| 47 |
target_include_directories(${bench_exec} PRIVATE |
| 48 |
${PROJECT_SOURCE_DIR}/../..) |
| 49 |
|
| 50 |
endforeach() |