Skip to content

Commit a757309

Browse files
ROCm CMake configuration cleanup (#3716)
Summary: Pull Request resolved: #3716 Renaming `USE_ROCM` to `FAISS_ENABLE_ROCM` in CMake files, `FAISS_ENABLE_ROCM` in SWIG files, and `USE_AMD_ROCM` in other source files to follow the existing naming convention. Reviewed By: mnorris11 Differential Revision: D60673731 fbshipit-source-id: 1aaa3f2ff6836830c4eb733ee7f41554f79f9695
1 parent e59d8c3 commit a757309

24 files changed

Lines changed: 69 additions & 83 deletions

CMakeLists.txt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ set(FAISS_LANGUAGES CXX)
2424

2525
if(FAISS_ENABLE_GPU)
2626
if (FAISS_ENABLE_ROCM)
27-
set(USE_ROCM TRUE)
2827
list(APPEND FAISS_LANGUAGES HIP)
2928
list(PREPEND CMAKE_MODULE_PATH "/opt/rocm/lib/cmake")
3029
list(PREPEND CMAKE_PREFIX_PATH "/opt/rocm")
@@ -66,9 +65,9 @@ option(FAISS_ENABLE_PYTHON "Build Python extension." ON)
6665
option(FAISS_ENABLE_C_API "Build C API." OFF)
6766

6867
if(FAISS_ENABLE_GPU)
69-
if(USE_ROCM)
68+
if(FAISS_ENABLE_ROCM)
7069
enable_language(HIP)
71-
add_definitions(-DUSE_ROCM)
70+
add_definitions(-DUSE_AMD_ROCM)
7271
find_package(HIP REQUIRED)
7372
find_package(hipBLAS REQUIRED)
7473
set(GPU_EXT_PREFIX "hip")
@@ -83,15 +82,10 @@ if(FAISS_ENABLE_RAFT AND NOT TARGET raft::raft)
8382
find_package(raft COMPONENTS compiled distributed)
8483
endif()
8584

86-
if(USE_ROCM)
87-
find_package(HIP REQUIRED)
88-
find_package(hipBLAS REQUIRED)
89-
endif()
90-
9185
add_subdirectory(faiss)
9286

9387
if(FAISS_ENABLE_GPU)
94-
if(USE_ROCM)
88+
if(FAISS_ENABLE_ROCM)
9589
add_subdirectory(faiss/gpu-rocm)
9690
else()
9791
add_subdirectory(faiss/gpu)
@@ -116,7 +110,7 @@ if(BUILD_TESTING)
116110
add_subdirectory(tests)
117111

118112
if(FAISS_ENABLE_GPU)
119-
if(USE_ROCM)
113+
if(FAISS_ENABLE_ROCM)
120114
add_subdirectory(faiss/gpu-rocm/test)
121115
else()
122116
add_subdirectory(faiss/gpu/test)

c_api/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ add_executable(example_c EXCLUDE_FROM_ALL example_c.c)
5656
target_link_libraries(example_c PRIVATE faiss_c)
5757

5858
if(FAISS_ENABLE_GPU)
59-
if(USE_ROCM)
59+
if(FAISS_ENABLE_ROCM)
6060
add_subdirectory(gpu-rocm)
6161
else ()
6262
add_subdirectory(gpu)

c_api/gpu/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ target_sources(faiss_c PRIVATE
1515
file(GLOB FAISS_C_API_GPU_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
1616
faiss_install_headers("${FAISS_C_API_GPU_HEADERS}" c_api/gpu)
1717

18-
if (USE_ROCM)
19-
find_package(HIP REQUIRED)
20-
find_package(hipBLAS REQUIRED)
21-
target_link_libraries(faiss_c PUBLIC hip::host roc::hipblas)
18+
if (FAISS_ENABLE_ROCM)
19+
target_link_libraries(faiss_c PUBLIC hip::host roc::hipblas)
2220
else()
23-
find_package(CUDAToolkit REQUIRED)
24-
target_link_libraries(faiss_c PUBLIC CUDA::cudart CUDA::cublas $<$<BOOL:${FAISS_ENABLE_RAFT}>:raft::raft> $<$<BOOL:${FAISS_ENABLE_RAFT}>:nvidia::cutlass::cutlass>)
21+
find_package(CUDAToolkit REQUIRED)
22+
target_link_libraries(faiss_c PUBLIC CUDA::cudart CUDA::cublas
23+
$<$<BOOL:${FAISS_ENABLE_RAFT}>:raft::raft>
24+
$<$<BOOL:${FAISS_ENABLE_RAFT}>:nvidia::cutlass::cutlass>)
2525
endif()
2626

2727
add_executable(example_gpu_c EXCLUDE_FROM_ALL example_gpu_c.c)

faiss/gpu/CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function(generate_ivf_interleaved_code)
197197
"64|2048|8"
198198
)
199199

200-
if (USE_ROCM)
200+
if (FAISS_ENABLE_ROCM)
201201
list(TRANSFORM FAISS_GPU_SRC REPLACE cu$ hip)
202202
endif()
203203

@@ -294,7 +294,7 @@ if(FAISS_ENABLE_RAFT)
294294
target_compile_definitions(faiss_gpu PUBLIC USE_NVIDIA_RAFT=1)
295295
endif()
296296

297-
if (USE_ROCM)
297+
if (FAISS_ENABLE_ROCM)
298298
list(TRANSFORM FAISS_GPU_SRC REPLACE cu$ hip)
299299
endif()
300300

@@ -313,10 +313,8 @@ foreach(header ${FAISS_GPU_HEADERS})
313313
)
314314
endforeach()
315315

316-
if (USE_ROCM)
317-
target_link_libraries(faiss_gpu PRIVATE
318-
$<$<BOOL:${USE_ROCM}>:hip::host>
319-
$<$<BOOL:${USE_ROCM}>:roc::hipblas>)
316+
if (FAISS_ENABLE_ROCM)
317+
target_link_libraries(faiss_gpu PRIVATE hip::host roc::hipblas)
320318
target_compile_options(faiss_gpu PRIVATE)
321319
else()
322320
# Prepares a host linker script and enables host linker to support

faiss/gpu/GpuFaissAssert.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/// Assertions
1616
///
1717

18-
#if defined(__CUDA_ARCH__) || defined(USE_ROCM)
18+
#if defined(__CUDA_ARCH__) || defined(USE_AMD_ROCM)
1919
#define GPU_FAISS_ASSERT(X) assert(X)
2020
#define GPU_FAISS_ASSERT_MSG(X, MSG) assert(X)
2121
#define GPU_FAISS_ASSERT_FMT(X, FMT, ...) assert(X)

faiss/gpu/StandardGpuResources.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ void StandardGpuResourcesImpl::initializeForDevice(int device) {
363363
prop.major,
364364
prop.minor);
365365

366-
#if USE_ROCM
366+
#if USE_AMD_ROCM
367367
// Our code is pre-built with and expects warpSize == 32 or 64, validate
368368
// that
369369
FAISS_ASSERT_FMT(

faiss/gpu/impl/PQCodeDistances-inl.cuh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace faiss {
2121
namespace gpu {
2222

23-
#if defined(USE_ROCM) && __AMDGCN_WAVEFRONT_SIZE == 64u
23+
#if defined(USE_AMD_ROCM) && __AMDGCN_WAVEFRONT_SIZE == 64u
2424
#define LAUNCH_BOUND 320
2525
#else
2626
#define LAUNCH_BOUND 288

faiss/gpu/impl/PQCodeLoad.cuh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ inline __device__ unsigned int getByte(uint64_t v, int pos, int width) {
4747
return getBitfield(v, pos, width);
4848
}
4949

50-
#ifdef USE_ROCM
50+
#ifdef USE_AMD_ROCM
5151

5252
template <int NumSubQuantizers>
5353
struct LoadCode32 {};
@@ -276,7 +276,7 @@ struct LoadCode32<96> {
276276
}
277277
};
278278

279-
#else // USE_ROCM
279+
#else // USE_AMD_ROCM
280280

281281
template <int NumSubQuantizers>
282282
struct LoadCode32 {};
@@ -609,7 +609,7 @@ struct LoadCode32<96> {
609609
}
610610
};
611611

612-
#endif // USE_ROCM
612+
#endif // USE_AMD_ROCM
613613

614614
} // namespace gpu
615615
} // namespace faiss

