Skip to content

Commit 411c172

Browse files
robertmaynardfacebook-github-bot
authored andcommitted
Add linker script to support large cuda cubin files (facebookresearch#3115)
Summary: nvcc starting with CUDA 11.5 offers a `-hls` option to generate host side linker scripts to support large cubin file support. Since faiss supports CUDA 11.4 we replicate that behavior but injecting the same linker script into the link line manually. Pull Request resolved: facebookresearch#3115 Reviewed By: mdouze Differential Revision: D51308908 Pulled By: algoriddle fbshipit-source-id: c6dd073cd3f44dbc99d2e2da97f79b9ebc843b59
1 parent 09c7aac commit 411c172

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

faiss/gpu/CMakeLists.txt

+16
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,22 @@ foreach(header ${FAISS_GPU_HEADERS})
261261
)
262262
endforeach()
263263

264+
# Prepares a host linker script and enables host linker to support
265+
# very large device object files.
266+
# This is what CUDA 11.5+ `nvcc -hls=gen-lcs -aug-hls` would generate
267+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/fatbin.ld"
268+
[=[
269+
SECTIONS
270+
{
271+
.nvFatBinSegment : { *(.nvFatBinSegment) }
272+
__nv_relfatbin : { *(__nv_relfatbin) }
273+
.nv_fatbin : { *(.nv_fatbin) }
274+
}
275+
]=]
276+
)
277+
target_link_options(faiss PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/fatbin.ld")
278+
target_link_options(faiss_avx2 PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/fatbin.ld")
279+
264280
find_package(CUDAToolkit REQUIRED)
265281
target_link_libraries(faiss PRIVATE CUDA::cudart CUDA::cublas $<$<BOOL:${FAISS_ENABLE_RAFT}>:raft::raft> $<$<BOOL:${FAISS_ENABLE_RAFT}>:raft::compiled> $<$<BOOL:${FAISS_ENABLE_RAFT}>:nvidia::cutlass::cutlass>)
266282
target_link_libraries(faiss_avx2 PRIVATE CUDA::cudart CUDA::cublas $<$<BOOL:${FAISS_ENABLE_RAFT}>:raft::raft> $<$<BOOL:${FAISS_ENABLE_RAFT}>:raft::compiled> $<$<BOOL:${FAISS_ENABLE_RAFT}>:nvidia::cutlass::cutlass>)

0 commit comments

Comments
 (0)