Skip to content

Commit fb62bab

Browse files
authored
Add job for testing simsimd dynamic dispatch to nightly build-and-deploy workflow (#5007)
1 parent f8f1517 commit fb62bab

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed

.github/workflows/linux-precompiled-bin-workflow.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
type: boolean
99
required: true
1010
default: false
11+
x86_64Only:
12+
type: boolean
13+
required: false
14+
default: false
1115

1216
env:
1317
PIP_BREAK_SYSTEM_PACKAGES: 1
@@ -53,6 +57,7 @@ jobs:
5357
path: kuzu_cli-linux-x86_64.tar.gz
5458

5559
build-precompiled-bin-aarch64:
60+
if: ${{ inputs.x86_64Only != true }}
5661
runs-on: kuzu-self-hosted-linux-building-aarch64
5762
steps:
5863
- uses: actions/checkout@v4
@@ -92,6 +97,7 @@ jobs:
9297
path: kuzu_cli-linux-aarch64.tar.gz
9398

9499
build-precompiled-bin-android-armv8a:
100+
if: ${{ inputs.x86_64Only != true }}
95101
runs-on: kuzu-self-hosted-testing
96102
steps:
97103
- uses: actions/checkout@v4
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: SimSIMD Dispatch Test
2+
on:
3+
schedule:
4+
- cron: "0 5 * * *"
5+
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-precompiled-bin-linux:
10+
uses: ./.github/workflows/linux-precompiled-bin-workflow.yml
11+
with:
12+
isNightly: true
13+
x86_64Only: true
14+
secrets: inherit
15+
16+
simsimd-dispatch-test:
17+
name: simsimd-dispatch-test
18+
needs: build-precompiled-bin-linux
19+
runs-on: kuzu-self-hosted-testing
20+
env:
21+
NUM_THREADS: 32
22+
GEN: Ninja
23+
CC: gcc
24+
CXX: g++
25+
steps:
26+
- name: Download nightly build
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: kuzu_cli-linux-x86_64
30+
31+
- name: Extract kuzu shell
32+
run: |
33+
tar xf kuzu_cli-linux-x86_64.tar.gz
34+
35+
- name: Test
36+
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('embeddings', 'e_hnsw_index', 'vec', distFunc := 'l2');
4+
CALL QUERY_HNSW_INDEX('embeddings', 'e_hnsw_index', 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)