Elffuss BraidHub

kikocis/kleidiai public

chore: Split .gitlab-ci.yml into kleidiai.yml and experimental-ops.yml

Split ci yml files into `.gitlab/ci/kleidiai.yml`, and `experimental-ops` to provide better CI pipeline trigger granularity. Leaving `gitlab-ci.yml` as shared CI entry point for includes, stages, global variables, defaults & workflow rules.

It ensures shared root CI changes still trigger both relevant job groups, but separates the KleidiAI/ and experimental-ops/ CI change-gating separate.

Other changes:
- Adds `RUN_EXPERIMENTAL_OPS_CI` so manually/API-triggered pipelines can opt into experimental ops jobs.
- Updates experimental ops rules to trigger on shared root `.gitlab-ci.yml` changes.
- Replaces GitLab-specific `!reference` usage with standard YAML anchors.
- Simplifies YAML pre-commit checking now that the CI files are standard YAML.

Signed-off-by: Cathal Lawlor <cathal.lawlor@arm.com>

Approved-by: Puneet Matharu <puneet.matharu@arm.com>
Approved-by: Aude Vuilliomenet <aude.vuilliomenet@arm.com>
Changeset4bba2d545594ec3ecbb9dc6d3473afc106aec6b315827f53b25e916c2d4dedb8
AuthorCathal Lawlor <cathal.lawlor@arm.com> · 2026-07-15 14:00 UTC
CommitterCathal Lawlor <cathal.lawlor@arm.com> · 2026-07-15 14:00 UTC
Parentsbf68ff371319

Browse the files at this changeset

4 files changed

