| 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 |
target_sources(faiss_c PRIVATE |
| 7 |
DeviceUtils_c.cpp |
| 8 |
GpuAutoTune_c.cpp |
| 9 |
GpuClonerOptions_c.cpp |
| 10 |
GpuIndex_c.cpp |
| 11 |
GpuResources_c.cpp |
| 12 |
StandardGpuResources_c.cpp |
| 13 |
) |
| 14 |
|
| 15 |
file(GLOB FAISS_C_API_GPU_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h") |
| 16 |
faiss_install_headers("${FAISS_C_API_GPU_HEADERS}" c_api/gpu) |
| 17 |
|
| 18 |
if (FAISS_ENABLE_ROCM) |
| 19 |
target_link_libraries(faiss_c PUBLIC hip::host roc::hipblas) |
| 20 |
target_link_libraries(faiss_c_avx2 PUBLIC hip::host roc::hipblas) |
| 21 |
target_link_libraries(faiss_c_avx512 PUBLIC hip::host roc::hipblas) |
| 22 |
target_link_libraries(faiss_c_avx512_spr PUBLIC hip::host roc::hipblas) |
| 23 |
target_link_libraries(faiss_c_sve PUBLIC hip::host roc::hipblas) |
| 24 |
else() |
| 25 |
find_package(CUDAToolkit REQUIRED) |
| 26 |
target_link_libraries(faiss_c PUBLIC CUDA::cudart CUDA::cublas $<$<BOOL:${FAISS_ENABLE_CUVS}>:cuvs::cuvs>) |
| 27 |
target_link_libraries(faiss_c_avx2 PUBLIC CUDA::cudart CUDA::cublas $<$<BOOL:${FAISS_ENABLE_CUVS}>:cuvs::cuvs>) |
| 28 |
target_link_libraries(faiss_c_avx512 PUBLIC CUDA::cudart CUDA::cublas $<$<BOOL:${FAISS_ENABLE_CUVS}>:cuvs::cuvs>) |
| 29 |
target_link_libraries(faiss_c_avx512_spr PUBLIC CUDA::cudart CUDA::cublas $<$<BOOL:${FAISS_ENABLE_CUVS}>:cuvs::cuvs>) |
| 30 |
target_link_libraries(faiss_c_sve PUBLIC CUDA::cudart CUDA::cublas $<$<BOOL:${FAISS_ENABLE_CUVS}>:cuvs::cuvs>) |
| 31 |
endif() |
| 32 |
|
| 33 |
add_executable(example_gpu_c EXCLUDE_FROM_ALL example_gpu_c.c) |
| 34 |
target_link_libraries(example_gpu_c PRIVATE faiss_c) |