faiss/gpu/impl/VectorResidual.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <faiss/gpu/utils/DeviceUtils.h>
99
#include <faiss/gpu/utils/StaticUtils.h>
1010
#include <faiss/impl/FaissAssert.h>
11-
#ifdef USE_ROCM
11+
#ifdef USE_AMD_ROCM
1212
#define CUDART_NAN_F __int_as_float(0x7fffffff)
1313
#else
1414
#include <math_constants.h> // in CUDA SDK, for CUDART_NAN_F

faiss/gpu/test/CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
# Defines `gtest_discover_tests()`.
2121
include(GoogleTest)
2222
add_library(faiss_gpu_test_helper TestUtils.cpp)
23-
if(USE_ROCM)
24-
target_link_libraries(faiss_gpu_test_helper PUBLIC
25-
faiss gtest $<$<BOOL:${USE_ROCM}>:hip::host>)
23+
if(FAISS_ENABLE_ROCM)
24+
target_link_libraries(faiss_gpu_test_helper PUBLIC faiss gtest hip::host)
2625
else()
2726
find_package(CUDAToolkit REQUIRED)
2827
target_link_libraries(faiss_gpu_test_helper PUBLIC
@@ -56,9 +55,9 @@ endif()
5655
add_executable(demo_ivfpq_indexing_gpu EXCLUDE_FROM_ALL
5756
demo_ivfpq_indexing_gpu.cpp)
5857

59-
if (USE_ROCM)
58+
if (FAISS_ENABLE_ROCM)
6059
target_link_libraries(demo_ivfpq_indexing_gpu
61-
PRIVATE faiss gtest_main $<$<BOOL:${USE_ROCM}>:hip::host>)
60+
PRIVATE faiss gtest_main hip::host)
6261
else()
6362
target_link_libraries(demo_ivfpq_indexing_gpu
6463
PRIVATE faiss gtest_main CUDA::cudart)

0 commit comments

Comments
 (0)