modified .gitlab-ci.yml +9 −1108
@@ -4,25 +4,16 @@
44 # SPDX-License-Identifier: Apache-2.0
55 #
66 # Summary:
7-# Run builds using different compilers, runs unit & example tests, performs static analysis,
8-# gathers multi-variant coverage and publishes HTML/JUnit/Cobertura reports.
9-# Stable jobs validate the top-level tree, while experimental jobs validate experimental/ops
10-# separately when that subtree changes or on release-style pipelines.
7+# Shared public CI entry point. It defines global defaults and includes the
8+# project-specific CI files for KleidiAI and experimental/ops.
119 # Purpose and scope:
12-# - Provide public-facing CI validating portability and feature coverage of the library.
13-# - Ensure all warnings are treated as errors across compilers.
14-# - Model negative/positive feature scenarios (illegal instruction paths, SME variants).
15-# - Collect code coverage across distinct environments & feature sets.
16-# - Offer reproducible pre-commit formatting / lint checks.
17-# Main jobs (high-level):
18-# - build-* : compile core library/tests/examples with different toolchains.
19-# - test-* : execute unit tests (sharded), examples, FVP feature model tests, clang-tidy.
20-# - coverage-* : produce per-variant JSON coverage traces.
21-# - coverage : aggregate traces into Cobertura + HTML.
22-# - pages : publish coverage reports via Pages.
23-# Usage notes:
24-# - FVP jobs simulate CPU feature sets; failures (Illegal instruction) are expected in negative tests.
25-# - CI caching policy switches to pull-push on default branch to warm shared caches.
10+# - Keep shared stages, variables, defaults and workflow rules in one place.
11+# - Include focused job definitions from .gitlab/ci/*.yml.
12+# - Preserve release/default-branch behavior through GitLab's expanded config.
13+
14+include:
15+ - local: .gitlab/ci/kleidiai.yml
16+ - local: .gitlab/ci/experimental-ops.yml
2617
2718 stages:
2819 - build
@@ -98,69 +89,6 @@
9889 - stuck_or_timeout_failure
9990 - runner_system_failure
10091
101-# Base template: .standard-rules
102-# Purpose: Common rules & timeout setting
103-.standard-rules:
104- timeout: 30m
105- rules:
106- # Run a job for merge requests
107- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
108- # Run a job for default (main) branch
109- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
110- variables:
111- CACHE_POLICY: pull-push
112- # Run a job for protected tags (release and rc ones)
113- - if: $CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"
114-
115-# Base template: .stable-rules
116-# Purpose: Run top-level project checks only when core project files change in MRs,
117-# and always on default branch/protected tags.
118-.stable-rules:
119- timeout: 30m
120- rules:
121- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
122- changes: &stable_changes
123- - "*"
124- - ".*"
125- - benchmark/**/*
126- - cmake/**/*
127- - docker/**/*
128- - docs/**/*
129- - examples/**/*
130- - kai/**/*
131- - LICENSES/**/*
132- - test/**/*
133- - third_party/**/*
134- - tools/**/*
135- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
136- variables:
137- CACHE_POLICY: pull-push
138- - if: $CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"
139-
140-# Base template: .main-branch-verification-rules
141-# Purpose: Common opt-out rules for jobs validating main branch state
142-.main-branch-verification-rules:
143- rules:
144- - if: >
145- $DISABLE_MAIN_BRANCH_VERIFICATION_JOBS != "true" &&
146- $CI_PIPELINE_SOURCE == 'merge_request_event' &&
147- $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != 'main'
148- when: never
149- - if: >
150- $DISABLE_MAIN_BRANCH_VERIFICATION_JOBS != "true" &&
151- $CI_PIPELINE_SOURCE == 'merge_request_event' &&
152- $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'main'
153- changes: *stable_changes
154- - if: >
155- $DISABLE_MAIN_BRANCH_VERIFICATION_JOBS != "true" &&
156- $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
157- variables:
158- CACHE_POLICY: pull-push
159- - if: >
160- $DISABLE_MAIN_BRANCH_VERIFICATION_JOBS != "true" &&
161- $CI_COMMIT_TAG &&
162- $CI_COMMIT_REF_PROTECTED == "true"
163-
16492 workflow:
16593 auto_cancel:
16694 # Interrupt old pipeline when new one pushed for MR
@@ -170,1030 +98,3 @@
17098 - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_DRAFT == "true"
17199 when: never
172100 - when: always
173-
174-# Purpose: Build library tests.
175-build-clang:
176- extends:
177- - .stable-rules
178- stage: build
179- script:
180- # Enforce strict warning-as-error policy
181- - cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror" -DCMAKE_BUILD_TYPE=Release -DKLEIDIAI_BUILD_TESTS=ON -DKLEIDIAI_BUILD_BENCHMARK=ON -S . -B ${CI_JOB_NAME_SLUG}
182- # Parallel build capped to reserved CPUs.
183- - cmake --build ${CI_JOB_NAME_SLUG} -j${PARALLEL_JOBS} --verbose
184- artifacts:
185- expire_in: 1 day
186- paths:
187- - ${CI_JOB_NAME_SLUG}/kleidiai_test
188- - ${CI_JOB_NAME_SLUG}/kleidiai_benchmark
189-
190-# Purpose: Build library tests.
191-build-gcc:
192- extends:
193- - .stable-rules
194- stage: build
195- script:
196- # Enforce strict warning-as-error policy
197- - cmake -G Ninja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror" -DCMAKE_BUILD_TYPE=Release -DKLEIDIAI_BUILD_TESTS=ON -DKLEIDIAI_BUILD_BENCHMARK=ON -S . -B ${CI_JOB_NAME_SLUG}
198- # Parallel build capped to reserved CPUs with verbose
199- - cmake --build ${CI_JOB_NAME_SLUG} -j${PARALLEL_JOBS} --verbose
200- artifacts:
201- expire_in: 1 day
202- paths:
203- - ${CI_JOB_NAME_SLUG}/kleidiai_test
204- - ${CI_JOB_NAME_SLUG}/kleidiai_benchmark
205-
206-# Purpose: Build library tests.
207-build-gcc-bazel:
208- extends:
209- - .stable-rules
210- stage: build
211- variables:
212- # Cache Bazelisk files in local folder
213- BAZELISK_HOME: '.cache/bazelisk'
214- cache:
215- - key: cache-bazelisk
216- paths:
217- - $BAZELISK_HOME
218- policy: $CACHE_POLICY
219- script:
220- # Ensure deterministic build state.
221- - bazelisk clean
222- # Enforce strict warning-as-error policy, cap parallel build and continues to gather full failure set
223- - bazelisk build -c opt --copt="-Werror" --cxxopt="-Werror" --jobs=${PARALLEL_JOBS} -k --subcommands --verbose_failures --curses=no //...
224- # Copy build artifacts to separate folder
225- - mkdir -p ${CI_JOB_NAME_SLUG} && cp bazel-bin/test/kleidiai_test ${CI_JOB_NAME_SLUG}/
226- artifacts:
227- expire_in: 1 day
228- paths:
229- - ${CI_JOB_NAME_SLUG}/kleidiai_test
230-
231-# Purpose: Build library tests
232-build-clang-bazel:
233- extends:
234- - .stable-rules
235- stage: build
236- variables:
237- # Cache Bazelisk files in local folder
238- BAZELISK_HOME: '.cache/bazelisk'
239- cache:
240- - key: cache-bazelisk
241- paths:
242- - $BAZELISK_HOME
243- policy: $CACHE_POLICY
244- script:
245- # Ensure deterministic build state.
246- - bazelisk clean
247- # Enforce strict warning-as-error policy, cap parallel build and continues to gather full failure set.
248- # Also disable explicit layering_check feature supported by the compiler
249- - CC=clang bazelisk build -c opt --copt="-Werror" --cxxopt="-Werror" --jobs=${PARALLEL_JOBS} -k --subcommands --verbose_failures --compiler=clang --features=no-layering_check --curses=no //...
250- # Copy build artifacts to separate folder
251- - mkdir -p ${CI_JOB_NAME_SLUG} && cp bazel-bin/test/kleidiai_test ${CI_JOB_NAME_SLUG}/
252- artifacts:
253- expire_in: 1 day
254- paths:
255- - ${CI_JOB_NAME_SLUG}/kleidiai_test
256-
257-# Purpose: Build examples
258-build-examples:
259- stage: build
260- extends:
261- - .stable-rules
262- script:
263- - mkdir -p build
264- - |
265- for EXAMPLE in `ls examples -1`; do
266- # Validate that each example has a build script
267- if [ -f examples/${EXAMPLE}/CMakeLists.txt ]; then
268- echo "-----------------------------------------------------------"
269- echo "Build examples/${EXAMPLE}"
270- echo "-----------------------------------------------------------"
271- mkdir -p build_${EXAMPLE}
272- cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror" -DCMAKE_BUILD_TYPE=Release -S examples/$EXAMPLE -B build_${EXAMPLE}
273- cmake --build build_${EXAMPLE} -j${PARALLEL_JOBS} --verbose
274- # Store in top level build/ folder, assuming output binary name is same as folder
275- cp build_${EXAMPLE}/${EXAMPLE} build/
276- else
277- # Guard against missing build config.
278- echo "No build file found for ${EXAMPLE}"
279- exit 1
280- fi
281- done
282- artifacts:
283- expire_in: 1 day
284- paths:
285- - build
286-
287-# Purpose: Run non-SME examples; skip SME variants (handled in dedicated job) and log output.
288-test-examples:
289- stage: test
290- extends:
291- - .stable-rules
292- needs:
293- - build-examples
294- script:
295- - |
296- for EXAMPLE in `ls build -1`; do
297- # Skip SME examples (run separately).
298- [[ $EXAMPLE == *sme* ]] && continue
299- echo "-----------------------------------------------------------"
300- echo "Run ${EXAMPLE}"
301- echo "-----------------------------------------------------------"
302- # Run and preserve separate log
303- build/${EXAMPLE} | tee -a example_${EXAMPLE}.log
304- done
305- artifacts:
306- expire_in: 1 day
307- paths:
308- - "example_*.log"
309-
310-# Purpose: clang-tidy static analysis of library C/C++ sources.
311-test-clang-tidy:
312- extends:
313- - .stable-rules
314- stage: test
315- needs: []
316- script:
317- # Build and generate compilation_database.json for proper flags propagation to post processing tools
318- - cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror" -DCMAKE_BUILD_TYPE=Release -DKLEIDIAI_BUILD_TESTS=ON -DKLEIDIAI_BUILD_BENCHMARK=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -B build/${CI_JOB_NAME_SLUG}
319- # Only test the main library with C/C++ files.
320- - clang-tidy --header-filter ".*" --warnings-as-errors "*" -p build/${CI_JOB_NAME_SLUG} $(find kai -type f \( -name \*.c -o -name \*.cpp \))
321-
322-# Purpose: Verify that all micro-kernels are registered for benchmarking.
323-test-verify-benchmark-registration:
324- extends:
325- - .stable-rules
326- stage: test
327- needs: []
328- rules:
329- - !reference [.main-branch-verification-rules, rules]
330- script:
331- - python3 tools/check_benchmark_microkernels.py
332-
333-# Purpose: Verify that all micro-kernels are documented in docs/microkernel_tables.md.
334-test-verify-microkernel-tables:
335- extends:
336- - .stable-rules
337- stage: test
338- needs: []
339- rules:
340- - !reference [.main-branch-verification-rules, rules]
341- script:
342- - python3 tools/check_microkernel_tables.py
343-
344-# Purpose: Verify that all micro-kernels have correct names.
345-test-verify-microkernel-names:
346- extends:
347- - .stable-rules
348- stage: test
349- needs: []
350- rules:
351- - !reference [.main-branch-verification-rules, rules]
352- script:
353- - python3 tools/check_microkernel_names.py
354- - python3 tools/check_microkernel_names.py --generate-documentation docs/microkernel_names.md
355- - |
356- if [ -n "$(git status --porcelain -- docs/microkernel_names.md)" ]; then
357- echo "docs/microkernel_names.md is out of date."
358- echo "Run:"
359- echo " python3 tools/check_microkernel_names.py --generate-documentation docs/microkernel_names.md"
360- echo "and commit the result whenever tools/naming/rules.py is updated."
361- git diff -- docs/microkernel_names.md
362- exit 1
363- fi
364-
365-# Purpose: Verify that all micro-kernel headers contain include directives for used symbols.
366-test-verify-microkernel-header-includes:
367- extends:
368- - .stable-rules
369- stage: test
370- needs: []
371- rules:
372- - !reference [.main-branch-verification-rules, rules]
373- script:
374- - python3 tools/check_microkernel_header_includes.py
375-
376-# Purpose: Build current sources against tests/benchmarks from latest semver tag to detect API breakage.
377-test-api-compat:
378- extends:
379- - .stable-rules
380- stage: test
381- needs: []
382- rules:
383- - !reference [.main-branch-verification-rules, rules]
384- script:
385- - ./tools/check_api_compat.py
386-
387-# Purpose: Run pre-commit hooks (formatting, linting) with cached tool downloads.
388-pre-commit-hooks:
389- variables:
390- PRE_COMMIT_HOME: '.cache/pre-commit'
391- extends:
392- - .standard-rules
393- stage: build
394- # Cache downloaded pre-commit checkers
395- cache:
396- - key: cache-pre-commit
397- paths:
398- - $PRE_COMMIT_HOME
399- policy: $CACHE_POLICY
400- script:
401- - PRE_COMMIT_HOME=$PRE_COMMIT_HOME pre-commit run --all-files
402-
403-# Purpose: Validate MR metadata used as the squash/merge commit message.
404-test-verify-squash-commit-message:
405- stage: test
406- needs: []
407- rules:
408- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
409- script:
410- - python3 tools/check_squash_commit_message.py
411-
412-# Purpose: Manual gate job to record external pipeline status.
413-test-remote:
414- # Part of the pipeline is executed in a separate system.
415- #
416- # When the remote pipeline has been completed, this job is triggered automatically
417- # with the information about the remote pipeline including whether it's passed or failed.
418- rules:
419- # Run the job only for a public pipeline
420- - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_SERVER_HOST == 'gitlab.arm.com'
421- # Longer timeout than rest of jobs to account for external system load
422- timeout: 1h
423- stage: test
424- needs: []
425- when: manual
426- allow_failure: false
427- variables:
428- REMOTE_PIPELINE_ID: 0
429- REMOTE_PIPELINE_PASSED: ""
430- REMOTE_PIPELINE_MESSAGE: ""
431- script:
432- - echo "REMOTE_PIPELINE_ID=${REMOTE_PIPELINE_ID}" |& tee remote_result.txt
433- - echo "REMOTE_PIPELINE_PASSED=${REMOTE_PIPELINE_PASSED}" |& tee -a remote_result.txt
434- - echo "REMOTE_PIPELINE_MESSAGE=${REMOTE_PIPELINE_MESSAGE}" |& tee -a remote_result.txt
435- - echo "${REMOTE_PIPELINE_PASSED}" | grep -q "true"
436- artifacts:
437- when: always
438- expire_in: 1 day
439- paths:
440- - remote_result.txt
441-
442-# Script anchor: run-unit-tests
443-# Purpose: Sharded GoogleTest execution producing multiple XML reports to be below CI limits.
444-# Input variables:
445-# * UT_VARIANT_NAME - base name used to find path to unit test binaries and generate report name
446-# * UT_PARALLEL - number of separate executions, default 4 since 100MB / 30MB = 3.(3) and rounded up
447-# * UT_BINARY_PATH - path to folder with unit test binaries, default is ./build-${UT_VARIANT_NAME}/
448-# * UT_REPORT_PATH - prefix to unit test report file path, default is ./kleidiai_results-${UT_VARIANT_NAME}
449-# * UT_EXTRA_ARGS - extra arguments for test binary, default is none
450-.run-unit-tests: &run-unit-tests
451- - echo "Run unit test from ${UT_BINARY_PATH:-./build-${UT_VARIANT_NAME}}"
452- - export GTEST_TOTAL_SHARDS=${UT_PARALLEL:-4}
453- - |
454- : "${KAI_TEST_BUFFER_POLICY:?KAI_TEST_BUFFER_POLICY must be set}"
455- echo "KAI_TEST_BUFFER_POLICY=${KAI_TEST_BUFFER_POLICY}"
456- export ASAN_OPTIONS="${ASAN_OPTIONS:+${ASAN_OPTIONS}:}halt_on_error=1:print_stacktrace=1"
457- export UBSAN_OPTIONS="${UBSAN_OPTIONS:+${UBSAN_OPTIONS}:}halt_on_error=1:print_stacktrace=1"
458- printf 'section_start:%s:test_environment[collapsed=true]\r\e[0KTest environment\n' "$(date +%s)"
459- echo "uname=$(uname -a)"
460- echo "cc=$(command -v cc || true)"
461- cc --version | head -5 || true
462- echo "cxx=$(command -v c++ || true)"
463- c++ --version | head -5 || true
464- echo "ASAN_OPTIONS=${ASAN_OPTIONS:-}"
465- echo "UBSAN_OPTIONS=${UBSAN_OPTIONS:-}"
466- printf 'section_end:%s:test_environment\r\e[0K\n' "$(date +%s)"
467- {
468- echo "job=${CI_JOB_NAME:-}"
469- echo "job_slug=${CI_JOB_NAME_SLUG:-}"
470- echo "commit=${CI_COMMIT_SHA:-}"
471- echo "seed=${GLOBAL_TEST_SEED:-42}"
472- echo "total_shards=${GTEST_TOTAL_SHARDS}"
473- echo "binary_path=${UT_BINARY_PATH:-./build-${UT_VARIANT_NAME}}/kleidiai_test"
474- echo "buffer_policy=${KAI_TEST_BUFFER_POLICY}"
475- echo "extra_args=${UT_EXTRA_ARGS:-}"
476- echo "quiet=${KLEIDIAI_TEST_CI_QUIET:-1}"
477- }
478- - |
479- for GTEST_SHARD_INDEX in `seq 0 $((GTEST_TOTAL_SHARDS - 1))` ; do
480- # Export index variable to child process
481- export GTEST_SHARD_INDEX
482- TEST_STDOUT_FILENAME="${UT_REPORT_PATH:-kleidiai_results-${UT_VARIANT_NAME}}${GTEST_SHARD_INDEX}.log"
483- echo "Running iteration $GTEST_SHARD_INDEX of $GTEST_TOTAL_SHARDS"
484- set +e
485- KLEIDIAI_TEST_CI_QUIET=${KLEIDIAI_TEST_CI_QUIET:-1} ${UT_BINARY_PATH:-./build-${UT_VARIANT_NAME}}/kleidiai_test --gtest_brief=1 --gtest_output=xml:${UT_REPORT_PATH:-kleidiai_results-${UT_VARIANT_NAME}}${GTEST_SHARD_INDEX}.xml --gtest_random_seed=${GLOBAL_TEST_SEED:-42} ${UT_EXTRA_ARGS:-} > "${TEST_STDOUT_FILENAME}" 2>&1
486- TEST_EXIT_CODE=$?
487- set -e
488- grep -E '^\[==========\]|^\[ PASSED \]|^\[ FAILED \]|^\[ SKIPPED \]|^Test seed|^[[:space:]]+[0-9]+ - ' "${TEST_STDOUT_FILENAME}" || true
489- if [ "${TEST_EXIT_CODE}" -ne 0 ]; then
490- if [ -f tools/ci/summarise_gtest.py ]; then
491- python3 tools/ci/summarise_gtest.py "${UT_REPORT_PATH:-kleidiai_results-${UT_VARIANT_NAME}}${GTEST_SHARD_INDEX}.xml" || true
492- else
493- echo "JUnit summary unavailable: tools/ci/summarise_gtest.py not found"
494- fi
495- echo "Test shard failed; last 200 output lines from ${TEST_STDOUT_FILENAME}:"
496- tail -200 "${TEST_STDOUT_FILENAME}" || true
497- exit "${TEST_EXIT_CODE}"
498- fi
499- done
500-
501-# Purpose: Sharded unit tests for each build provider.
502-test-linux-aarch64:
503- extends:
504- - .stable-rules
505- stage: test
506- parallel:
507- matrix:
508- # All current build jobs
509- - BUILD_JOB_PROVIDER: [ clang, gcc, clang-bazel, gcc-bazel ]
510- needs:
511- # A CI system limitation does not allow usage of matrix variables to avoid fetching unnecessary artifacts.
512- # So make sure to fetch artifacts from all jobs required.
513- - build-gcc
514- - build-gcc-bazel
515- - build-clang
516- - build-clang-bazel
517- script:
518- # Explicitly configure overflow protection for public unit tests.
519- # The shared unit-test runner requires this variable to be set.
520- - |
521- export KAI_TEST_BUFFER_POLICY=PROTECT_OVERFLOW
522- UT_VARIANT_NAME=$BUILD_JOB_PROVIDER
523- UT_REPORT_PATH=kleidiai_test_results-${BUILD_JOB_PROVIDER}
524- # Export UT_REPORT_PATH to CI env to use in artifacts
525- echo "UT_REPORT_PATH=$UT_REPORT_PATH" >> $GITLAB_ENV
526- - *run-unit-tests
527- artifacts:
528- when: always
529- expire_in: 1 day
530- paths:
531- - ${UT_REPORT_PATH}*.xml
532- - ${UT_REPORT_PATH}*.log
533- reports:
534- junit: ${UT_REPORT_PATH}*.xml
535-
536-# Purpose: Specialization of test-linux-aarch64 to run only SVE 256-bit VL unit test subset
537-test-linux-aarch64-sve256:
538- extends:
539- - test-linux-aarch64
540- variables:
541- # Generation 7 is the instance with SVE VL 256
542- KUBERNETES_NODE_SELECTOR_INSTANCE_GENERATION: "karpenter.k8s.aws/instance-generation=7"
543- # Run only SVE unit tests
544- GTEST_FILTER: "*_sve_*"
545-
546-# Base template: .test-linux-aarch64-fvp
547-# Purpose: Common FVP unit-test runner for feature-specific tests.
548-.test-linux-aarch64-fvp:
549- extends:
550- - .stable-rules
551- stage: test
552- parallel:
553- matrix:
554- - BUILD_JOB_PROVIDER: [ clang, gcc, clang-bazel, gcc-bazel ]
555- needs:
556- - build-gcc
557- - build-gcc-bazel
558- - build-clang
559- - build-clang-bazel
560- variables:
561- # Long test requires more stable node
562- KUBERNETES_NODE_SELECTOR_TYPE: "karpenter.sh/capacity-type=on-demand"
563- FVP_TEST_EXECUTABLE: "./build-${BUILD_JOB_PROVIDER}/kleidiai_test --gtest_brief=1 --gtest_output=xml:kleidiai_test_results-${BUILD_JOB_PROVIDER}.xml --gtest_random_seed=${GLOBAL_TEST_SEED:-42}"
564- script:
565- - ./tools/fvp.sh ${FVP_TEST_EXECUTABLE}
566- artifacts:
567- when: always
568- expire_in: 1 day
569- paths:
570- - kleidiai_test_results-${BUILD_JOB_PROVIDER}.xml
571- reports:
572- junit: kleidiai_test_results-${BUILD_JOB_PROVIDER}.xml
573-
574-# Purpose: FVP feature tests with disabled SVE/SVE2 but enabled SME/SME2
575-# Disabled at the moment due to huge amount of SME/SME2 kernels
576-.test-linux-aarch64-fvp-nosve:
577- extends:
578- - .test-linux-aarch64-fvp
579- variables:
580- # Disable SVE/SVE2, but keep SME/SME2
581- FVP_MODEL_EXTRA: "-C cluster0.sve.has_sve2=0 -C cluster0.sve.sme_only=1"
582-
583-# Purpose: FVP SVE2.1 unit tests.
584-test-linux-aarch64-sve2p1-fvp:
585- extends:
586- - .test-linux-aarch64-fvp
587- timeout: 1h
588- variables:
589- # Enable SVE2.1 support explicitly for this feature-specific FVP run.
590- FVP_MODEL_EXTRA: "-C cluster0.sve.has_sve2=1 -C cluster0.sve.sve2_version=1"
591- # Run only SVE2.1 unit tests.
592- GTEST_FILTER: "*sve2p1*"
593- FVP_TEST_EXECUTABLE: "KLEIDIAI_TEST_CI_QUIET=1 ./build-${BUILD_JOB_PROVIDER}/kleidiai_test --gtest_brief=1 --test_size small --gtest_output=xml:kleidiai_test_results-${BUILD_JOB_PROVIDER}.xml --gtest_random_seed=${GLOBAL_TEST_SEED:-42}"
594- script:
595- - ./tools/fvp.sh -- "${FVP_TEST_EXECUTABLE}" | tee output.txt
596- - "grep -qE 'Features\\s+:.*sve2p1' output.txt"
597- artifacts:
598- when: always
599- expire_in: 1 day
600- paths:
601- - kleidiai_test_results-${BUILD_JOB_PROVIDER}.xml
602- - output.txt
603- reports:
604- junit: kleidiai_test_results-${BUILD_JOB_PROVIDER}.xml
605-
606-# Purpose: FVP v8-only model; expect Illegal instruction for examples; validates CPU feature detection path.
607-test-linux-aarch64-v8only-fvp:
608- extends:
609- - .stable-rules
610- stage: test
611- needs:
612- - build-clang
613- - build-examples
614- script:
615- # Make sure to match disabled V8 and V9 version to enabled in tools/fvp.sh, otherwise the test would fail
616- - >
617- export FVP_MODEL_EXTRA="
618- -C cluster0.has_arm_v8-1=0
619- -C cluster0.has_arm_v8-2=0
620- -C cluster0.has_arm_v8-3=0
621- -C cluster0.has_arm_v8-4=0
622- -C cluster0.has_arm_v8-5=0
623- -C cluster0.has_arm_v8-6=0
624- -C cluster0.has_arm_v8-7=0
625- -C cluster0.has_arm_v8-8=0
626- -C cluster0.has_arm_v8-9=0
627- -C cluster0.has_arm_v9-0=0
628- -C cluster0.has_arm_v9-1=0
629- -C cluster0.has_arm_v9-2=0
630- -C cluster0.has_arm_v9-3=0
631- -C cluster0.has_arm_v9-4=0
632- -C cluster0.has_arm_v9-5=0
633- -C cluster0.has_arm_v9-6=0
634- -C cluster0.has_sve=0"
635- # Generate test script with negative and positive tests
636- - |
637- echo -e "#\!/bin/bash -ex" > run_tests.sh
638- echo "echo Perform a negative test with illegal instructions" >> run_tests.sh
639- find build -type f -perm -a=x -print0 | \
640- while read -d '' EXAMPLE; do
641- echo -e "echo \"Run '${EXAMPLE}'\"" >> run_tests.sh
642- echo -e "./'${EXAMPLE}' || true" >> run_tests.sh # Allow failure (expected crash).
643- done
644- echo "echo Perform a positive test with CPU feature detection" >> run_tests.sh
645- echo "KLEIDIAI_TEST_CI_QUIET=1 ./build-clang/kleidiai_test --gtest_brief=1 --gtest_random_seed=\${GLOBAL_TEST_SEED:-42} || exit 1" >> run_tests.sh # Must succeed.
646- # Dump content for debugging purposes
647- - |
648- echo "Test script content:"
649- cat run_tests.sh
650- # Execute test script in FVP and capture output for feature assertions
651- - chmod a+x run_tests.sh
652- - ./tools/fvp.sh ./run_tests.sh | tee output.txt
653- # Verify that no extra features enabled and CPU variant is v8.0
654- - "grep -qE 'Features\\s+: fp asimd evtstrm cpuid' output.txt"
655- - "grep -qE 'CPU variant\\s+: 0' output.txt"
656- # Verify that all examples crashed with Illegal instruction (negative path coverage)
657- - test $(grep -cE "Illegal instruction\s+./'build/" output.txt) -eq $(ls -1 build | wc -l | tr -d ' ')
658-
659-# Purpose: FVP with only SME enabled (SME2 disabled); SME example runs.
660-test-linux-aarch64-sme1only-fvp:
661- extends:
662- - .stable-rules
663- timeout: 1h
664- stage: test
665- needs:
666- - build-clang
667- - build-examples
668- script:
669- # Disable SME2 in FVP
670- - >
671- export FVP_MODEL_EXTRA="
672- -C cluster0.sve.has_sme2=0
673- -C cluster0.sve.sme2_version=0" # Disable SME2.
674- # Generate test script
675- - |
676- echo -e "#\!/bin/bash -ex" > run_tests.sh
677- echo "echo Run SME examples" >> run_tests.sh
678- # Find any SME examples and execute them
679- find build -type f -perm -a=x \( -name \*_sme -o -name \*_sme_\* \) -print0 | \
680- while read -d '' EXAMPLE; do
681- echo -e "echo \"Run '${EXAMPLE}'\"" >> run_tests.sh
682- echo -e "./'${EXAMPLE}' || exit 1" >> run_tests.sh
683- done
684- # Dump content for debugging purposes
685- - |
686- echo "Test script content:"
687- cat run_tests.sh
688- - chmod a+x run_tests.sh
689- # Execute test script in FVP and capture output for feature assertions
690- - FVP_TEST_EXECUTABLE="./run_tests.sh"
691- - ./tools/fvp.sh ${FVP_TEST_EXECUTABLE} | tee output.txt
692- # Verify that SME2 is not available
693- - "grep -qv 'sme2' output.txt"
694- artifacts:
695- when: always
696- expire_in: 1 day
697- paths:
698- - output.txt
699-
700-# Purpose: Execute all SME examples under FVP; consolidate output into single log.
701-test-examples-sme-fvp:
702- extends:
703- - .stable-rules
704- stage: test
705- needs:
706- - build-examples
707- script:
708- # Generate test script with negative and positive tests
709- - |
710- echo -e "#\!/bin/bash -ex" > run_tests.sh
711- find build -type f -perm -a=x -name \*_sme\* -print0 | \
712- while read -d '' EXAMPLE; do
713- echo "echo ---------------------------------------------------" >> run_tests.sh
714- echo "echo Run '${EXAMPLE}'" >> run_tests.sh
715- echo "echo ---------------------------------------------------" >> run_tests.sh
716- echo "./'${EXAMPLE}' | tee -a example.log" >> run_tests.sh
717- done
718- # Dump content for debugging purposes
719- - |
720- echo "Test script content:"
721- cat run_tests.sh
722- # Execute test script in FVP and capture output for feature assertions
723- - chmod a+x run_tests.sh
724- - ./tools/fvp.sh ./run_tests.sh
725- artifacts:
726- when: always
727- expire_in: 1 day
728- paths:
729- - example.log
730-
731-# Base template: .experimental-ops-rules
732-# Notice: Temporarily disabled while the experimental/ops CI coverage is reworked.
733-# Purpose: Run experimental/ops checks only when relevant in MRs, and always on default branch/protected tags.
734-.experimental-ops-rules:
735- timeout: 1h
736- rules:
737- - when: never
738- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
739- changes:
740- - .gitlab-ci.yml
741- - experimental/ops/**/*
742- exists:
743- - experimental/ops/CMakeLists.txt
744- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
745- exists:
746- - experimental/ops/CMakeLists.txt
747- variables:
748- CACHE_POLICY: pull-push
749- - if: $CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"
750- exists:
751- - experimental/ops/CMakeLists.txt
752-
753-# Base template: .build-experimental-ops-native
754-# Purpose: Build the experimental/ops benchmark executable for native test jobs.
755-.build-experimental-ops-native:
756- extends:
757- - .experimental-ops-rules
758- stage: build
759- script:
760- - cmake -G Ninja
761- --toolchain ${CI_PROJECT_DIR}/${EXPERIMENTAL_OPS_TOOLCHAIN_FILE}
762- -DCMAKE_C_COMPILER=${EXPERIMENTAL_OPS_C_COMPILER}
763- -DCMAKE_CXX_COMPILER=${EXPERIMENTAL_OPS_CXX_COMPILER}
764- -DKLEIDIAI_OPS_ENABLE_BUILD_BENCHMARK=ON
765- ${EXPERIMENTAL_OPS_CMAKE_EXTRA:-}
766- -S experimental/ops
767- -B ${CI_JOB_NAME_SLUG}
768- - cmake --build ${CI_JOB_NAME_SLUG} -j${PARALLEL_JOBS} --verbose
769- artifacts:
770- expire_in: 1 day
771- paths:
772- - ${CI_JOB_NAME_SLUG}/benchmark/gemm
773-
774-# Base template: .test-experimental-ops-native
775-# Purpose: Run the native GEMM, convolution, and depthwise test plans.
776-.test-experimental-ops-native:
777- extends:
778- - .experimental-ops-rules
779- stage: test
780- timeout: 2h
781- variables:
782- RUNNER_SCRIPT_TIMEOUT: 2h
783- script:
784- - |
785- if [ -n "${EXPERIMENTAL_OPS_ASAN_OPTIONS:-}" ]; then
786- export ASAN_OPTIONS="${EXPERIMENTAL_OPS_ASAN_OPTIONS}"
787- fi
788- - echo "Running soak tests with ${PARALLEL_JOBS} threads"
789- - |
790- set -o pipefail
791- python3 experimental/ops/scripts/soak-full.py \
792- --test_plan_file experimental/ops/tests/configs/conv_tests.cfg \
793- --run_test_plan \
794- --conv \
795- --threads ${PARALLEL_JOBS} \
796- ${EXPERIMENTAL_OPS_SOAK_EXTRA_ARGS:-} \
797- --binary ${EXPERIMENTAL_OPS_BUILD_DIR}/benchmark/gemm 2>&1 \
798- | tee conv_tests.log
799- - |
800- set -o pipefail
801- python3 experimental/ops/scripts/soak-full.py \
802- --test_plan_file experimental/ops/tests/configs/depthwise_tests.cfg \
803- --run_test_plan \
804- --conv \
805- --kernel_filter depthwise \
806- --threads ${PARALLEL_JOBS} \
807- ${EXPERIMENTAL_OPS_SOAK_EXTRA_ARGS:-} \
808- --binary ${EXPERIMENTAL_OPS_BUILD_DIR}/benchmark/gemm 2>&1 \
809- | tee depthwise_tests.log
810- - |
811- set -o pipefail
812- python3 experimental/ops/scripts/soak-full.py \
813- --test_plan_file experimental/ops/tests/configs/gemm_tests.cfg \
814- --run_test_plan \
815- --threads ${PARALLEL_JOBS} \
816- ${EXPERIMENTAL_OPS_SOAK_EXTRA_ARGS:-} \
817- --binary ${EXPERIMENTAL_OPS_BUILD_DIR}/benchmark/gemm 2>&1 \
818- | tee gemm_tests.log
819- artifacts:
820- when: always
821- expire_in: 7 days
822- paths:
823- - conv_tests.log
824- - depthwise_tests.log
825- - gemm_tests.log
826- - soak-*/
827-
828-build-experimental-ops-clang-linux-aarch64:
829- extends:
830- - .build-experimental-ops-native
831- variables:
832- EXPERIMENTAL_OPS_C_COMPILER: clang
833- EXPERIMENTAL_OPS_CXX_COMPILER: clang++
834- EXPERIMENTAL_OPS_TOOLCHAIN_FILE: experimental/ops/toolchains/native/native-linux-aarch64-gnu.cmake
835-
836-build-experimental-ops-clang-asan-linux-aarch64:
837- extends:
838- - .build-experimental-ops-native
839- variables:
840- EXPERIMENTAL_OPS_C_COMPILER: clang
841- EXPERIMENTAL_OPS_CXX_COMPILER: clang++
842- EXPERIMENTAL_OPS_TOOLCHAIN_FILE: experimental/ops/toolchains/native/native-linux-aarch64-gnu.cmake
843- EXPERIMENTAL_OPS_CMAKE_EXTRA: >-
844- -DCMAKE_BUILD_TYPE=Debug
845- -DKLEIDIAI_OPS_CCXX_FLAGS_INIT:STRING=-g;-fsanitize=address;-fno-omit-frame-pointer;-fno-common
846- -DKLEIDIAI_OPS_LINKER_FLAGS_INIT:STRING=-fsanitize=address
847-
848-build-experimental-ops-gcc-linux-aarch64:
849- extends:
850- - .build-experimental-ops-native
851- variables:
852- EXPERIMENTAL_OPS_C_COMPILER: gcc
853- EXPERIMENTAL_OPS_CXX_COMPILER: g++
854- EXPERIMENTAL_OPS_TOOLCHAIN_FILE: experimental/ops/toolchains/native/native-linux-aarch64-gnu.cmake
855-
856-build-experimental-ops-clang-macos:
857- extends:
858- - .build-experimental-ops-native
859- tags:
860- - apple_silicon
861- variables:
862- EXPERIMENTAL_OPS_C_COMPILER: clang
863- EXPERIMENTAL_OPS_CXX_COMPILER: clang++
864- EXPERIMENTAL_OPS_TOOLCHAIN_FILE: experimental/ops/toolchains/native/native-macos-aarch64-clang.cmake
865-
866-build-experimental-ops-clang-asan-macos:
867- extends:
868- - .build-experimental-ops-native
869- tags:
870- - apple_silicon
871- variables:
872- EXPERIMENTAL_OPS_C_COMPILER: clang
873- EXPERIMENTAL_OPS_CXX_COMPILER: clang++
874- EXPERIMENTAL_OPS_TOOLCHAIN_FILE: experimental/ops/toolchains/native/native-macos-aarch64-clang.cmake
875- EXPERIMENTAL_OPS_CMAKE_EXTRA: >-
876- -DCMAKE_BUILD_TYPE=Debug
877- -DKLEIDIAI_OPS_CCXX_FLAGS_INIT:STRING=-g;-fsanitize=address;-fno-omit-frame-pointer;-fno-common
878- -DKLEIDIAI_OPS_LINKER_FLAGS_INIT:STRING=-fsanitize=address
879-
880-build-experimental-ops-android-arm64-v8a:
881- extends:
882- - .experimental-ops-rules
883- stage: build
884- needs: []
885- variables:
886- # Android NDK is installed only in the amd64 CI image.
887- KUBERNETES_NODE_SELECTOR_ARCH: "kubernetes.io/arch=amd64"
888- script:
889- - cmake -G Ninja
890- --toolchain ${CI_PROJECT_DIR}/experimental/ops/toolchains/cross/cross-android-arm64-v8a.cmake
891- -DKLEIDIAI_OPS_ENABLE_BUILD_BENCHMARK=ON
892- -S experimental/ops
893- -B ${CI_JOB_NAME_SLUG}
894- - cmake --build ${CI_JOB_NAME_SLUG} -j${PARALLEL_JOBS} --verbose
895-
896-test-experimental-ops-clang-linux-aarch64:
897- extends:
898- - .test-experimental-ops-native
899- needs:
900- - build-experimental-ops-clang-linux-aarch64
901- variables:
902- EXPERIMENTAL_OPS_BUILD_DIR: build-experimental-ops-clang-linux-aarch64
903-
904-test-experimental-ops-clang-asan-linux-aarch64:
905- extends:
906- - .test-experimental-ops-native
907- needs:
908- - build-experimental-ops-clang-asan-linux-aarch64
909- variables:
910- EXPERIMENTAL_OPS_BUILD_DIR: build-experimental-ops-clang-asan-linux-aarch64
911- EXPERIMENTAL_OPS_ASAN_OPTIONS: halt_on_error=1:print_stacktrace=1
912- EXPERIMENTAL_OPS_SOAK_EXTRA_ARGS: --case_limit 20
913- KUBERNETES_CPU_REQUEST: 8
914- KUBERNETES_CPU_LIMIT: 12
915- PARALLEL_JOBS: 4
916-
917-test-experimental-ops-gcc-linux-aarch64:
918- extends:
919- - .test-experimental-ops-native
920- needs:
921- - build-experimental-ops-gcc-linux-aarch64
922- variables:
923- EXPERIMENTAL_OPS_BUILD_DIR: build-experimental-ops-gcc-linux-aarch64
924- KUBERNETES_CPU_REQUEST: 32
925- KUBERNETES_CPU_LIMIT: 48
926- PARALLEL_JOBS: 32
927-
928-test-experimental-ops-clang-macos:
929- extends:
930- - .test-experimental-ops-native
931- needs:
932- - build-experimental-ops-clang-macos
933- tags:
934- - apple_silicon
935- variables:
936- EXPERIMENTAL_OPS_BUILD_DIR: build-experimental-ops-clang-macos
937-
938-test-experimental-ops-clang-asan-macos:
939- extends:
940- - .test-experimental-ops-native
941- needs:
942- - build-experimental-ops-clang-asan-macos
943- tags:
944- - apple_silicon
945- variables:
946- EXPERIMENTAL_OPS_BUILD_DIR: build-experimental-ops-clang-asan-macos
947- EXPERIMENTAL_OPS_ASAN_OPTIONS: halt_on_error=1:print_stacktrace=1
948- EXPERIMENTAL_OPS_SOAK_EXTRA_ARGS: --case_limit 20
949-
950-# Purpose: Resolve and lock gcovr version for consistent coverage reporting.
951-resolve-gcovr:
952- extends: .stable-rules
953- stage: analyze
954- needs: []
955- variables:
956- PIP_CACHE_DIR: ".cache/pip3"
957- cache:
958- - key: "cache-pip3"
959- paths:
960- - $PIP_CACHE_DIR
961- policy: $CACHE_POLICY
962- script:
963- # Install latest gcovr once, then record the exact version
964- - python3 -m pip install --cache-dir=$PIP_CACHE_DIR --user -U --break-system-packages gcovr
965- - export PATH="$(python3 -m site --user-base)/bin:${PATH}"
966- - GCOVR_VERSION=$(gcovr --version | awk 'NR==1 {print $2; exit}')
967- - echo "GCOVR_VERSION=${GCOVR_VERSION}" | tee gcovr.env
968- artifacts:
969- paths:
970- - gcovr.env
971-
972-# Base template: .gcovr-install
973-# Purpose: Install cached gcovr version from resolve-gcovr job.
974-.gcovr-install:
975- variables:
976- PIP_CACHE_DIR: ".cache/pip3"
977- cache:
978- - key: "cache-pip3"
979- paths:
980- - $PIP_CACHE_DIR
981- policy: $CACHE_POLICY
982- before_script:
983- # Prefer Homebrew python3.13 -> 3.10 on macOS, otherwise keep python3 on PATH
984- - |
985- PYTHON_BIN="python3"
986- if [ "$(uname)" = "Darwin" ]; then
987- export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
988- for ver in 3.13 3.12 3.11 3.10; do
989- if [ -x "/opt/homebrew/bin/python${ver}" ]; then
990- PYTHON_BIN="/opt/homebrew/bin/python${ver}"
991- break
992- fi
993- done
994- fi
995- # Ensure the selected python is present on PATH.
996- if ! command -v "${PYTHON_BIN}" >/dev/null 2>&1; then
997- echo "Missing ${PYTHON_BIN} on PATH" >&2
998- exit 1
999- fi
1000- # Enforce minimum python version required by gcovr tooling.
1001- if ! "$PYTHON_BIN" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)'; then
1002- echo "Python ${PYTHON_BIN} is too old; need >= 3.10" >&2
1003- exit 1
1004- fi
1005- echo "Using python: ${PYTHON_BIN}"
1006- "$PYTHON_BIN" -V
1007-
1008- # Load the locked GCOVR_VERSION from resolve-gcovr
1009- - |
1010- if [ -f gcovr.env ]; then
1011- set -a
1012- . gcovr.env
1013- set +a
1014- echo "Using gcovr ${GCOVR_VERSION} from resolve-gcovr"
1015- else
1016- echo "gcovr.env not found; ensure resolve-gcovr is listed in needs." >&2
1017- exit 1
1018- fi
1019-
1020- # Install pip + gcovr==$GCOVR_VERSION
1021- - |
1022- if "$PYTHON_BIN" -m pip help install 2>&1 | grep -q -- "--break-system-packages"; then
1023- PIP_BREAK_SYSTEM_PACKAGES_FLAG="--break-system-packages"
1024- else
1025- PIP_BREAK_SYSTEM_PACKAGES_FLAG=""
1026- fi
1027- $PYTHON_BIN -m pip install --cache-dir=$PIP_CACHE_DIR --user -U ${PIP_BREAK_SYSTEM_PACKAGES_FLAG} pip
1028- $PYTHON_BIN -m pip install --cache-dir=$PIP_CACHE_DIR --user ${PIP_BREAK_SYSTEM_PACKAGES_FLAG} "gcovr==${GCOVR_VERSION}"
1029- - export PATH="$("$PYTHON_BIN" -m site --user-base)/bin:${PATH}"
1030-
1031- # Sanity check the installed gcovr version
1032- - |
1033- (
1034- set -euo pipefail
1035- INSTALLED_GCOVR_VERSION=$(gcovr --version | awk 'NR==1 {print $2; exit}')
1036- echo "gcovr ${INSTALLED_GCOVR_VERSION}"
1037- if [ "${INSTALLED_GCOVR_VERSION}" != "${GCOVR_VERSION}" ]; then
1038- echo "Expected gcovr ${GCOVR_VERSION} but found ${INSTALLED_GCOVR_VERSION}" >&2
1039- exit 1
1040- fi
1041- )
1042-
1043-# Base template: .coverage-base
1044-# Purpose: Instrumented build & diversified benchmark/test execution producing per-job JSON coverage trace.
1045-.coverage-base:
1046- extends:
1047- - .stable-rules
1048- needs: []
1049- variables:
1050- GCOV_EXECUTABLE: ""
1051- script:
1052- # Configure and build with coverage instrumentation
1053- - cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
1054- -DCMAKE_CXX_FLAGS="-Werror --coverage" -DCMAKE_C_FLAGS="-Werror --coverage" -DCMAKE_BUILD_TYPE=Release
1055- -DKLEIDIAI_BUILD_TESTS=ON -DKLEIDIAI_BUILD_BENCHMARK=ON
1056- ${CMAKE_EXTRA_FLAGS}
1057- -S . -B ${CI_JOB_NAME_SLUG}
1058- - cmake --build ${CI_JOB_NAME_SLUG} -j${PARALLEL_JOBS} --verbose
1059- # Run kleidiai_test to generate coverage report for unit tests
1060- - KLEIDIAI_TEST_CI_QUIET=${KLEIDIAI_TEST_CI_QUIET:-1} ./${CI_JOB_NAME_SLUG}/kleidiai_test --gtest_brief=1 --gtest_random_seed=${GLOBAL_TEST_SEED:-42}
1061- # Run combined benchmark for all subcommands (backwards compatibility, matmul, imatmul, dwconv)
1062- - |
1063- declare -a BENCHMARKS=(
1064- "" "--benchmark_dry_run=true -m 1 -n 30 -k 64"
1065- "matmul" "--benchmark_dry_run=true -m 1 -n 30 -k 64"
1066- "pack_matmul" "--benchmark_dry_run=true -m 1 -n 30 -k 64"
1067- "imatmul" "--benchmark_dry_run=true -m 1 -n 30 -c 4 -l 15"
1068- "dwconv" "--benchmark_dry_run=true --input_height 32 --input_width 32 --channels 64 --padding 1,1,1,1"
1069- )
1070- for ((i=0; i<${#BENCHMARKS[@]}; i+=2)); do
1071- KT="${BENCHMARKS[i]}"
1072- ARGS="${BENCHMARKS[i+1]}"
1073- # Run benchmark
1074- if [ -z "$KT" ]; then
1075- ./${CI_JOB_NAME_SLUG}/kleidiai_benchmark $ARGS > /dev/null 2>&1
1076- ./${CI_JOB_NAME_SLUG}/kleidiai_benchmark --benchmark_list_tests > /dev/null 2>&1
1077- ./${CI_JOB_NAME_SLUG}/kleidiai_benchmark > /dev/null 2>&1 || true
1078- else
1079- ./${CI_JOB_NAME_SLUG}/kleidiai_benchmark $KT $ARGS > /dev/null 2>&1
1080- ./${CI_JOB_NAME_SLUG}/kleidiai_benchmark $KT --benchmark_list_tests > /dev/null 2>&1
1081- ./${CI_JOB_NAME_SLUG}/kleidiai_benchmark $KT > /dev/null 2>&1 || true
1082- fi
1083- done
1084- # Generate gcovr configuration tuned to exclude build dir, unreachable branches, and assertion macros.
1085- - mkdir -p build/coverage
1086- - |
1087- echo -e "
1088- root=${PWD}
1089- exclude=${PWD}/${CI_JOB_NAME_SLUG}
1090- gcov-ignore-parse-errors=suspicious_hits.warn
1091- gcov-executable=$GCOV_EXECUTABLE
1092- exclude-unreachable-branches=yes
1093- exclude-lines-by-pattern=.*KAI_(?:ASSERT|ASSUME|ERROR).*
1094- exclude-branches-by-pattern=.*KAI_(?:ASSERT|ASSUME).*" > build/gcovr.cfg
1095- # Post-process generated coverage report into JSON for later aggregation.
1096- - gcovr --json=build/coverage/${CI_JOB_NAME_SLUG}.json -j ${PARALLEL_JOBS} --config build/gcovr.cfg --merge-mode-functions=merge-use-line-min
1097- artifacts:
1098- expire_in: 1 day
1099- paths:
1100- - build/coverage/${CI_JOB_NAME_SLUG}.json
1101-
1102-# Purpose: Coverage generation using llvm-cov gcov with cached gcovr install.
1103-coverage-linux:
1104- extends:
1105- - .coverage-base
1106- - .gcovr-install
1107- stage: analyze
1108- needs:
1109- - resolve-gcovr
1110- variables:
1111- GCOV_EXECUTABLE: "llvm-cov gcov"
1112-
1113-# Purpose: SVE256 coverage variant (focus on *_sve_* tests) to extend line/function coverage set.
1114-coverage-linux-sve256:
1115- extends:
1116- - coverage-linux
1117- variables:
1118- # Use instance with SVE VL 256
1119- KUBERNETES_NODE_SELECTOR_INSTANCE_GENERATION: "karpenter.k8s.aws/instance-generation=7"
1120- GTEST_FILTER: "*_sve_*"
1121-
1122-# Purpose: Coverage build for SME/SME2 architecture.
1123-coverage-clang:
1124- extends:
1125- - .coverage-base
1126- - .gcovr-install
1127- stage: analyze
1128- needs:
1129- - resolve-gcovr
1130- tags:
1131- - apple_silicon
1132- variables:
1133- GCOV_EXECUTABLE: "xcrun llvm-cov gcov"
1134- CMAKE_EXTRA_FLAGS: "-DKLEIDIAI_INTERNAL_EXTRA_ARCH='+sme'"
1135-
1136-# Purpose: Aggregate all JSON coverage traces into Cobertura & HTML reports for publication.
1137-coverage:
1138- extends:
1139- - .stable-rules
1140- - .gcovr-install
1141- stage: deploy
1142- needs:
1143- - resolve-gcovr
1144- - coverage-linux
1145- - coverage-linux-sve256
1146- - coverage-clang
1147- tags:
1148- - apple_silicon
1149- script:
1150- # Generage Cobertura and HTML reports merging coverage across variants,
1151- # where each variant artifact should be stored in JSON file at build/coverage/
1152- # Merge different reports with merge-lines and separate function coverage with same name.
1153- # It's required to handle different build/OS options properly.
1154- - mkdir -p build/html/coverage
1155- - gcovr --json-add-tracefile "build/coverage/*.json" --print-summary
1156- --cobertura=build/coverage.xml --html-details=build/html/coverage/coverage_report.html
1157- --html-title="KleidiAI Coverage Report" --merge-mode-functions=separate --merge-lines
1158- -j ${PARALLEL_JOBS}
1159- # Publish line coverage metric for pipeline reports
1160- coverage: '/^lines:\s+(\d+.\d)%\s+/'
1161- artifacts:
1162- name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
1163- expire_in: 1 day
1164- reports:
1165- # Publish coverage report for MR visualisation
1166- coverage_report:
1167- coverage_format: cobertura
1168- path: build/coverage.xml
1169- paths:
1170- - build
1171-
1172-# Purpose: Publish coverage HTML via Pages (index auto-redirects to detailed report).
1173-pages:
1174- rules:
1175- - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
1176- timeout: 30m
1177- stage: deploy
1178- tags:
1179- - apple_silicon
1180- needs:
1181- - coverage
1182- script:
1183- # Generate simple redirect page
1184- - |
1185- echo '
1186- <!DOCTYPE html>
1187- <html>
1188- <head>
1189- <meta http-equiv="refresh" content="5; url=coverage/coverage_report.html" />
1190- <title>Redirecting...</title>
1191- </head>
1192- <body>
1193- <p>If you are not redirected soon, <a href="coverage/coverage_report.html">click here</a>.</p>
1194- </body>
1195- </html>' > build/html/index.html
1196- artifacts:
1197- paths:
1198- - build/html
1199- publish: build/html
added .gitlab/ci/experimental-ops.yml +240 −0
@@ -0,0 +1,240 @@
1+# SPDX-FileCopyrightText: Copyright 2026 Arm Limited and/or its affiliates <open-source-office@arm.com>
2+#
3+# SPDX-License-Identifier: Apache-2.0
4+#
5+# Summary:
6+# Build and test experimental/ops across different targets.
7+# Purpose and scope:
8+# - Validate experimental/ops native benchmark builds with Clang and GCC.
9+# - Run GEMM, convolution and depthwise soak test plans against native builds.
10+# - Cover ASan variants with reduced test limits for diagnostic coverage.
11+# - Keep experimental/ops checks change-gated in MRs while preserving default
12+# branch and protected tag coverage when re-enabled.
13+# Main jobs (high-level):
14+# - build-experimental-ops-* : compile experimental/ops benchmark binaries.
15+# - test-experimental-ops-* : execute experimental/ops soak test plans.
16+# Usage notes:
17+# - Temporarily disabled while the experimental/ops CI coverage is reworked.
18+# - Changes to shared root CI config are listed because shared defaults, runner
19+# settings and variables can affect experimental/ops when re-enabled.
20+#
21+
22+# Base template: .experimental-ops-rules
23+# Notice: Temporarily disabled while the experimental/ops CI coverage is reworked.
24+# Purpose: Run experimental/ops checks only when relevant in MRs, and always on default branch/protected tags.
25+.experimental-ops-rules:
26+ timeout: 1h
27+ rules:
28+ - when: never
29+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
30+ changes:
31+ - .gitlab-ci.yml
32+ - .gitlab/ci/experimental-ops.yml
33+ - experimental/ops/**/*
34+ exists:
35+ - experimental/ops/CMakeLists.txt
36+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
37+ exists:
38+ - experimental/ops/CMakeLists.txt
39+ variables:
40+ CACHE_POLICY: pull-push
41+ - if: $CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"
42+ exists:
43+ - experimental/ops/CMakeLists.txt
44+
45+# Base template: .build-experimental-ops-native
46+# Purpose: Build the experimental/ops benchmark executable for native test jobs.
47+.build-experimental-ops-native:
48+ extends:
49+ - .experimental-ops-rules
50+ stage: build
51+ script:
52+ - cmake -G Ninja
53+ --toolchain ${CI_PROJECT_DIR}/${EXPERIMENTAL_OPS_TOOLCHAIN_FILE}
54+ -DCMAKE_C_COMPILER=${EXPERIMENTAL_OPS_C_COMPILER}
55+ -DCMAKE_CXX_COMPILER=${EXPERIMENTAL_OPS_CXX_COMPILER}
56+ -DKLEIDIAI_OPS_ENABLE_BUILD_BENCHMARK=ON
57+ ${EXPERIMENTAL_OPS_CMAKE_EXTRA:-}
58+ -S experimental/ops
59+ -B ${CI_JOB_NAME_SLUG}
60+ - cmake --build ${CI_JOB_NAME_SLUG} -j${PARALLEL_JOBS} --verbose
61+ artifacts:
62+ expire_in: 1 day
63+ paths:
64+ - ${CI_JOB_NAME_SLUG}/benchmark/gemm
65+
66+# Base template: .test-experimental-ops-native
67+# Purpose: Run the native GEMM, convolution, and depthwise test plans.
68+.test-experimental-ops-native:
69+ extends:
70+ - .experimental-ops-rules
71+ stage: test
72+ timeout: 2h
73+ variables:
74+ RUNNER_SCRIPT_TIMEOUT: 2h
75+ script:
76+ - |
77+ if [ -n "${EXPERIMENTAL_OPS_ASAN_OPTIONS:-}" ]; then
78+ export ASAN_OPTIONS="${EXPERIMENTAL_OPS_ASAN_OPTIONS}"
79+ fi
80+ - echo "Running soak tests with ${PARALLEL_JOBS} threads"
81+ - |
82+ set -o pipefail
83+ python3 experimental/ops/scripts/soak-full.py \
84+ --test_plan_file experimental/ops/tests/configs/conv_tests.cfg \
85+ --run_test_plan \
86+ --conv \
87+ --threads ${PARALLEL_JOBS} \
88+ ${EXPERIMENTAL_OPS_SOAK_EXTRA_ARGS:-} \
89+ --binary ${EXPERIMENTAL_OPS_BUILD_DIR}/benchmark/gemm 2>&1 \
90+ | tee conv_tests.log
91+ - |
92+ set -o pipefail
93+ python3 experimental/ops/scripts/soak-full.py \
94+ --test_plan_file experimental/ops/tests/configs/depthwise_tests.cfg \
95+ --run_test_plan \
96+ --conv \
97+ --kernel_filter depthwise \
98+ --threads ${PARALLEL_JOBS} \
99+ ${EXPERIMENTAL_OPS_SOAK_EXTRA_ARGS:-} \
100+ --binary ${EXPERIMENTAL_OPS_BUILD_DIR}/benchmark/gemm 2>&1 \
101+ | tee depthwise_tests.log
102+ - |
103+ set -o pipefail
104+ python3 experimental/ops/scripts/soak-full.py \
105+ --test_plan_file experimental/ops/tests/configs/gemm_tests.cfg \
106+ --run_test_plan \
107+ --threads ${PARALLEL_JOBS} \
108+ ${EXPERIMENTAL_OPS_SOAK_EXTRA_ARGS:-} \
109+ --binary ${EXPERIMENTAL_OPS_BUILD_DIR}/benchmark/gemm 2>&1 \
110+ | tee gemm_tests.log
111+ artifacts:
112+ when: always
113+ expire_in: 7 days
114+ paths:
115+ - conv_tests.log
116+ - depthwise_tests.log
117+ - gemm_tests.log
118+ - soak-*/
119+
120+build-experimental-ops-clang-linux-aarch64:
121+ extends:
122+ - .build-experimental-ops-native
123+ variables:
124+ EXPERIMENTAL_OPS_C_COMPILER: clang
125+ EXPERIMENTAL_OPS_CXX_COMPILER: clang++
126+ EXPERIMENTAL_OPS_TOOLCHAIN_FILE: experimental/ops/toolchains/native/native-linux-aarch64-gnu.cmake
127+
128+build-experimental-ops-clang-asan-linux-aarch64:
129+ extends:
130+ - .build-experimental-ops-native
131+ variables:
132+ EXPERIMENTAL_OPS_C_COMPILER: clang
133+ EXPERIMENTAL_OPS_CXX_COMPILER: clang++
134+ EXPERIMENTAL_OPS_TOOLCHAIN_FILE: experimental/ops/toolchains/native/native-linux-aarch64-gnu.cmake
135+ EXPERIMENTAL_OPS_CMAKE_EXTRA: >-
136+ -DCMAKE_BUILD_TYPE=Debug
137+ -DKLEIDIAI_OPS_CCXX_FLAGS_INIT:STRING=-g;-fsanitize=address;-fno-omit-frame-pointer;-fno-common
138+ -DKLEIDIAI_OPS_LINKER_FLAGS_INIT:STRING=-fsanitize=address
139+
140+build-experimental-ops-gcc-linux-aarch64:
141+ extends:
142+ - .build-experimental-ops-native
143+ variables:
144+ EXPERIMENTAL_OPS_C_COMPILER: gcc
145+ EXPERIMENTAL_OPS_CXX_COMPILER: g++
146+ EXPERIMENTAL_OPS_TOOLCHAIN_FILE: experimental/ops/toolchains/native/native-linux-aarch64-gnu.cmake
147+
148+build-experimental-ops-clang-macos:
149+ extends:
150+ - .build-experimental-ops-native
151+ tags:
152+ - apple_silicon
153+ variables:
154+ EXPERIMENTAL_OPS_C_COMPILER: clang
155+ EXPERIMENTAL_OPS_CXX_COMPILER: clang++
156+ EXPERIMENTAL_OPS_TOOLCHAIN_FILE: experimental/ops/toolchains/native/native-macos-aarch64-clang.cmake
157+
158+build-experimental-ops-clang-asan-macos:
159+ extends:
160+ - .build-experimental-ops-native
161+ tags:
162+ - apple_silicon
163+ variables:
164+ EXPERIMENTAL_OPS_C_COMPILER: clang
165+ EXPERIMENTAL_OPS_CXX_COMPILER: clang++
166+ EXPERIMENTAL_OPS_TOOLCHAIN_FILE: experimental/ops/toolchains/native/native-macos-aarch64-clang.cmake
167+ EXPERIMENTAL_OPS_CMAKE_EXTRA: >-
168+ -DCMAKE_BUILD_TYPE=Debug
169+ -DKLEIDIAI_OPS_CCXX_FLAGS_INIT:STRING=-g;-fsanitize=address;-fno-omit-frame-pointer;-fno-common
170+ -DKLEIDIAI_OPS_LINKER_FLAGS_INIT:STRING=-fsanitize=address
171+
172+build-experimental-ops-android-arm64-v8a:
173+ extends:
174+ - .experimental-ops-rules
175+ stage: build
176+ needs: []
177+ variables:
178+ # Android NDK is installed only in the amd64 CI image.
179+ KUBERNETES_NODE_SELECTOR_ARCH: "kubernetes.io/arch=amd64"
180+ script:
181+ - cmake -G Ninja
182+ --toolchain ${CI_PROJECT_DIR}/experimental/ops/toolchains/cross/cross-android-arm64-v8a.cmake
183+ -DKLEIDIAI_OPS_ENABLE_BUILD_BENCHMARK=ON
184+ -S experimental/ops
185+ -B ${CI_JOB_NAME_SLUG}
186+ - cmake --build ${CI_JOB_NAME_SLUG} -j${PARALLEL_JOBS} --verbose
187+
188+test-experimental-ops-clang-linux-aarch64:
189+ extends:
190+ - .test-experimental-ops-native
191+ needs:
192+ - build-experimental-ops-clang-linux-aarch64
193+ variables:
194+ EXPERIMENTAL_OPS_BUILD_DIR: build-experimental-ops-clang-linux-aarch64
195+
196+test-experimental-ops-clang-asan-linux-aarch64:
197+ extends:
198+ - .test-experimental-ops-native
199+ needs:
200+ - build-experimental-ops-clang-asan-linux-aarch64
201+ variables:
202+ EXPERIMENTAL_OPS_BUILD_DIR: build-experimental-ops-clang-asan-linux-aarch64
203+ EXPERIMENTAL_OPS_ASAN_OPTIONS: halt_on_error=1:print_stacktrace=1
204+ EXPERIMENTAL_OPS_SOAK_EXTRA_ARGS: --case_limit 20
205+ KUBERNETES_CPU_REQUEST: 8
206+ KUBERNETES_CPU_LIMIT: 12
207+ PARALLEL_JOBS: 4
208+
209+test-experimental-ops-gcc-linux-aarch64:
210+ extends:
211+ - .test-experimental-ops-native
212+ needs:
213+ - build-experimental-ops-gcc-linux-aarch64
214+ variables:
215+ EXPERIMENTAL_OPS_BUILD_DIR: build-experimental-ops-gcc-linux-aarch64
216+ KUBERNETES_CPU_REQUEST: 32
217+ KUBERNETES_CPU_LIMIT: 48
218+ PARALLEL_JOBS: 32
219+
220+test-experimental-ops-clang-macos:
221+ extends:
222+ - .test-experimental-ops-native
223+ needs:
224+ - build-experimental-ops-clang-macos
225+ tags:
226+ - apple_silicon
227+ variables:
228+ EXPERIMENTAL_OPS_BUILD_DIR: build-experimental-ops-clang-macos
229+
230+test-experimental-ops-clang-asan-macos:
231+ extends:
232+ - .test-experimental-ops-native
233+ needs:
234+ - build-experimental-ops-clang-asan-macos
235+ tags:
236+ - apple_silicon
237+ variables:
238+ EXPERIMENTAL_OPS_BUILD_DIR: build-experimental-ops-clang-asan-macos
239+ EXPERIMENTAL_OPS_ASAN_OPTIONS: halt_on_error=1:print_stacktrace=1
240+ EXPERIMENTAL_OPS_SOAK_EXTRA_ARGS: --case_limit 20
added .gitlab/ci/kleidiai.yml +891 −0
@@ -0,0 +1,891 @@
1+#
2+# SPDX-FileCopyrightText: Copyright 2024-2026 Arm Limited and/or its affiliates <open-source-office@arm.com>
3+#
4+# SPDX-License-Identifier: Apache-2.0
5+#
6+# Summary:
7+# Run builds using different compilers, runs unit & example tests, performs static analysis,
8+# gathers multi-variant coverage and publishes HTML/JUnit/Cobertura reports.
9+# Purpose and scope:
10+# - Provide public-facing CI validating portability and feature coverage of the library.
11+# - Ensure all warnings are treated as errors across compilers.
12+# - Model negative/positive feature scenarios (illegal instruction paths, SME variants).
13+# - Collect code coverage across distinct environments & feature sets.
14+# - Offer reproducible pre-commit formatting / lint checks.
15+# Main jobs (high-level):
16+# - build-* : compile library/tests/examples with different toolchains.
17+# - test-* : execute unit tests (sharded), examples, FVP feature model tests, clang-tidy.
18+# - coverage-* : produce per-variant JSON coverage traces.
19+# - coverage : aggregate traces into Cobertura + HTML.
20+# - pages : publish coverage reports via Pages.
21+# Usage notes:
22+# - FVP jobs simulate CPU feature sets; failures (Illegal instruction) are expected in negative tests.
23+# - CI caching policy switches to pull-push on default branch to warm shared caches.
24+#
25+
26+# Base template: .standard-rules
27+# Purpose: Common rules & timeout setting
28+.standard-rules:
29+ timeout: 30m
30+ rules:
31+ # Run a job for merge requests
32+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
33+ # Run a job for default (main) branch
34+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
35+ variables:
36+ CACHE_POLICY: pull-push
37+ # Run a job for protected tags (release and rc ones)
38+ - if: $CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"
39+
40+# Base template: .stable-rules
41+# Purpose: Run top-level project checks only when core project files change in MRs,
42+# and always on default branch/protected tags.
43+.stable-rules:
44+ timeout: 30m
45+ rules:
46+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
47+ changes: &stable_changes
48+ - .gitlab/ci/kleidiai.yml
49+ - "*"
50+ - ".*"
51+ - benchmark/**/*
52+ - cmake/**/*
53+ - docker/**/*
54+ - docs/**/*
55+ - examples/**/*
56+ - kai/**/*
57+ - LICENSES/**/*
58+ - test/**/*
59+ - third_party/**/*
60+ - tools/**/*
61+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
62+ variables:
63+ CACHE_POLICY: pull-push
64+ - if: $CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"
65+
66+# Base template: .main-branch-verification-rules
67+# Purpose: Common opt-out rules for jobs validating main branch state
68+.main-branch-verification-rules:
69+ rules: &main_branch_verification_rules
70+ - if: >
71+ $DISABLE_MAIN_BRANCH_VERIFICATION_JOBS != "true" &&
72+ $CI_PIPELINE_SOURCE == 'merge_request_event' &&
73+ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != 'main'
74+ when: never
75+ - if: >
76+ $DISABLE_MAIN_BRANCH_VERIFICATION_JOBS != "true" &&
77+ $CI_PIPELINE_SOURCE == 'merge_request_event' &&
78+ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'main'
79+ changes: *stable_changes
80+ - if: >
81+ $DISABLE_MAIN_BRANCH_VERIFICATION_JOBS != "true" &&
82+ $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
83+ variables:
84+ CACHE_POLICY: pull-push
85+ - if: >
86+ $DISABLE_MAIN_BRANCH_VERIFICATION_JOBS != "true" &&
87+ $CI_COMMIT_TAG &&
88+ $CI_COMMIT_REF_PROTECTED == "true"
89+
90+# Purpose: Build library tests.
91+build-clang:
92+ extends:
93+ - .stable-rules
94+ stage: build
95+ script:
96+ # Enforce strict warning-as-error policy
97+ - cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror" -DCMAKE_BUILD_TYPE=Release -DKLEIDIAI_BUILD_TESTS=ON -DKLEIDIAI_BUILD_BENCHMARK=ON -S . -B ${CI_JOB_NAME_SLUG}
98+ # Parallel build capped to reserved CPUs.
99+ - cmake --build ${CI_JOB_NAME_SLUG} -j${PARALLEL_JOBS} --verbose
100+ artifacts:
101+ expire_in: 1 day
102+ paths:
103+ - ${CI_JOB_NAME_SLUG}/kleidiai_test
104+ - ${CI_JOB_NAME_SLUG}/kleidiai_benchmark
105+
106+# Purpose: Build library tests.
107+build-gcc:
108+ extends:
109+ - .stable-rules
110+ stage: build
111+ script:
112+ # Enforce strict warning-as-error policy
113+ - cmake -G Ninja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror" -DCMAKE_BUILD_TYPE=Release -DKLEIDIAI_BUILD_TESTS=ON -DKLEIDIAI_BUILD_BENCHMARK=ON -S . -B ${CI_JOB_NAME_SLUG}
114+ # Parallel build capped to reserved CPUs with verbose
115+ - cmake --build ${CI_JOB_NAME_SLUG} -j${PARALLEL_JOBS} --verbose
116+ artifacts:
117+ expire_in: 1 day
118+ paths:
119+ - ${CI_JOB_NAME_SLUG}/kleidiai_test
120+ - ${CI_JOB_NAME_SLUG}/kleidiai_benchmark
121+
122+# Purpose: Build library tests.
123+build-gcc-bazel:
124+ extends:
125+ - .stable-rules
126+ stage: build
127+ variables:
128+ # Cache Bazelisk files in local folder
129+ BAZELISK_HOME: '.cache/bazelisk'
130+ cache:
131+ - key: cache-bazelisk
132+ paths:
133+ - $BAZELISK_HOME
134+ policy: $CACHE_POLICY
135+ script:
136+ # Ensure deterministic build state.
137+ - bazelisk clean
138+ # Enforce strict warning-as-error policy, cap parallel build and continues to gather full failure set
139+ - bazelisk build -c opt --copt="-Werror" --cxxopt="-Werror" --jobs=${PARALLEL_JOBS} -k --subcommands --verbose_failures --curses=no //...
140+ # Copy build artifacts to separate folder
141+ - mkdir -p ${CI_JOB_NAME_SLUG} && cp bazel-bin/test/kleidiai_test ${CI_JOB_NAME_SLUG}/
142+ artifacts:
143+ expire_in: 1 day
144+ paths:
145+ - ${CI_JOB_NAME_SLUG}/kleidiai_test
146+
147+# Purpose: Build library tests
148+build-clang-bazel:
149+ extends:
150+ - .stable-rules
151+ stage: build
152+ variables:
153+ # Cache Bazelisk files in local folder
154+ BAZELISK_HOME: '.cache/bazelisk'
155+ cache:
156+ - key: cache-bazelisk
157+ paths:
158+ - $BAZELISK_HOME
159+ policy: $CACHE_POLICY
160+ script:
161+ # Ensure deterministic build state.
162+ - bazelisk clean
163+ # Enforce strict warning-as-error policy, cap parallel build and continues to gather full failure set.
164+ # Also disable explicit layering_check feature supported by the compiler
165+ - CC=clang bazelisk build -c opt --copt="-Werror" --cxxopt="-Werror" --jobs=${PARALLEL_JOBS} -k --subcommands --verbose_failures --compiler=clang --features=no-layering_check --curses=no //...
166+ # Copy build artifacts to separate folder
167+ - mkdir -p ${CI_JOB_NAME_SLUG} && cp bazel-bin/test/kleidiai_test ${CI_JOB_NAME_SLUG}/
168+ artifacts:
169+ expire_in: 1 day
170+ paths:
171+ - ${CI_JOB_NAME_SLUG}/kleidiai_test
172+
173+# Purpose: Build examples
174+build-examples:
175+ stage: build
176+ extends:
177+ - .stable-rules
178+ script:
179+ - mkdir -p build
180+ - |
181+ for EXAMPLE in `ls examples -1`; do
182+ # Validate that each example has a build script
183+ if [ -f examples/${EXAMPLE}/CMakeLists.txt ]; then
184+ echo "-----------------------------------------------------------"
185+ echo "Build examples/${EXAMPLE}"
186+ echo "-----------------------------------------------------------"
187+ mkdir -p build_${EXAMPLE}
188+ cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror" -DCMAKE_BUILD_TYPE=Release -S examples/$EXAMPLE -B build_${EXAMPLE}
189+ cmake --build build_${EXAMPLE} -j${PARALLEL_JOBS} --verbose
190+ # Store in top level build/ folder, assuming output binary name is same as folder
191+ cp build_${EXAMPLE}/${EXAMPLE} build/
192+ else
193+ # Guard against missing build config.
194+ echo "No build file found for ${EXAMPLE}"
195+ exit 1
196+ fi
197+ done
198+ artifacts:
199+ expire_in: 1 day
200+ paths:
201+ - build
202+
203+# Purpose: Run non-SME examples; skip SME variants (handled in dedicated job) and log output.
204+test-examples:
205+ stage: test
206+ extends:
207+ - .stable-rules
208+ needs:
209+ - build-examples
210+ script:
211+ - |
212+ for EXAMPLE in `ls build -1`; do
213+ # Skip SME examples (run separately).
214+ [[ $EXAMPLE == *sme* ]] && continue
215+ echo "-----------------------------------------------------------"
216+ echo "Run ${EXAMPLE}"
217+ echo "-----------------------------------------------------------"
218+ # Run and preserve separate log
219+ build/${EXAMPLE} | tee -a example_${EXAMPLE}.log
220+ done
221+ artifacts:
222+ expire_in: 1 day
223+ paths:
224+ - "example_*.log"
225+
226+# Purpose: clang-tidy static analysis of library C/C++ sources.
227+test-clang-tidy:
228+ extends:
229+ - .stable-rules
230+ stage: test
231+ needs: []
232+ script:
233+ # Build and generate compilation_database.json for proper flags propagation to post processing tools
234+ - cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror" -DCMAKE_BUILD_TYPE=Release -DKLEIDIAI_BUILD_TESTS=ON -DKLEIDIAI_BUILD_BENCHMARK=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -B build/${CI_JOB_NAME_SLUG}
235+ # Only test the main library with C/C++ files.
236+ - clang-tidy --header-filter ".*" --warnings-as-errors "*" -p build/${CI_JOB_NAME_SLUG} $(find kai -type f \( -name \*.c -o -name \*.cpp \))
237+
238+# Purpose: Verify that all micro-kernels are registered for benchmarking.
239+test-verify-benchmark-registration:
240+ extends:
241+ - .stable-rules
242+ stage: test
243+ needs: []
244+ rules: *main_branch_verification_rules
245+ script:
246+ - python3 tools/check_benchmark_microkernels.py
247+
248+# Purpose: Verify that all micro-kernels are documented in docs/microkernel_tables.md.
249+test-verify-microkernel-tables:
250+ extends:
251+ - .stable-rules
252+ stage: test
253+ needs: []
254+ rules: *main_branch_verification_rules
255+ script:
256+ - python3 tools/check_microkernel_tables.py
257+
258+# Purpose: Verify that all micro-kernels have correct names.
259+test-verify-microkernel-names:
260+ extends:
261+ - .stable-rules
262+ stage: test
263+ needs: []
264+ rules: *main_branch_verification_rules
265+ script:
266+ - python3 tools/check_microkernel_names.py
267+ - python3 tools/check_microkernel_names.py --generate-documentation docs/microkernel_names.md
268+ - |
269+ if [ -n "$(git status --porcelain -- docs/microkernel_names.md)" ]; then
270+ echo "docs/microkernel_names.md is out of date."
271+ echo "Run:"
272+ echo " python3 tools/check_microkernel_names.py --generate-documentation docs/microkernel_names.md"
273+ echo "and commit the result whenever tools/naming/rules.py is updated."
274+ git diff -- docs/microkernel_names.md
275+ exit 1
276+ fi
277+
278+# Purpose: Verify that all micro-kernel headers contain include directives for used symbols.
279+test-verify-microkernel-header-includes:
280+ extends:
281+ - .stable-rules
282+ stage: test
283+ needs: []
284+ rules: *main_branch_verification_rules
285+ script:
286+ - python3 tools/check_microkernel_header_includes.py
287+
288+# Purpose: Build current sources against tests/benchmarks from latest semver tag to detect API breakage.
289+test-api-compat:
290+ extends:
291+ - .stable-rules
292+ stage: test
293+ needs: []
294+ rules: *main_branch_verification_rules
295+ script:
296+ - ./tools/check_api_compat.py
297+
298+# Purpose: Run pre-commit hooks (formatting, linting) with cached tool downloads.
299+pre-commit-hooks:
300+ variables:
301+ PRE_COMMIT_HOME: '.cache/pre-commit'
302+ extends:
303+ - .standard-rules
304+ stage: build
305+ # Cache downloaded pre-commit checkers
306+ cache:
307+ - key: cache-pre-commit
308+ paths:
309+ - $PRE_COMMIT_HOME
310+ policy: $CACHE_POLICY
311+ script:
312+ - PRE_COMMIT_HOME=$PRE_COMMIT_HOME pre-commit run --all-files
313+
314+# Purpose: Validate MR metadata used as the squash/merge commit message.
315+test-verify-squash-commit-message:
316+ stage: test
317+ needs: []
318+ rules:
319+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
320+ script:
321+ - python3 tools/check_squash_commit_message.py
322+
323+# Purpose: Manual gate job to record external pipeline status.
324+test-remote:
325+ # Part of the pipeline is executed in a separate system.
326+ #
327+ # When the remote pipeline has been completed, this job is triggered automatically
328+ # with the information about the remote pipeline including whether it's passed or failed.
329+ rules:
330+ # Run the job only for a public pipeline
331+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_SERVER_HOST == 'gitlab.arm.com'
332+ # Longer timeout than rest of jobs to account for external system load
333+ timeout: 1h
334+ stage: test
335+ needs: []
336+ when: manual
337+ allow_failure: false
338+ variables:
339+ REMOTE_PIPELINE_ID: 0
340+ REMOTE_PIPELINE_PASSED: ""
341+ REMOTE_PIPELINE_MESSAGE: ""
342+ script:
343+ - echo "REMOTE_PIPELINE_ID=${REMOTE_PIPELINE_ID}" |& tee remote_result.txt
344+ - echo "REMOTE_PIPELINE_PASSED=${REMOTE_PIPELINE_PASSED}" |& tee -a remote_result.txt
345+ - echo "REMOTE_PIPELINE_MESSAGE=${REMOTE_PIPELINE_MESSAGE}" |& tee -a remote_result.txt
346+ - echo "${REMOTE_PIPELINE_PASSED}" | grep -q "true"
347+ artifacts:
348+ when: always
349+ expire_in: 1 day
350+ paths:
351+ - remote_result.txt
352+
353+# Script anchor: run-unit-tests
354+# Purpose: Sharded GoogleTest execution producing multiple XML reports to be below CI limits.
355+# Input variables:
356+# * UT_VARIANT_NAME - base name used to find path to unit test binaries and generate report name
357+# * UT_PARALLEL - number of separate executions, default 4 since 100MB / 30MB = 3.(3) and rounded up
358+# * UT_BINARY_PATH - path to folder with unit test binaries, default is ./build-${UT_VARIANT_NAME}/
359+# * UT_REPORT_PATH - prefix to unit test report file path, default is ./kleidiai_results-${UT_VARIANT_NAME}
360+# * UT_EXTRA_ARGS - extra arguments for test binary, default is none
361+.run-unit-tests: &run-unit-tests
362+ - echo "Run unit test from ${UT_BINARY_PATH:-./build-${UT_VARIANT_NAME}}"
363+ - export GTEST_TOTAL_SHARDS=${UT_PARALLEL:-4}
364+ - |
365+ : "${KAI_TEST_BUFFER_POLICY:?KAI_TEST_BUFFER_POLICY must be set}"
366+ echo "KAI_TEST_BUFFER_POLICY=${KAI_TEST_BUFFER_POLICY}"
367+ export ASAN_OPTIONS="${ASAN_OPTIONS:+${ASAN_OPTIONS}:}halt_on_error=1:print_stacktrace=1"
368+ export UBSAN_OPTIONS="${UBSAN_OPTIONS:+${UBSAN_OPTIONS}:}halt_on_error=1:print_stacktrace=1"
369+ printf 'section_start:%s:test_environment[collapsed=true]\r\e[0KTest environment\n' "$(date +%s)"
370+ echo "uname=$(uname -a)"
371+ echo "cc=$(command -v cc || true)"
372+ cc --version | head -5 || true
373+ echo "cxx=$(command -v c++ || true)"
374+ c++ --version | head -5 || true
375+ echo "ASAN_OPTIONS=${ASAN_OPTIONS:-}"
376+ echo "UBSAN_OPTIONS=${UBSAN_OPTIONS:-}"
377+ printf 'section_end:%s:test_environment\r\e[0K\n' "$(date +%s)"
378+ {
379+ echo "job=${CI_JOB_NAME:-}"
380+ echo "job_slug=${CI_JOB_NAME_SLUG:-}"
381+ echo "commit=${CI_COMMIT_SHA:-}"
382+ echo "seed=${GLOBAL_TEST_SEED:-42}"
383+ echo "total_shards=${GTEST_TOTAL_SHARDS}"
384+ echo "binary_path=${UT_BINARY_PATH:-./build-${UT_VARIANT_NAME}}/kleidiai_test"
385+ echo "buffer_policy=${KAI_TEST_BUFFER_POLICY}"
386+ echo "extra_args=${UT_EXTRA_ARGS:-}"
387+ echo "quiet=${KLEIDIAI_TEST_CI_QUIET:-1}"
388+ }
389+ - |
390+ for GTEST_SHARD_INDEX in `seq 0 $((GTEST_TOTAL_SHARDS - 1))` ; do
391+ # Export index variable to child process
392+ export GTEST_SHARD_INDEX
393+ TEST_STDOUT_FILENAME="${UT_REPORT_PATH:-kleidiai_results-${UT_VARIANT_NAME}}${GTEST_SHARD_INDEX}.log"
394+ echo "Running iteration $GTEST_SHARD_INDEX of $GTEST_TOTAL_SHARDS"
395+ set +e
396+ KLEIDIAI_TEST_CI_QUIET=${KLEIDIAI_TEST_CI_QUIET:-1} ${UT_BINARY_PATH:-./build-${UT_VARIANT_NAME}}/kleidiai_test --gtest_brief=1 --gtest_output=xml:${UT_REPORT_PATH:-kleidiai_results-${UT_VARIANT_NAME}}${GTEST_SHARD_INDEX}.xml --gtest_random_seed=${GLOBAL_TEST_SEED:-42} ${UT_EXTRA_ARGS:-} > "${TEST_STDOUT_FILENAME}" 2>&1
397+ TEST_EXIT_CODE=$?
398+ set -e
399+ grep -E '^\[==========\]|^\[ PASSED \]|^\[ FAILED \]|^\[ SKIPPED \]|^Test seed|^[[:space:]]+[0-9]+ - ' "${TEST_STDOUT_FILENAME}" || true
400+ if [ "${TEST_EXIT_CODE}" -ne 0 ]; then
401+ if [ -f tools/ci/summarise_gtest.py ]; then
402+ python3 tools/ci/summarise_gtest.py "${UT_REPORT_PATH:-kleidiai_results-${UT_VARIANT_NAME}}${GTEST_SHARD_INDEX}.xml" || true
403+ else
404+ echo "JUnit summary unavailable: tools/ci/summarise_gtest.py not found"
405+ fi
406+ echo "Test shard failed; last 200 output lines from ${TEST_STDOUT_FILENAME}:"
407+ tail -200 "${TEST_STDOUT_FILENAME}" || true
408+ exit "${TEST_EXIT_CODE}"
409+ fi
410+ done
411+
412+# Purpose: Sharded unit tests for each build provider.
413+test-linux-aarch64:
414+ extends:
415+ - .stable-rules
416+ stage: test
417+ parallel:
418+ matrix:
419+ # All current build jobs
420+ - BUILD_JOB_PROVIDER: [ clang, gcc, clang-bazel, gcc-bazel ]
421+ needs:
422+ # A CI system limitation does not allow usage of matrix variables to avoid fetching unnecessary artifacts.
423+ # So make sure to fetch artifacts from all jobs required.
424+ - build-gcc
425+ - build-gcc-bazel
426+ - build-clang
427+ - build-clang-bazel
428+ script:
429+ # Explicitly configure overflow protection for public unit tests.
430+ # The shared unit-test runner requires this variable to be set.
431+ - |
432+ export KAI_TEST_BUFFER_POLICY=PROTECT_OVERFLOW
433+ UT_VARIANT_NAME=$BUILD_JOB_PROVIDER
434+ UT_REPORT_PATH=kleidiai_test_results-${BUILD_JOB_PROVIDER}
435+ # Export UT_REPORT_PATH to CI env to use in artifacts
436+ echo "UT_REPORT_PATH=$UT_REPORT_PATH" >> $GITLAB_ENV
437+ - *run-unit-tests
438+ artifacts:
439+ when: always
440+ expire_in: 1 day
441+ paths:
442+ - ${UT_REPORT_PATH}*.xml
443+ - ${UT_REPORT_PATH}*.log
444+ reports:
445+ junit: ${UT_REPORT_PATH}*.xml
446+
447+# Purpose: Specialization of test-linux-aarch64 to run only SVE 256-bit VL unit test subset
448+test-linux-aarch64-sve256:
449+ extends:
450+ - test-linux-aarch64
451+ variables:
452+ # Generation 7 is the instance with SVE VL 256
453+ KUBERNETES_NODE_SELECTOR_INSTANCE_GENERATION: "karpenter.k8s.aws/instance-generation=7"
454+ # Run only SVE unit tests
455+ GTEST_FILTER: "*_sve_*"
456+
457+# Base template: .test-linux-aarch64-fvp
458+# Purpose: Common FVP unit-test runner for feature-specific tests.
459+.test-linux-aarch64-fvp:
460+ extends:
461+ - .stable-rules
462+ stage: test
463+ parallel:
464+ matrix:
465+ - BUILD_JOB_PROVIDER: [ clang, gcc, clang-bazel, gcc-bazel ]
466+ needs:
467+ - build-gcc
468+ - build-gcc-bazel
469+ - build-clang
470+ - build-clang-bazel
471+ variables:
472+ # Long test requires more stable node
473+ KUBERNETES_NODE_SELECTOR_TYPE: "karpenter.sh/capacity-type=on-demand"
474+ FVP_TEST_EXECUTABLE: "./build-${BUILD_JOB_PROVIDER}/kleidiai_test --gtest_brief=1 --gtest_output=xml:kleidiai_test_results-${BUILD_JOB_PROVIDER}.xml --gtest_random_seed=${GLOBAL_TEST_SEED:-42}"
475+ script:
476+ - ./tools/fvp.sh ${FVP_TEST_EXECUTABLE}
477+ artifacts:
478+ when: always
479+ expire_in: 1 day
480+ paths:
481+ - kleidiai_test_results-${BUILD_JOB_PROVIDER}.xml
482+ reports:
483+ junit: kleidiai_test_results-${BUILD_JOB_PROVIDER}.xml
484+
485+# Purpose: FVP feature tests with disabled SVE/SVE2 but enabled SME/SME2
486+# Disabled at the moment due to huge amount of SME/SME2 kernels
487+.test-linux-aarch64-fvp-nosve:
488+ extends:
489+ - .test-linux-aarch64-fvp
490+ variables:
491+ # Disable SVE/SVE2, but keep SME/SME2
492+ FVP_MODEL_EXTRA: "-C cluster0.sve.has_sve2=0 -C cluster0.sve.sme_only=1"
493+
494+# Purpose: FVP SVE2.1 unit tests.
495+test-linux-aarch64-sve2p1-fvp:
496+ extends:
497+ - .test-linux-aarch64-fvp
498+ timeout: 1h
499+ variables:
500+ # Enable SVE2.1 support explicitly for this feature-specific FVP run.
501+ FVP_MODEL_EXTRA: "-C cluster0.sve.has_sve2=1 -C cluster0.sve.sve2_version=1"
502+ # Run only SVE2.1 unit tests.
503+ GTEST_FILTER: "*sve2p1*"
504+ FVP_TEST_EXECUTABLE: "KLEIDIAI_TEST_CI_QUIET=1 ./build-${BUILD_JOB_PROVIDER}/kleidiai_test --gtest_brief=1 --test_size small --gtest_output=xml:kleidiai_test_results-${BUILD_JOB_PROVIDER}.xml --gtest_random_seed=${GLOBAL_TEST_SEED:-42}"
505+ script:
506+ - ./tools/fvp.sh -- "${FVP_TEST_EXECUTABLE}" | tee output.txt
507+ - "grep -qE 'Features\\s+:.*sve2p1' output.txt"
508+ artifacts:
509+ when: always
510+ expire_in: 1 day
511+ paths:
512+ - kleidiai_test_results-${BUILD_JOB_PROVIDER}.xml
513+ - output.txt
514+ reports:
515+ junit: kleidiai_test_results-${BUILD_JOB_PROVIDER}.xml
516+
517+# Purpose: FVP v8-only model; expect Illegal instruction for examples; validates CPU feature detection path.
518+test-linux-aarch64-v8only-fvp:
519+ extends:
520+ - .stable-rules
521+ stage: test
522+ needs:
523+ - build-clang
524+ - build-examples
525+ script:
526+ # Make sure to match disabled V8 and V9 version to enabled in tools/fvp.sh, otherwise the test would fail
527+ - >
528+ export FVP_MODEL_EXTRA="
529+ -C cluster0.has_arm_v8-1=0
530+ -C cluster0.has_arm_v8-2=0
531+ -C cluster0.has_arm_v8-3=0
532+ -C cluster0.has_arm_v8-4=0
533+ -C cluster0.has_arm_v8-5=0
534+ -C cluster0.has_arm_v8-6=0
535+ -C cluster0.has_arm_v8-7=0
536+ -C cluster0.has_arm_v8-8=0
537+ -C cluster0.has_arm_v8-9=0
538+ -C cluster0.has_arm_v9-0=0
539+ -C cluster0.has_arm_v9-1=0
540+ -C cluster0.has_arm_v9-2=0
541+ -C cluster0.has_arm_v9-3=0
542+ -C cluster0.has_arm_v9-4=0
543+ -C cluster0.has_arm_v9-5=0
544+ -C cluster0.has_arm_v9-6=0
545+ -C cluster0.has_sve=0"
546+ # Generate test script with negative and positive tests
547+ - |
548+ echo -e "#\!/bin/bash -ex" > run_tests.sh
549+ echo "echo Perform a negative test with illegal instructions" >> run_tests.sh
550+ find build -type f -perm -a=x -print0 | \
551+ while read -d '' EXAMPLE; do
552+ echo -e "echo \"Run '${EXAMPLE}'\"" >> run_tests.sh
553+ echo -e "./'${EXAMPLE}' || true" >> run_tests.sh # Allow failure (expected crash).
554+ done
555+ echo "echo Perform a positive test with CPU feature detection" >> run_tests.sh
556+ echo "KLEIDIAI_TEST_CI_QUIET=1 ./build-clang/kleidiai_test --gtest_brief=1 --gtest_random_seed=\${GLOBAL_TEST_SEED:-42} || exit 1" >> run_tests.sh # Must succeed.
557+ # Dump content for debugging purposes
558+ - |
559+ echo "Test script content:"
560+ cat run_tests.sh
561+ # Execute test script in FVP and capture output for feature assertions
562+ - chmod a+x run_tests.sh
563+ - ./tools/fvp.sh ./run_tests.sh | tee output.txt
564+ # Verify that no extra features enabled and CPU variant is v8.0
565+ - "grep -qE 'Features\\s+: fp asimd evtstrm cpuid' output.txt"
566+ - "grep -qE 'CPU variant\\s+: 0' output.txt"
567+ # Verify that all examples crashed with Illegal instruction (negative path coverage)
568+ - test $(grep -cE "Illegal instruction\s+./'build/" output.txt) -eq $(ls -1 build | wc -l | tr -d ' ')
569+
570+# Purpose: FVP with only SME enabled (SME2 disabled); SME example runs.
571+test-linux-aarch64-sme1only-fvp:
572+ extends:
573+ - .stable-rules
574+ timeout: 1h
575+ stage: test
576+ needs:
577+ - build-clang
578+ - build-examples
579+ script:
580+ # Disable SME2 in FVP
581+ - >
582+ export FVP_MODEL_EXTRA="
583+ -C cluster0.sve.has_sme2=0
584+ -C cluster0.sve.sme2_version=0" # Disable SME2.
585+ # Generate test script
586+ - |
587+ echo -e "#\!/bin/bash -ex" > run_tests.sh
588+ echo "echo Run SME examples" >> run_tests.sh
589+ # Find any SME examples and execute them
590+ find build -type f -perm -a=x \( -name \*_sme -o -name \*_sme_\* \) -print0 | \
591+ while read -d '' EXAMPLE; do
592+ echo -e "echo \"Run '${EXAMPLE}'\"" >> run_tests.sh
593+ echo -e "./'${EXAMPLE}' || exit 1" >> run_tests.sh
594+ done
595+ # Dump content for debugging purposes
596+ - |
597+ echo "Test script content:"
598+ cat run_tests.sh
599+ - chmod a+x run_tests.sh
600+ # Execute test script in FVP and capture output for feature assertions
601+ - FVP_TEST_EXECUTABLE="./run_tests.sh"
602+ - ./tools/fvp.sh ${FVP_TEST_EXECUTABLE} | tee output.txt
603+ # Verify that SME2 is not available
604+ - "grep -qv 'sme2' output.txt"
605+ artifacts:
606+ when: always
607+ expire_in: 1 day
608+ paths:
609+ - output.txt
610+
611+# Purpose: Execute all SME examples under FVP; consolidate output into single log.
612+test-examples-sme-fvp:
613+ extends:
614+ - .stable-rules
615+ stage: test
616+ needs:
617+ - build-examples
618+ script:
619+ # Generate test script with negative and positive tests
620+ - |
621+ echo -e "#\!/bin/bash -ex" > run_tests.sh
622+ find build -type f -perm -a=x -name \*_sme\* -print0 | \
623+ while read -d '' EXAMPLE; do
624+ echo "echo ---------------------------------------------------" >> run_tests.sh
625+ echo "echo Run '${EXAMPLE}'" >> run_tests.sh
626+ echo "echo ---------------------------------------------------" >> run_tests.sh
627+ echo "./'${EXAMPLE}' | tee -a example.log" >> run_tests.sh
628+ done
629+ # Dump content for debugging purposes
630+ - |
631+ echo "Test script content:"
632+ cat run_tests.sh
633+ # Execute test script in FVP and capture output for feature assertions
634+ - chmod a+x run_tests.sh
635+ - ./tools/fvp.sh ./run_tests.sh
636+ artifacts:
637+ when: always
638+ expire_in: 1 day
639+ paths:
640+ - example.log
641+
642+# Purpose: Resolve and lock gcovr version for consistent coverage reporting.
643+resolve-gcovr:
644+ extends: .stable-rules
645+ stage: analyze
646+ needs: []
647+ variables:
648+ PIP_CACHE_DIR: ".cache/pip3"
649+ cache:
650+ - key: "cache-pip3"
651+ paths:
652+ - $PIP_CACHE_DIR
653+ policy: $CACHE_POLICY
654+ script:
655+ # Install latest gcovr once, then record the exact version
656+ - python3 -m pip install --cache-dir=$PIP_CACHE_DIR --user -U --break-system-packages gcovr
657+ - export PATH="$(python3 -m site --user-base)/bin:${PATH}"
658+ - GCOVR_VERSION=$(gcovr --version | awk 'NR==1 {print $2; exit}')
659+ - echo "GCOVR_VERSION=${GCOVR_VERSION}" | tee gcovr.env
660+ artifacts:
661+ paths:
662+ - gcovr.env
663+
664+# Base template: .gcovr-install
665+# Purpose: Install cached gcovr version from resolve-gcovr job.
666+.gcovr-install:
667+ variables:
668+ PIP_CACHE_DIR: ".cache/pip3"
669+ cache:
670+ - key: "cache-pip3"
671+ paths:
672+ - $PIP_CACHE_DIR
673+ policy: $CACHE_POLICY
674+ before_script:
675+ # Prefer Homebrew python3.13 -> 3.10 on macOS, otherwise keep python3 on PATH
676+ - |
677+ PYTHON_BIN="python3"
678+ if [ "$(uname)" = "Darwin" ]; then
679+ export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
680+ for ver in 3.13 3.12 3.11 3.10; do
681+ if [ -x "/opt/homebrew/bin/python${ver}" ]; then
682+ PYTHON_BIN="/opt/homebrew/bin/python${ver}"
683+ break
684+ fi
685+ done
686+ fi
687+ # Ensure the selected python is present on PATH.
688+ if ! command -v "${PYTHON_BIN}" >/dev/null 2>&1; then
689+ echo "Missing ${PYTHON_BIN} on PATH" >&2
690+ exit 1
691+ fi
692+ # Enforce minimum python version required by gcovr tooling.
693+ if ! "$PYTHON_BIN" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)'; then
694+ echo "Python ${PYTHON_BIN} is too old; need >= 3.10" >&2
695+ exit 1
696+ fi
697+ echo "Using python: ${PYTHON_BIN}"
698+ "$PYTHON_BIN" -V
699+
700+ # Load the locked GCOVR_VERSION from resolve-gcovr
701+ - |
702+ if [ -f gcovr.env ]; then
703+ set -a
704+ . gcovr.env
705+ set +a
706+ echo "Using gcovr ${GCOVR_VERSION} from resolve-gcovr"
707+ else
708+ echo "gcovr.env not found; ensure resolve-gcovr is listed in needs." >&2
709+ exit 1
710+ fi
711+
712+ # Install pip + gcovr==$GCOVR_VERSION
713+ - |
714+ if "$PYTHON_BIN" -m pip help install 2>&1 | grep -q -- "--break-system-packages"; then
715+ PIP_BREAK_SYSTEM_PACKAGES_FLAG="--break-system-packages"
716+ else
717+ PIP_BREAK_SYSTEM_PACKAGES_FLAG=""
718+ fi
719+ $PYTHON_BIN -m pip install --cache-dir=$PIP_CACHE_DIR --user -U ${PIP_BREAK_SYSTEM_PACKAGES_FLAG} pip
720+ $PYTHON_BIN -m pip install --cache-dir=$PIP_CACHE_DIR --user ${PIP_BREAK_SYSTEM_PACKAGES_FLAG} "gcovr==${GCOVR_VERSION}"
721+ - export PATH="$("$PYTHON_BIN" -m site --user-base)/bin:${PATH}"
722+
723+ # Sanity check the installed gcovr version
724+ - |
725+ (
726+ set -euo pipefail
727+ INSTALLED_GCOVR_VERSION=$(gcovr --version | awk 'NR==1 {print $2; exit}')
728+ echo "gcovr ${INSTALLED_GCOVR_VERSION}"
729+ if [ "${INSTALLED_GCOVR_VERSION}" != "${GCOVR_VERSION}" ]; then
730+ echo "Expected gcovr ${GCOVR_VERSION} but found ${INSTALLED_GCOVR_VERSION}" >&2
731+ exit 1
732+ fi
733+ )
734+
735+# Base template: .coverage-base
736+# Purpose: Instrumented build & diversified benchmark/test execution producing per-job JSON coverage trace.
737+.coverage-base:
738+ extends:
739+ - .stable-rules
740+ needs: []
741+ variables:
742+ GCOV_EXECUTABLE: ""
743+ script:
744+ # Configure and build with coverage instrumentation
745+ - cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
746+ -DCMAKE_CXX_FLAGS="-Werror --coverage" -DCMAKE_C_FLAGS="-Werror --coverage" -DCMAKE_BUILD_TYPE=Release
747+ -DKLEIDIAI_BUILD_TESTS=ON -DKLEIDIAI_BUILD_BENCHMARK=ON
748+ ${CMAKE_EXTRA_FLAGS}
749+ -S . -B ${CI_JOB_NAME_SLUG}
750+ - cmake --build ${CI_JOB_NAME_SLUG} -j${PARALLEL_JOBS} --verbose
751+ # Run kleidiai_test to generate coverage report for unit tests
752+ - KLEIDIAI_TEST_CI_QUIET=${KLEIDIAI_TEST_CI_QUIET:-1} ./${CI_JOB_NAME_SLUG}/kleidiai_test --gtest_brief=1 --gtest_random_seed=${GLOBAL_TEST_SEED:-42}
753+ # Run combined benchmark for all subcommands (backwards compatibility, matmul, imatmul, dwconv)
754+ - |
755+ declare -a BENCHMARKS=(
756+ "" "--benchmark_dry_run=true -m 1 -n 30 -k 64"
757+ "matmul" "--benchmark_dry_run=true -m 1 -n 30 -k 64"
758+ "pack_matmul" "--benchmark_dry_run=true -m 1 -n 30 -k 64"
759+ "imatmul" "--benchmark_dry_run=true -m 1 -n 30 -c 4 -l 15"
760+ "dwconv" "--benchmark_dry_run=true --input_height 32 --input_width 32 --channels 64 --padding 1,1,1,1"
761+ )
762+ for ((i=0; i<${#BENCHMARKS[@]}; i+=2)); do
763+ KT="${BENCHMARKS[i]}"
764+ ARGS="${BENCHMARKS[i+1]}"
765+ # Run benchmark
766+ if [ -z "$KT" ]; then
767+ ./${CI_JOB_NAME_SLUG}/kleidiai_benchmark $ARGS > /dev/null 2>&1
768+ ./${CI_JOB_NAME_SLUG}/kleidiai_benchmark --benchmark_list_tests > /dev/null 2>&1
769+ ./${CI_JOB_NAME_SLUG}/kleidiai_benchmark > /dev/null 2>&1 || true
770+ else
771+ ./${CI_JOB_NAME_SLUG}/kleidiai_benchmark $KT $ARGS > /dev/null 2>&1
772+ ./${CI_JOB_NAME_SLUG}/kleidiai_benchmark $KT --benchmark_list_tests > /dev/null 2>&1
773+ ./${CI_JOB_NAME_SLUG}/kleidiai_benchmark $KT > /dev/null 2>&1 || true
774+ fi
775+ done
776+ # Generate gcovr configuration tuned to exclude build dir, unreachable branches, and assertion macros.
777+ - mkdir -p build/coverage
778+ - |
779+ echo -e "
780+ root=${PWD}
781+ exclude=${PWD}/${CI_JOB_NAME_SLUG}
782+ gcov-ignore-parse-errors=suspicious_hits.warn
783+ gcov-executable=$GCOV_EXECUTABLE
784+ exclude-unreachable-branches=yes
785+ exclude-lines-by-pattern=.*KAI_(?:ASSERT|ASSUME|ERROR).*
786+ exclude-branches-by-pattern=.*KAI_(?:ASSERT|ASSUME).*" > build/gcovr.cfg
787+ # Post-process generated coverage report into JSON for later aggregation.
788+ - gcovr --json=build/coverage/${CI_JOB_NAME_SLUG}.json -j ${PARALLEL_JOBS} --config build/gcovr.cfg --merge-mode-functions=merge-use-line-min
789+ artifacts:
790+ expire_in: 1 day
791+ paths:
792+ - build/coverage/${CI_JOB_NAME_SLUG}.json
793+
794+# Purpose: Coverage generation using llvm-cov gcov with cached gcovr install.
795+coverage-linux:
796+ extends:
797+ - .coverage-base
798+ - .gcovr-install
799+ stage: analyze
800+ needs:
801+ - resolve-gcovr
802+ variables:
803+ GCOV_EXECUTABLE: "llvm-cov gcov"
804+
805+# Purpose: SVE256 coverage variant (focus on *_sve_* tests) to extend line/function coverage set.
806+coverage-linux-sve256:
807+ extends:
808+ - coverage-linux
809+ variables:
810+ # Use instance with SVE VL 256
811+ KUBERNETES_NODE_SELECTOR_INSTANCE_GENERATION: "karpenter.k8s.aws/instance-generation=7"
812+ GTEST_FILTER: "*_sve_*"
813+
814+# Purpose: Coverage build for SME/SME2 architecture.
815+coverage-clang:
816+ extends:
817+ - .coverage-base
818+ - .gcovr-install
819+ stage: analyze
820+ needs:
821+ - resolve-gcovr
822+ tags:
823+ - apple_silicon
824+ variables:
825+ GCOV_EXECUTABLE: "xcrun llvm-cov gcov"
826+ CMAKE_EXTRA_FLAGS: "-DKLEIDIAI_INTERNAL_EXTRA_ARCH='+sme'"
827+
828+# Purpose: Aggregate all JSON coverage traces into Cobertura & HTML reports for publication.
829+coverage:
830+ extends:
831+ - .stable-rules
832+ - .gcovr-install
833+ stage: deploy
834+ needs:
835+ - resolve-gcovr
836+ - coverage-linux
837+ - coverage-linux-sve256
838+ - coverage-clang
839+ tags:
840+ - apple_silicon
841+ script:
842+ # Generage Cobertura and HTML reports merging coverage across variants,
843+ # where each variant artifact should be stored in JSON file at build/coverage/
844+ # Merge different reports with merge-lines and separate function coverage with same name.
845+ # It's required to handle different build/OS options properly.
846+ - mkdir -p build/html/coverage
847+ - gcovr --json-add-tracefile "build/coverage/*.json" --print-summary
848+ --cobertura=build/coverage.xml --html-details=build/html/coverage/coverage_report.html
849+ --html-title="KleidiAI Coverage Report" --merge-mode-functions=separate --merge-lines
850+ -j ${PARALLEL_JOBS}
851+ # Publish line coverage metric for pipeline reports
852+ coverage: '/^lines:\s+(\d+.\d)%\s+/'
853+ artifacts:
854+ name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
855+ expire_in: 1 day
856+ reports:
857+ # Publish coverage report for MR visualisation
858+ coverage_report:
859+ coverage_format: cobertura
860+ path: build/coverage.xml
861+ paths:
862+ - build
863+
864+# Purpose: Publish coverage HTML via Pages (index auto-redirects to detailed report).
865+pages:
866+ rules:
867+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
868+ timeout: 30m
869+ stage: deploy
870+ tags:
871+ - apple_silicon
872+ needs:
873+ - coverage
874+ script:
875+ # Generate simple redirect page
876+ - |
877+ echo '
878+ <!DOCTYPE html>
879+ <html>
880+ <head>
881+ <meta http-equiv="refresh" content="5; url=coverage/coverage_report.html" />
882+ <title>Redirecting...</title>
883+ </head>
884+ <body>
885+ <p>If you are not redirected soon, <a href="coverage/coverage_report.html">click here</a>.</p>
886+ </body>
887+ </html>' > build/html/index.html
888+ artifacts:
889+ paths:
890+ - build/html
891+ publish: build/html
modified .pre-commit-config.yaml +1 −6
@@ -30,12 +30,7 @@
3030 - id: check-yaml
3131 stages: [ pre-commit ]
3232 name: "YAML Syntax"
33- exclude: ^(\.clang-format|\.gitlab-ci\.yml)$
34- - id: check-yaml
35- stages: [ pre-commit ]
36- name: "GitLab CI YAML Syntax"
37- files: ^\.gitlab-ci\.yml$
38- args: [ "--unsafe" ]
33+ exclude: ^\.clang-format$
3934 - id: trailing-whitespace
4035 stages: [ pre-commit ]
4136 exclude: ^LICENSES/