Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ data/

*.pyc
.clang-*
.vscode/

# macOS garbages
.DS_Store
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "rabitqlib/third/simde"]
path = rabitqlib/third/simde
url = https://github.com/simd-everywhere/simde.git
27 changes: 25 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,34 @@ project(RaBitQLib LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(cmake/cpu_features.cmake)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Building in debug mode")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0")
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
message(STATUS "Building in release mode")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Ofast")
endif()

include_directories(${PROJECT_SOURCE_DIR}/rabitqlib)
include_directories(${PROJECT_SOURCE_DIR}/rabitqlib/third/simde)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

SET(CMAKE_CXX_FLAGS "-Wall -Ofast -Wextra -lrt -march=native -fpic -fopenmp -ftree-vectorize -fexceptions")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -lrt -march=native -fpic -fopenmp -ftree-vectorize -fexceptions -w")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -lrt -march=native -fpic -fopenmp -ftree-vectorize -fexceptions -w")

message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")

add_subdirectory(sample)

option(BUILD_TESTS "Build tests" ON)

add_subdirectory(sample)
if (BUILD_TESTS)
add_subdirectory(contrib)
add_subdirectory(tests)
endif()
54 changes: 54 additions & 0 deletions cmake/cpu_features.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# check if the cpu supports avx512
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
execute_process(COMMAND lscpu OUTPUT_VARIABLE CPU_INFO)
string(REGEX MATCH "avx512f" AVX512_SUPPORT "${CPU_INFO}")
if(AVX512_SUPPORT)
set(AVX512_SUPPORT ON)
endif()

string(REGEX MATCH "avx2" AVX2_SUPPORT "${CPU_INFO}")
if(AVX2_SUPPORT)
set(AVX2_SUPPORT ON)
endif()

string(REGEX MATCH "avx" AVX_SUPPORT "${CPU_INFO}")
if(AVX_SUPPORT)
set(AVX_SUPPORT ON)
endif()

string(REGEX MATCH "sse4_2" SSE4_2_SUPPORT "${CPU_INFO}")
if(SSE4_2_SUPPORT)
set(SSE4_2_SUPPORT ON)
endif()

string(REGEX MATCH "sse4_1" SSE4_1_SUPPORT "${CPU_INFO}")
if(SSE4_1_SUPPORT)
set(SSE4_1_SUPPORT ON)
endif()
endif()


if(AVX512_SUPPORT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx512f")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx512f")
endif()

if(AVX2_SUPPORT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2")
endif()

if(AVX_SUPPORT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
endif()

if(SSE4_2_SUPPORT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
endif()

if(SSE4_1_SUPPORT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
endif()
6 changes: 6 additions & 0 deletions contrib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if (BUILD_TESTS)
add_executable(dataset_example dataset_example.cpp)
# target_link_libraries(dataset_example PRIVATE rabitqlib)
target_include_directories(dataset_example PRIVATE ${PROJECT_SOURCE_DIR}/contrib)
target_include_directories(dataset_example PRIVATE ${PROJECT_SOURCE_DIR}/)
endif()
Loading