Skip to content

Commit e5fef28

Browse files
andyfengHKUroyi-luo
authored andcommitted
Add dispatch test script
Update testing script Update script Remove testing script Update rust build Update tests so that it passes in wasm Add testing script Fix script Fix indentation Fix script Fix indentation Fix script Add CI workflow for simsimd dispatch test Move job to build and deploy workflow Fix yaml Add test trigger Add dependency on build job Move CI job to separate workflow
1 parent 5cfad24 commit e5fef28

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: SimSIMD Dispatch Test
2+
on:
3+
# TODO(Royi) remove once done testing
4+
pull_request:
5+
branches:
6+
- master
7+
schedule:
8+
- cron: "0 5 * * *"
9+
10+
workflow_dispatch:
11+
12+
jobs:
13+
build-precompiled-bin-linux:
14+
if: ${{ github.event_name == 'schedule' || github.event.inputs.skipBinaries != 'true' }}
15+
uses: ./.github/workflows/linux-precompiled-bin-workflow.yml
16+
with:
17+
isNightly: true
18+
secrets: inherit
19+
20+
simsimd-dispatch-test:
21+
name: simsimd-dispatch-test
22+
needs: build-precompiled-bin-linux
23+
runs-on: kuzu-self-hosted-testing
24+
env:
25+
NUM_THREADS: 32
26+
GEN: Ninja
27+
CC: gcc
28+
CXX: g++
29+
steps:
30+
- name: Download nightly build
31+
uses: actions/download-artifact@v4
32+
with:
33+
name: kuzu_cli-linux-x86_64
34+
35+
- name: Extract kuzu shell
36+
run: |
37+
tar xf kuzu_cli-linux-x86_64.tar.gz
38+
39+
- name: Test
40+
run: gdb --batch -x scripts/test-simsimd-dispatch.py --args ./kuzu

scripts/simd-dispatch-test.cypher

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CREATE NODE TABLE embeddings (id int64, vec FLOAT[8], PRIMARY KEY (id));
2+
COPY embeddings FROM "dataset/embeddings/embeddings-8-1k.csv" (deLim=',');
3+
CALL CREATE_HNSW_INDEX('e_hnsw_index', 'embeddings', 'vec', distFunc := 'l2');
4+
CALL QUERY_HNSW_INDEX('e_hnsw_index', 'embeddings', CAST([0.1521,0.3021,0.5366,0.2774,0.5593,0.5589,0.1365,0.8557],'FLOAT[8]'), 3) RETURN nn.id ORDER BY _distance;

scripts/test-simsimd-dispatch.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import gdb
2+
import subprocess
3+
4+
5+
def get_machine_architecture():
6+
output = subprocess.check_output(["cat", "/proc/cpuinfo"])
7+
flags_str = ""
8+
for line in output.decode("utf-8").split("\n"):
9+
line = line.strip()
10+
if line.startswith("flags"):
11+
flags_str = line
12+
break
13+
assert len(line) > 0
14+
15+
# Uses the same way as _simsimd_capabilities_x86() in simsimd.h to detect supported features
16+
# The only simsimd functions we use in the vector index are cos/l2/l2_sq/dot which only branch for the targets 'skylake', 'haswell', and 'serial' so we only test for those
17+
if "avx512f" in flags_str:
18+
return "skylake"
19+
elif "avx2" in flags_str and "f16c" in flags_str and "fma" in flags_str:
20+
return "haswell"
21+
else:
22+
return "serial"
23+
24+
25+
bp = gdb.Breakpoint(f"simsimd_l2_f32_{get_machine_architecture()}")
26+
27+
gdb.execute("run < scripts/simd-dispatch-test.cypher")
28+
29+
try:
30+
gdb.execute("continue")
31+
# we only care if the breakpoint is hit at all
32+
# disable it now to prevent the test from needing to execute 'continue' many times to reach completion
33+
bp.enabled = False
34+
except gdb.error:
35+
# the program has terminated
36+
pass
37+
38+
# Check if the breakpoint was hit
39+
if bp.hit_count == 0:
40+
print(
41+
f"Error: did not hit the expected simsimd function for machine architecture '{get_machine_architecture()}'"
42+
)
43+
gdb.execute("quit 1")
44+
45+
gdb.execute("quit")

0 commit comments

Comments
 (0)