Skip to content

Commit 53432ba

Browse files
committed
spike: macOS opencv snapshot workflow (headless core/imgproc/imgcodecs) + gen_descriptor ISA_RE neon
1 parent faa6a7a commit 53432ba

2 files changed

Lines changed: 79 additions & 1 deletion

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# TEMP spike: generate a macOS-arm64 (headless core/imgproc/imgcodecs) config
2+
# snapshot for compat.opencv on a real macos-15 runner, then emit the descriptor
3+
# via gen_descriptor.py and upload it as an artifact. Two-phase (like the ffmpeg
4+
# snapshot): this captures + generates; a follow-up build spike validates it.
5+
name: snapshot-macos-opencv
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches: [spike/opencv-macos-snapshot]
10+
jobs:
11+
snapshot:
12+
runs-on: macos-15
13+
timeout-minutes: 90
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: install toolchain
17+
run: brew install cmake ninja
18+
- name: fetch + extract OpenCV 5.0.0
19+
run: |
20+
set -eux
21+
V=5.0.0
22+
SHA=b0528f5a1d379d59d4701cb28c36e22214cc51cf64594e5b56f2d3e6c0233095
23+
curl -L -fsS -o opencv.tar.gz "https://github.com/opencv/opencv/archive/refs/tags/$V.tar.gz"
24+
echo "$SHA opencv.tar.gz" | shasum -a 256 -c -
25+
tar -xzf opencv.tar.gz
26+
echo "SRC=$PWD/opencv-$V" >> "$GITHUB_ENV"
27+
- name: cmake configure (headless, aarch64, no external probes)
28+
run: |
29+
set -eux
30+
cmake -G Ninja -S "$SRC" -B bld \
31+
-DCMAKE_BUILD_TYPE=Release \
32+
-DBUILD_LIST=core,imgproc,imgcodecs \
33+
-DBUILD_SHARED_LIBS=OFF \
34+
-DBUILD_ZLIB=ON -DBUILD_PNG=ON -DBUILD_JPEG=ON \
35+
-DWITH_TIFF=OFF -DWITH_WEBP=OFF -DWITH_OPENJPEG=OFF -DWITH_JASPER=OFF \
36+
-DWITH_OPENEXR=OFF -DWITH_AVIF=OFF -DWITH_JPEGXL=OFF -DWITH_IMGCODEC_GIF=OFF \
37+
-DWITH_OPENCL=OFF -DWITH_IPP=OFF -DWITH_LAPACK=OFF -DWITH_EIGEN=OFF -DWITH_ITT=OFF \
38+
-DWITH_QT=OFF -DWITH_OPENGL=OFF -DWITH_FFMPEG=OFF -DWITH_GSTREAMER=OFF \
39+
-DWITH_AVFOUNDATION=OFF -DWITH_V4L=OFF -DWITH_OBSENSOR=OFF \
40+
-DWITH_PROTOBUF=OFF -DWITH_CAROTENE=OFF -DWITH_FLATBUFFERS=OFF \
41+
-DWITH_UNIFONT=OFF -DWITH_ADE=OFF \
42+
-DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_EXAMPLES=OFF \
43+
-DBUILD_opencv_apps=OFF -DBUILD_JAVA=OFF -DBUILD_opencv_python3=OFF
44+
- name: reference build (materialize generators; -k keeps going past ICEs)
45+
run: ninja -C bld -k 0 > bld/ninja-build.log 2>&1 || true
46+
- name: dump compile commands + gen descriptor
47+
run: |
48+
set -eux
49+
ninja -C bld -t commands > bld/ninja-cmds.log
50+
python3 tools/compat-opencv/gen_descriptor.py \
51+
"$SRC" bld 5.0.0 \
52+
b0528f5a1d379d59d4701cb28c36e22214cc51cf64594e5b56f2d3e6c0233095 \
53+
compat.opencv.macgen.lua
54+
# retarget the single-platform emission to macosx + a spike name
55+
sed -e 's/^ linux = {{/ macosx = {{/' \
56+
-e 's/^ linux = {/ macosx = {/' \
57+
-e 's/name = "compat.opencv"/name = "compat.opencvmac"/' \
58+
compat.opencv.macgen.lua > compat.opencvmac.lua
59+
echo "=== descriptor head ==="; head -60 compat.opencvmac.lua
60+
echo "=== sanity: aarch64 SIMD dispatch files present? ==="
61+
grep -oE '\.(neon[a-z0-9_]*|fp16)\.cpp' bld/ninja-cmds.log | sort | uniq -c || true
62+
- name: upload artifact
63+
if: always()
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: opencv-macos-snapshot
67+
path: |
68+
compat.opencvmac.lua
69+
compat.opencv.macgen.lua
70+
bld/cvconfig.h
71+
bld/cv_cpu_config.h
72+
bld/ninja-cmds.log
73+
bld/ninja-build.log

tools/compat-opencv/gen_descriptor.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@
8686
assert compiles, "no compile commands parsed"
8787
print(f"parsed {len(compiles)} compiles")
8888

89-
ISA_RE = re.compile(r"\.(sse4_1|sse4_2|avx512_skx|avx2|avx|fp16)\.cpp$")
89+
# x86 dispatch suffixes + aarch64 NEON dispatch suffixes (macOS/arm). Longest
90+
# alternatives first so `.neon_dotprod.cpp` isn't shadowed by `neon` (the
91+
# trailing `\.cpp$` anchor already forces a full match, but keep it explicit).
92+
ISA_RE = re.compile(
93+
r"\.(sse4_1|sse4_2|avx512_skx|avx2|avx|fp16"
94+
r"|neon_dotprod|neon_fp16|neon_bf16|neon_i8mm|neon)\.cpp$")
9095
MODS = ("core", "imgproc", "imgcodecs", "highgui", "videoio", "flann", "geometry", "dnn")
9196
# groups that belong to the additive `dnn` feature (sources gated; flags
9297
# entries stay unconditional — harmless when the feature is off)

0 commit comments

Comments
 (0)