From 35ecc4e118f2d1aaa70472fdfd14952f4d7e2a0e Mon Sep 17 00:00:00 2001 From: Renovate Date: Thu, 24 Sep 2026 00:24:39 +0000 Subject: [PATCH 1/5] Update dependency ashvardanian/simsimd to v7 --- CMakeLists.txt | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aaec036c..443688b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ FetchContent_Declare( SYSTEM GIT_REPOSITORY https://github.com/ashvardanian/simsimd.git # renovate: datasource=github-tags depName=ashvardanian/simsimd versioning=loose - GIT_TAG v6.5.13 + GIT_TAG v7.8.2 GIT_SHALLOW 1 GIT_PROGRESS ON ) diff --git a/README.md b/README.md index 0c2738dd..23202872 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,6 @@ The [template repository](https://github.com/mcmarius/oop-template) itself is li - Versiune: [v0.9.1](https://github.com/Mozilla-Ocho/llamafile) (Apache 2.0) - [simsimd](https://github.com/ashvardanian/simsimd) - - Versiune: [v6.5.13](https://github.com/ashvardanian/simsimd) (Apache 2.0) + - Versiune: [v7.8.2](https://github.com/ashvardanian/simsimd) (Apache 2.0) - pentru similaritate cosinus - adăugați trimiteri **detaliate** către resursele externe care v-au ajutat sau pe care le-ați folosit From c49ad5cf08e31626a7a0bc6ff14cc6f761ecdd3d Mon Sep 17 00:00:00 2001 From: mcmarius <23401453+mcmarius@users.noreply.github.com> Date: Thu, 24 Sep 2026 13:37:11 +0300 Subject: [PATCH 2/5] fix(cmake): treat RUN_SANITIZERS as a boolean option set_compiler_flags() compared the value of the RUN_SANITIZERS keyword against the literal string "TRUE", so callers that pass an option variable, e.g. `RUN_SANITIZERS ${USE_ASAN}` (which expands to ON/OFF), never matched and the sanitizer flags were silently dropped: CI jobs configured with -DUSE_ASAN=ON built and ran completely uninstrumented binaries. Use a real boolean test so that ON/OFF, TRUE/FALSE and 1/0 all behave as expected. Omitting RUN_SANITIZERS still defaults to running the sanitizers. --- cmake/CompilerFlags.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CompilerFlags.cmake b/cmake/CompilerFlags.cmake index acd00127..4ba0c694 100644 --- a/cmake/CompilerFlags.cmake +++ b/cmake/CompilerFlags.cmake @@ -37,7 +37,7 @@ function(set_compiler_flags) ############################################################################### # sanitizers - if("${ARG_RUN_SANITIZERS}" STREQUAL "TRUE") + if(ARG_RUN_SANITIZERS) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") else() set_custom_stdlib_and_sanitizers(cpr false) From 32454f346af92093c454373422a62cb521387b22 Mon Sep 17 00:00:00 2001 From: mcmarius <23401453+mcmarius@users.noreply.github.com> Date: Thu, 24 Sep 2026 13:37:25 +0300 Subject: [PATCH 3/5] fix(valgrind): suppress uninitialized termios reports on recent glibc Recent glibc implements tcsetattr() through the termios2 ioctl, so memcheck no longer reports the syscall parameter as ioctl(TCSETS) but as ioctl(generic), and it additionally reports an 8 byte read of an uninitialized value inside ___cbaud_to_speed(). Both come from libraries that ignore the return value of tcgetattr() and then hand the untouched struct termios to tcsetattr(), which happens whenever stdin is not a tty (e.g. when the executable is fed from a file in CI). Add narrow suppressions for these call stacks so scripts/run_valgrind.sh keeps passing on recent distributions. The existing entry is kept as is, since it is what older distributions used to report. --- scripts/valgrind-suppressions.supp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/scripts/valgrind-suppressions.supp b/scripts/valgrind-suppressions.supp index 3e71ec85..3b3dc468 100644 --- a/scripts/valgrind-suppressions.supp +++ b/scripts/valgrind-suppressions.supp @@ -3327,5 +3327,25 @@ ioctl(TCSET{S,SW,SF}) fun:tcsetattr ... - fun:main +} + +{ + + Memcheck:Param + ioctl(TCSETS) + fun:tcsetattr + ... +} +{ + + Memcheck:Param + ioctl(generic) + fun:tcsetattr + ... +} +{ + + Memcheck:Value8 + fun:*cbaud_to_speed* + ... } From 0d4b35bf0a723959bb45690e68199c6db6e5bfa5 Mon Sep 17 00:00:00 2001 From: mcmarius <23401453+mcmarius@users.noreply.github.com> Date: Thu, 24 Sep 2026 15:45:58 +0300 Subject: [PATCH 4/5] build(cmake): upgrade simsimd to NumKong v7.8.2 v7 is the release in which simsimd was renamed to NumKong (the GitHub repository redirects there): the headers moved from include/simsimd to include/numkong and the symbols are prefixed with nk_ instead of simsimd_. There is no compatibility layer, so the Renovate GIT_TAG bump alone does not compile. Changes needed by the embeddings example: - cos was renamed to angular (same value: 1 - cosine similarity) - f32 inputs now return f64 results, so the distance is nk_f64_t - the value printed by the example is a distance, not a similarity, so the label was fixed while touching those lines NK_NATIVE_F16 / NK_NATIVE_BF16 replace the SIMSIMD_NATIVE_F16 / SIMSIMD_NATIVE_BF16 defines that were required in v6, locally and in CI. Verified locally with GCC 16 (Debug, warnings as errors): ASan+UBSan run, valgrind (0 errors, 0 lost bytes), cppcheck, clang-tidy, and clang 23 / GCC 15 compiles. --- CMakeLists.txt | 10 +++++----- README.md | 6 +++--- cmake/CompilerFlags.cmake | 4 ++-- main.cpp | 16 +++++++++------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 443688b9..45074888 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,16 +53,16 @@ FetchContent_Declare( ) FetchContent_Declare( - simsimd + numkong SYSTEM - GIT_REPOSITORY https://github.com/ashvardanian/simsimd.git - # renovate: datasource=github-tags depName=ashvardanian/simsimd versioning=loose + GIT_REPOSITORY https://github.com/ashvardanian/NumKong.git + # renovate: datasource=github-tags depName=ashvardanian/NumKong versioning=loose GIT_TAG v7.8.2 GIT_SHALLOW 1 GIT_PROGRESS ON ) -FetchContent_MakeAvailable(cpr simsimd) +FetchContent_MakeAvailable(cpr numkong) ############################################################################### @@ -98,7 +98,7 @@ target_include_directories(${MAIN_EXECUTABLE_NAME} SYSTEM PRIVATE ext ext/include/json ${cpr_SOURCE_DIR}/include - ${simsimd_SOURCE_DIR}/include + ${numkong_SOURCE_DIR}/include ) # target_include_directories(${MAIN_EXECUTABLE_NAME} SYSTEM PRIVATE ${_SOURCE_DIR}/include) # target_link_directories(${MAIN_EXECUTABLE_NAME} PRIVATE ${_BINARY_DIR}/lib) diff --git a/README.md b/README.md index 23202872..0d9ca658 100644 --- a/README.md +++ b/README.md @@ -194,8 +194,8 @@ The [template repository](https://github.com/mcmarius/oop-template) itself is li - Versiune: [v3.11.3](https://github.com/nlohmann/json/releases/tag/v3.11.3) (MIT) - [llamafile](https://github.com/Mozilla-Ocho/llamafile) - Versiune: [v0.9.1](https://github.com/Mozilla-Ocho/llamafile) (Apache 2.0) -- [simsimd](https://github.com/ashvardanian/simsimd) - - - Versiune: [v7.8.2](https://github.com/ashvardanian/simsimd) (Apache 2.0) +- [NumKong](https://github.com/ashvardanian/NumKong) + + - Versiune: [v7.8.2](https://github.com/ashvardanian/NumKong) (Apache 2.0) - pentru similaritate cosinus - adăugați trimiteri **detaliate** către resursele externe care v-au ajutat sau pe care le-ați folosit diff --git a/cmake/CompilerFlags.cmake b/cmake/CompilerFlags.cmake index 4ba0c694..c0ecdf1c 100644 --- a/cmake/CompilerFlags.cmake +++ b/cmake/CompilerFlags.cmake @@ -17,8 +17,8 @@ function(set_compiler_flags) message("NOTE: GITHUB_ACTIONS defined") target_compile_definitions(${TARGET_NAME} PRIVATE GITHUB_ACTIONS) endif() - target_compile_definitions(${TARGET_NAME} PRIVATE SIMSIMD_NATIVE_F16=0) - target_compile_definitions(${TARGET_NAME} PRIVATE SIMSIMD_NATIVE_BF16=0) + target_compile_definitions(${TARGET_NAME} PRIVATE NK_NATIVE_F16=0) + target_compile_definitions(${TARGET_NAME} PRIVATE NK_NATIVE_BF16=0) ############################################################################### diff --git a/main.cpp b/main.cpp index b5ffa654..ad62d03b 100644 --- a/main.cpp +++ b/main.cpp @@ -7,8 +7,8 @@ // #include "Example.h" /////////////////////////////////////////////////////////////////// -//// Vom folosi simsimd pentru a calcula similaritatea cosinus //// -#include //// +//// Vom folosi numkong pentru a calcula similaritatea cosinus //// +#include //// /////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// @@ -39,7 +39,7 @@ const std::string API_URL = "http://127.0.0.1:8080"; -std::vector getEmbeddings(const std::string& word) +std::vector getEmbeddings(const std::string& word) { std::string api_url = API_URL; if(const auto* url = std::getenv("LLM_URL")) { @@ -79,7 +79,7 @@ std::vector getEmbeddings(const std::string& word) } json json_resp = json::parse(res.text); // Parsăm răspunsul primit - std::vector embedding = json_resp["embedding"]; + std::vector embedding = json_resp["embedding"]; // std::cout << json_resp["embedding"].size() << std::endl; return embedding; } @@ -161,9 +161,11 @@ int main() auto emb1 = getEmbeddings(word1); auto emb2 = getEmbeddings(word2); - simsimd_distance_t distance; - simsimd_cos_f32(emb1.data(), emb2.data(), emb1.size(), &distance); - std::cout << "similarity " << word1 << " - " << word2 << ": " << distance << "\n"; + // distanța angulară (1 - cosinusul unghiului dintre vectori): + // cu cât vectorii sunt mai similari, cu cât distanța e mai aproape de 0 + nk_f64_t distance{}; + nk_angular_f32(emb1.data(), emb2.data(), emb1.size(), &distance); + std::cout << "angular distance (1 - cos) " << word1 << " - " << word2 << ": " << distance << "\n"; // not very reliable, varies too much, not deterministic // std::cout << "score: " << getScore(word1, word2) << "\n"; From 47db32fe44497e663cd941fb818fd4a97310cfbc Mon Sep 17 00:00:00 2001 From: mcmarius <23401453+mcmarius@users.noreply.github.com> Date: Thu, 24 Sep 2026 15:46:34 +0300 Subject: [PATCH 5/5] ci: add NUMKONG_VERSION to the deps cache key The _deps cache key ends in the CPR_VERSION env var, which is not defined anywhere, so bumping a dependency does not invalidate the cache. Until that is fixed on descarcare-date-api, add a version env var for the other FetchContent dependency of this branch, so a NumKong bump always rebuilds _deps. The annotation uses the same depName as the ones in CMakeLists.txt and README.md, so Renovate updates all three in a single PR and the version cannot drift. --- .github/actions/configure-cmake/action.yml | 2 +- .github/workflows/cmake.yml | 3 +++ CMakeLists.txt | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/actions/configure-cmake/action.yml b/.github/actions/configure-cmake/action.yml index 3ae6806d..c780a212 100644 --- a/.github/actions/configure-cmake/action.yml +++ b/.github/actions/configure-cmake/action.yml @@ -25,7 +25,7 @@ runs: with: path: | ${{ env.BUILD_DIR }}/_deps - key: ${{ inputs.cache_key }}-${{ matrix.cmake_generator }}-${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.asan_name }}-${{ env.BUILD_TYPE }}-${{ env.CPR_VERSION }} + key: ${{ inputs.cache_key }}-${{ matrix.cmake_generator }}-${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.asan_name }}-${{ env.BUILD_TYPE }}-${{ env.CPR_VERSION }}-${{ env.NUMKONG_VERSION }} # NOTE: GH Actions does not allow updating the cache yet # Using the workaround found here: https://github.com/actions/cache/issues/171 diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 01813c67..bf1c423e 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -31,6 +31,9 @@ env: BIN_DIR: "bin" # update in cmake/Options.cmake:6 if changing name here BUILD_DIR: "build" EXT_DIR: "ext" + # NOTE: keep in sync with GIT_TAG in CMakeLists.txt; only used to invalidate the _deps cache + # renovate: datasource=github-tags depName=ashvardanian/NumKong versioning=loose + NUMKONG_VERSION: "v7.8.2" defaults: diff --git a/CMakeLists.txt b/CMakeLists.txt index 45074888..0d7575ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,7 @@ FetchContent_Declare( GIT_PROGRESS ON ) +# NOTE: Also update NUMKONG_VERSION in .github/workflows/cmake.yml FetchContent_Declare( numkong SYSTEM