From 6a09d925403315687aefa0d7f89fd8f0fb33f986 Mon Sep 17 00:00:00 2001 From: Liyun Xiu Date: Thu, 12 Mar 2026 11:49:33 +0800 Subject: [PATCH 1/2] Update CI to install abseil & fix demo code Signed-off-by: Liyun Xiu --- .github/workflows/CI.yml | 12 ++++++++++-- DEVELOPER_GUIDE.md | 27 ++++++++++++++------------- demos/seismic_sq.py | 6 +++--- nsparse/python/requirements.txt | 1 + 4 files changed, 28 insertions(+), 18 deletions(-) create mode 100644 nsparse/python/requirements.txt diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9035be2..8d76210 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -44,6 +44,10 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Install Abseil + run: | + apt-get update && apt-get install -y libabsl-dev + # Generic build - name: Configure (generic) run: | @@ -112,7 +116,7 @@ jobs: uses: actions/checkout@v4 - name: Install dependencies - run: brew install libomp + run: brew install libomp abseil - name: Detect SIMD capability id: detect-simd @@ -176,12 +180,16 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Install Abseil + run: vcpkg install abseil[core]:x64-windows + - name: Configure (generic) run: | cmake -B build ` -DNSPARSE_ENABLE_TESTS=ON ` -DNSPARSE_OPT_LEVEL=generic ` - -DCMAKE_BUILD_TYPE=Release + -DCMAKE_BUILD_TYPE=Release ` + -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" - name: Build (generic) run: cmake --build build --config Release -j $env:NUMBER_OF_PROCESSORS diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 8fcc2ae..38638fc 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -11,7 +11,8 @@ - [Run Benchmarks](#run-benchmarks) - [Python Bindings](#python-bindings) - [Build Python Bindings](#build-python-bindings) - - [Python Environment Setup](#python-environment-setup) + - [Using venv](#using-venv) + - [Using Conda](#using-conda) - [Python Usage](#python-usage) - [Debugging](#debugging) - [Major Dependencies](#major-dependencies) @@ -148,29 +149,29 @@ On Linux, the benchmarks support hardware performance counters via [libpfm](http ### Build Python Bindings +#### Using venv + ```bash +python3 -m venv venv +source venv/bin/activate +pip install -r nsparse/python/requirements.txt cmake -S . -B build -DNSPARSE_ENABLE_PYTHON=ON -DNSPARSE_OPT_LEVEL=avx2 cmake --build build -j cd build/nsparse/python pip install . ``` -### Python Environment Setup +#### Using Conda -**Using venv** ```bash -python3 -m venv venv -source venv/bin/activate -``` - -**Using Conda** -```bash -conda create -n nsparse python=3.12 +conda create -n nsparse python=3.12 numpy conda activate nsparse +cmake -S . -B build -DNSPARSE_ENABLE_PYTHON=ON -DNSPARSE_OPT_LEVEL=avx2 +cmake --build build -j +cd build/nsparse/python +pip install . ``` -Then build and install the Python bindings as described above. - ### Python Usage After building and installing, you can run the demo scripts: @@ -200,7 +201,7 @@ gdb ./build/tests/nsparse_test lldb ./build/tests/nsparse_test ``` -In CLion or VS Code, you can set breakpoints and debug directly from the IDE using the test or benchmark targets. +In VS Code, you can set breakpoints and debug directly from the IDE using the test or benchmark targets. ### Major Dependencies diff --git a/demos/seismic_sq.py b/demos/seismic_sq.py index 17a0f9e..ce20788 100644 --- a/demos/seismic_sq.py +++ b/demos/seismic_sq.py @@ -81,15 +81,15 @@ def main(): params = nsparse.SeismicSearchParameters(k, 1.2) # Perform search - labels = index.search( + distances, labels = index.search( n_queries, query_indptr, query_indices, query_values, k, params ) print(f"\nTop {k} nearest neighbors:") print(f"Labels shape: {labels.shape}") + print(f"Distances shape: {distances.shape}") for i in range(n_queries): - neighbors = labels[i] - print(f"Query {i}: {neighbors}") + print(f"Query {i}: labels={labels[i]}, distances={distances[i]}") if __name__ == "__main__": diff --git a/nsparse/python/requirements.txt b/nsparse/python/requirements.txt new file mode 100644 index 0000000..88dd02a --- /dev/null +++ b/nsparse/python/requirements.txt @@ -0,0 +1 @@ +numpy>=2.0 From 6581efb8dec334e832484761cb2fc2e162bdc200 Mon Sep 17 00:00:00 2001 From: Liyun Xiu Date: Thu, 12 Mar 2026 12:00:39 +0800 Subject: [PATCH 2/2] AL2 doesn't support abseil Signed-off-by: Liyun Xiu --- .github/workflows/CI.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8d76210..74f7e01 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -44,10 +44,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Install Abseil - run: | - apt-get update && apt-get install -y libabsl-dev - # Generic build - name: Configure (generic) run: |