Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ alaya_preflight()
include(cmake/AlayaToolchain.cmake)
include(cmake/AlayaFlags.cmake)
include(cmake/AlayaDependencies.cmake)
include(cmake/AlayaDiskANN.cmake)
include(cmake/AlayaLaser.cmake)
include(cmake/Codecov.cmake)
include(cmake/PrintSummary.cmake)
Expand All @@ -52,7 +53,7 @@ add_library(AlayaLite INTERFACE)
target_include_directories(
AlayaLite INTERFACE $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>
)
target_link_libraries(AlayaLite INTERFACE ${THIRD_PARTY_LIBS})
target_link_libraries(AlayaLite INTERFACE ${THIRD_PARTY_LIBS} alaya_diskann)
target_compile_features(AlayaLite INTERFACE cxx_std_20)

if(BUILD_TESTING)
Expand Down
18 changes: 12 additions & 6 deletions cmake/AlayaDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#
# Packages resolve through the Conan dependency provider registered in AlayaConan.cmake: the first find_package below
# triggers `conan install` transparently and the generated config packages land in ${CMAKE_BINARY_DIR}/conan. OpenMP
# (system / Homebrew) and libaio (system, handled in AlayaLaser.cmake) are not in the Conan graph and fall through the
# provider to CMake's builtin lookup. THIRD_PARTY_LIBS stays a plain list because test helper code and the AlayaLite
# (system / Homebrew) and libaio (system, handled by the disk-I/O targets) are not in the Conan graph and fall through
# the provider to CMake's builtin lookup. THIRD_PARTY_LIBS stays a plain list because test helper code and the AlayaLite
# INTERFACE target both consume it.

include_guard(GLOBAL)
Expand All @@ -28,6 +28,7 @@ find_package(spdlog REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(OpenMP QUIET)
find_package(RocksDB REQUIRED)
find_package(libcoro REQUIRED)

if(BUILD_PYTHON)
# Reuse the interpreter alaya_preflight() resolved (FindPython / Python_* family) instead of letting pybind11 run its
Expand All @@ -36,14 +37,19 @@ if(BUILD_PYTHON)
find_package(pybind11 REQUIRED)
endif()

set(THIRD_PARTY_LIBS spdlog::spdlog_header_only concurrentqueue::concurrentqueue Eigen3::Eigen RocksDB::rocksdb)
set(THIRD_PARTY_LIBS
spdlog::spdlog_header_only
concurrentqueue::concurrentqueue
Eigen3::Eigen
RocksDB::rocksdb
libcoro::libcoro
)

if(TARGET OpenMP::OpenMP_CXX)
list(APPEND THIRD_PARTY_LIBS OpenMP::OpenMP_CXX)
endif()

if(UNIX AND NOT APPLE)
find_package(libcoro REQUIRED)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(liburing REQUIRED)
list(APPEND THIRD_PARTY_LIBS libcoro::libcoro liburing::liburing)
list(APPEND THIRD_PARTY_LIBS liburing::liburing)
endif()
47 changes: 47 additions & 0 deletions cmake/AlayaDiskANN.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# SPDX-FileCopyrightText: 2025 AlayaDB.AI
#
# SPDX-License-Identifier: AGPL-3.0-only

# DiskANN's portable reader backend and platform runtime dependencies.

include_guard(GLOBAL)

set(_alaya_diskann_backend_libs libcoro::libcoro)

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(_alaya_diskann_backend_definition ALAYA_LASER_USE_IOCP=1)
set(_alaya_diskann_backend_message "IOCP + Win32 positioned writes")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR ALAYA_LASER_USE_THREADPOOL)
set(_alaya_diskann_backend_definition ALAYA_LASER_USE_THREADPOOL=1)
set(_alaya_diskann_backend_message "thread-pool reads + POSIX positioned writes")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_library(AIO_LIBRARY aio)
find_path(AIO_INCLUDE_DIR libaio.h)
if(NOT AIO_LIBRARY OR NOT AIO_INCLUDE_DIR)
message(FATAL_ERROR "DiskANN requires libaio for the default Linux reader. Install libaio-dev/libaio-devel, "
"or configure with -DALAYA_LASER_USE_THREADPOOL=ON."
)
endif()
if(NOT TARGET AIO::aio)
add_library(AIO::aio UNKNOWN IMPORTED)
set_target_properties(
AIO::aio PROPERTIES IMPORTED_LOCATION "${AIO_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${AIO_INCLUDE_DIR}"
)
endif()
list(APPEND _alaya_diskann_backend_libs AIO::aio liburing::liburing)
set(_alaya_diskann_backend_definition ALAYA_LASER_USE_LIBAIO=1)
set(_alaya_diskann_backend_message "libaio reads + O_DIRECT positioned writes")
else()
set(_alaya_diskann_backend_definition ALAYA_LASER_USE_THREADPOOL=1)
set(_alaya_diskann_backend_message "portable thread-pool reads + POSIX positioned writes")
endif()

message(STATUS "DiskANN I/O backend: ${_alaya_diskann_backend_message}")

add_library(alaya_diskann INTERFACE)
target_include_directories(
alaya_diskann INTERFACE $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>
)
target_link_libraries(alaya_diskann INTERFACE ${_alaya_diskann_backend_libs})
target_compile_definitions(alaya_diskann INTERFACE ${_alaya_diskann_backend_definition})
target_compile_features(alaya_diskann INTERFACE cxx_std_20)
5 changes: 3 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ def requirements(self):
self.requires("lz4/1.9.4")
self.requires("zstd/1.5.6")
self.requires("rocksdb/10.5.1")
# io_uring and coroutine scheduler support are Linux-only in CMake.
# DiskANN uses libcoro's portable task/thread-pool primitives on every
# platform; only its io_uring accelerator is Linux-specific.
self.requires("libcoro/0.14.1")
if self.settings.os == "Linux":
self.requires("libcoro/0.14.1")
self.requires("liburing/2.13")

# OpenMP support
Expand Down
Loading
Loading