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
16 changes: 16 additions & 0 deletions .install/ubuntu_26.04.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -e
export DEBIAN_FRONTEND=noninteractive
MODE=$1 # whether to install using sudo or not

$MODE apt update -qq

# apt.llvm.org has no clang-18 repo for 26.04, but the Ubuntu archive ships clang-format-18.
# check-format.sh calls the unversioned clang-format, so point it at version 18.
$MODE apt install -yqq clang-format-18
$MODE ln -sf /usr/bin/clang-format-18 /usr/local/bin/clang-format
clang-format --version

$MODE apt install -yqq git wget build-essential lcov openssl libssl-dev \
python3 python3-venv python3-dev unzip rsync curl
source install_cmake.sh $MODE
36 changes: 28 additions & 8 deletions cmake/x86_64InstructionFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,35 @@ CHECK_CXX_COMPILER_FLAG(-msse4.1 CXX_SSE4)
CHECK_CXX_COMPILER_FLAG(-msse3 CXX_SSE3)
CHECK_CXX_COMPILER_FLAG(-msse CXX_SSE)

# Turn off AVX512BF16 on Ubuntu 18.04 as it is not supported by its binutils assembler version.
# Check binutils version for AVX512 instruction support.
# Even if the compiler supports certain flags, the assembler (binutils) may not.
# - AVX512-BF16 requires binutils >= 2.34
# - AVX512-FP16 requires binutils >= 2.38
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
execute_process(COMMAND lsb_release -rs
OUTPUT_VARIABLE UBUNTU_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)

if("${UBUNTU_VERSION}" STREQUAL "18.04")
message(STATUS "Compiling on Ubuntu 18.04, turning off CXX_AVX512BF16 flag.")
set(CXX_AVX512BF16 FALSE)
# Get binutils/assembler version
execute_process(COMMAND as --version
OUTPUT_VARIABLE AS_VERSION_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
# Extract version number (e.g., "2.34" from "GNU assembler (GNU Binutils for Ubuntu) 2.34")
string(REGEX MATCH "[0-9]+\\.[0-9]+" BINUTILS_VERSION "${AS_VERSION_OUTPUT}")

if(BINUTILS_VERSION)
message(STATUS "Detected binutils version: ${BINUTILS_VERSION}")

# AVX512-BF16 requires binutils >= 2.34
if(BINUTILS_VERSION VERSION_LESS "2.34")
message(STATUS "binutils ${BINUTILS_VERSION} < 2.34, turning off CXX_AVX512BF16 flag.")
set(CXX_AVX512BF16 FALSE)
endif()

# AVX512-FP16 requires binutils >= 2.38
if(BINUTILS_VERSION VERSION_LESS "2.38")
message(STATUS "binutils ${BINUTILS_VERSION} < 2.38, turning off CXX_AVX512FP16 flag.")
set(CXX_AVX512FP16 FALSE)
endif()
else()
message(WARNING "Could not detect binutils version, AVX512 features may fail to assemble")
endif()
endif()

Expand Down
10 changes: 10 additions & 0 deletions src/VecSim/memory/vecsim_malloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ inline void vecsim_free(void *p) { VecSimAllocator::memFunctions.freeFunction(p)
template <typename T>
struct VecsimSTLAllocator {
using value_type = T;
// Tiered indexes use separate allocators for frontend/backend/management layers.
// Swapping containers across these layers is safe (same underlying alloc functions),
// so we must tell std::vector::swap to swap the allocator along with the data.
using propagate_on_container_swap = std::true_type;

private:
VecsimSTLAllocator() {}
Expand Down Expand Up @@ -148,3 +152,9 @@ template <class T, class U>
bool operator!=(const VecsimSTLAllocator<T> &a, const VecsimSTLAllocator<U> &b) {
return a.vecsim_allocator != b.vecsim_allocator;
}

// Guard against regressions of the allocator swap-propagation trait. Tiered indexes swap
// std::vectors whose allocators reference different VecSimAllocator instances, which is UB
// unless the allocator is swapped along with the buffer (see hnsw_tiered.h getNextResults).
static_assert(std::allocator_traits<VecsimSTLAllocator<char>>::propagate_on_container_swap::value,
"VecsimSTLAllocator must propagate on container swap.");
4 changes: 2 additions & 2 deletions src/VecSim/spaces/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall")

set(OPTIMIZATIONS "")

if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)")
# Check that the compiler supports instructions flag.
# from gcc14+ -mavx512bw is implicitly enabled when -mavx512vbmi2 is requested
include(${root}/cmake/x86_64InstructionFlags.cmake)
Expand Down Expand Up @@ -93,7 +93,7 @@ if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)")
endif()
endif()

if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "(aarch64)|(arm64)|(ARM64)|(armv.*)")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(aarch64)|(arm64)|(ARM64)|(armv.*)")
include(${root}/cmake/aarch64InstructionFlags.cmake)

# Create different optimization implementations for ARM architecture
Expand Down
4 changes: 2 additions & 2 deletions tests/benchmark/spaces_benchmarks/bm_spaces_int8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ INITIALIZE_BENCHMARKS_SET_Cosine(BM_VecSimSpaces_Integers_INT8, INT8, SVE2, 32,
#endif
#ifdef OPT_SVE
bool sve_supported = opt.sve; // Check for SVE support
INITIALIZE_BENCHMARKS_SET_L2_IP(BM_VecSimSpaces_Integers_INT8, INT8, SVE, 32, sve2_supported);
INITIALIZE_BENCHMARKS_SET_Cosine(BM_VecSimSpaces_Integers_INT8, INT8, SVE, 32, sve2_supported);
INITIALIZE_BENCHMARKS_SET_L2_IP(BM_VecSimSpaces_Integers_INT8, INT8, SVE, 32, sve_supported);
INITIALIZE_BENCHMARKS_SET_Cosine(BM_VecSimSpaces_Integers_INT8, INT8, SVE, 32, sve_supported);
#endif
#ifdef OPT_NEON_DOTPROD
bool neon_dotprod_supported = opt.asimddp;
Expand Down
4 changes: 2 additions & 2 deletions tests/benchmark/spaces_benchmarks/bm_spaces_uint8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ INITIALIZE_BENCHMARKS_SET_Cosine(BM_VecSimSpaces_Integers_UINT8, UINT8, SVE2, 32
#endif
#ifdef OPT_SVE
bool sve_supported = opt.sve; // Check for SVE support
INITIALIZE_BENCHMARKS_SET_L2_IP(BM_VecSimSpaces_Integers_UINT8, UINT8, SVE, 32, sve2_supported);
INITIALIZE_BENCHMARKS_SET_Cosine(BM_VecSimSpaces_Integers_UINT8, UINT8, SVE, 32, sve2_supported);
INITIALIZE_BENCHMARKS_SET_L2_IP(BM_VecSimSpaces_Integers_UINT8, UINT8, SVE, 32, sve_supported);
INITIALIZE_BENCHMARKS_SET_Cosine(BM_VecSimSpaces_Integers_UINT8, UINT8, SVE, 32, sve_supported);
#endif
#ifdef OPT_NEON_DOTPROD
// NEON_DOTPROD functions
Expand Down
Loading