public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/onednn] rawhide: Build and package benchdnn and the tests
@ 2026-09-23 20:12 Adam Jackson
0 siblings, 0 replies; only message in thread
From: Adam Jackson @ 2026-09-23 20:12 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/onednn
Branch : rawhide
Commit : bb6a42cef4950a14549d374eb485ea9ea06d12ad
Author : Adam Jackson <ajax@redhat.com>
Date : 2026-09-23T16:11:39-04:00
Stats : +244/-0 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/onednn/c/bb6a42cef4950a14549d374eb485ea9ea06d12ad?branch=rawhide
Log:
Build and package benchdnn and the tests
---
diff --git a/onednn-test.in b/onednn-test.in
new file mode 100644
index 0000000..d7f8eb7
--- /dev/null
+++ b/onednn-test.in
@@ -0,0 +1,182 @@
+#!/bin/bash
+# SPDX-License-Identifier: Apache-2.0
+# onednn test runner - runs gtests and optionally benchdnn smoke tests
+
+set -euo pipefail
+
+GTESTS_DIR=@LIBEXECDIR@/onednn/gtests
+BENCHDNN=@LIBEXECDIR@/onednn/benchdnn
+INPUTS_DIR=@LIBEXECDIR@/onednn/inputs
+
+usage() {
+ cat << USAGE
+usage: onednn-test [OPTIONS]
+
+run onednn validation tests
+
+OPTIONS:
+ --test=TESTS which gtests to run (default: all)
+ 'all' = all tests, '' = none, or comma-separated list
+ --benchdnn=DRIVERS which benchdnn drivers to run (default: none)
+ comma-separated list: matmul,conv,eltwise,...
+ --engine=ENGINE test engine: cpu (default) or gpu
+ --filter=PATTERN only run tests matching pattern
+ --list list available tests
+ -h, --help show this help
+
+EXAMPLES:
+ onednn-test # all gtests on cpu
+ onednn-test --engine=gpu # all gtests on gpu
+ onednn-test --benchdnn=matmul,conv,eltwise # gtests + benchdnn
+ onednn-test --test='' --benchdnn=matmul # benchdnn only
+ onednn-test --filter='*matmul*' # matmul-related gtests
+USAGE
+}
+
+ENGINE="cpu"
+TEST_LIST="all"
+BENCHDNN_LIST=""
+FILTER="*"
+LIST_ONLY=0
+
+while [[ $# -gt 0 ]]; do
+ case $1 in
+ --test=*)
+ TEST_LIST="${1#*=}"
+ shift
+ ;;
+ --benchdnn=*)
+ BENCHDNN_LIST="${1#*=}"
+ shift
+ ;;
+ --engine=*)
+ ENGINE="${1#*=}"
+ shift
+ ;;
+ --filter=*)
+ FILTER="${1#*=}"
+ shift
+ ;;
+ --list)
+ LIST_ONLY=1
+ shift
+ ;;
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ *)
+ echo "unknown option: $1"
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+if [[ $LIST_ONLY -eq 1 ]]; then
+ echo "gtests:"
+ ls -1 "$GTESTS_DIR" | grep -v "\.so"
+ if [[ -x "$BENCHDNN" ]]; then
+ echo ""
+ echo "benchdnn drivers:"
+ ls -1 "$INPUTS_DIR"
+ fi
+ exit 0
+fi
+
+export DNNL_DEFAULT_FPMATH_MODE=strict
+
+passed=0
+failed=0
+skipped=0
+
+# run gtests if requested
+if [[ -n "$TEST_LIST" ]]; then
+ echo "running onednn gtests (engine=$ENGINE)..."
+ echo ""
+
+ for test in "$GTESTS_DIR"/*; do
+ [[ -x "$test" ]] || continue
+ testname=$(basename "$test")
+
+ # check against --test= list
+ if [[ "$TEST_LIST" != "all" ]]; then
+ match=0
+ IFS=',' read -ra TESTS <<< "$TEST_LIST"
+ for pattern in "${TESTS[@]}"; do
+ if [[ "$testname" == $pattern ]]; then
+ match=1
+ break
+ fi
+ done
+ [[ $match -eq 0 ]] && continue
+ fi
+
+ # check against --filter
+ case "$testname" in
+ $FILTER)
+ ;;
+ *)
+ continue
+ ;;
+ esac
+
+ # skip buffer tests on cpu
+ if [[ "$ENGINE" == "cpu" && "$testname" == *_buffer ]]; then
+ echo "[ SKIP ] $testname (buffer tests require gpu)"
+ skipped=$((skipped + 1))
+ continue
+ fi
+
+ echo "[ RUN ] $testname"
+ set +e
+ "$test" --gtest_color=no > /dev/null 2>&1
+ result=$?
+ set -e
+ if [[ $result -eq 0 ]]; then
+ echo "[ OK ] $testname"
+ passed=$((passed + 1))
+ else
+ echo "[ FAIL ] $testname"
+ failed=$((failed + 1))
+ fi
+ done
+fi
+
+# run benchdnn if requested
+if [[ -n "$BENCHDNN_LIST" && -x "$BENCHDNN" ]]; then
+ echo ""
+ echo "running benchdnn tests (engine=$ENGINE)..."
+ echo ""
+
+ IFS=',' read -ra DRIVERS <<< "$BENCHDNN_LIST"
+ for driver in "${DRIVERS[@]}"; do
+ smoke_batch="test_${driver}_smoke"
+ if [[ -f "$INPUTS_DIR/$driver/$smoke_batch" ]]; then
+ echo "[ RUN ] benchdnn --$driver --batch=$smoke_batch"
+ set +e
+ "$BENCHDNN" --engine="$ENGINE" --"$driver" --batch="$smoke_batch" --mode=C > /dev/null 2>&1
+ result=$?
+ set -e
+ if [[ $result -eq 0 ]]; then
+ echo "[ OK ] benchdnn $driver smoke"
+ passed=$((passed + 1))
+ else
+ echo "[ FAIL ] benchdnn $driver smoke"
+ failed=$((failed + 1))
+ fi
+ else
+ echo "[ SKIP ] benchdnn $driver (no smoke batch found)"
+ skipped=$((skipped + 1))
+ fi
+ done
+fi
+
+echo ""
+echo "========================================"
+echo "passed: $passed"
+echo "failed: $failed"
+echo "skipped: $skipped"
+echo "========================================"
+
+[[ $failed -eq 0 ]]
diff --git a/onednn.spec b/onednn.spec
index b55ce4c..71d7e41 100644
--- a/onednn.spec
+++ b/onednn.spec
@@ -6,6 +6,7 @@ Summary: The oneAPI Deep Neural Network Library
License: Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSL-1.0 AND MIT
URL: https://github.com/uxlfoundation/oneDNN
Source0: %{url}/archive/v%{version}/onednn-%{version}.tar.gz
+Source1: onednn-test.in
# This package only work in 64bit arches for now
ExclusiveArch: x86_64 aarch64 ppc64le s390x
@@ -14,6 +15,7 @@ BuildRequires: make
BuildRequires: cmake
BuildRequires: doxygen
BuildRequires: gcc-c++
+BuildRequires: chrpath
# Optionals not yet enabled
BuildRequires: pkgconfig(OpenCL)
@@ -46,6 +48,23 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
+%package benchdnn
+Summary: benchdnn benchmark and test tool for %{name}
+Requires: %{name}%{?_isa} = %{version}-%{release}
+
+%description benchdnn
+benchdnn is a standalone correctness and performance benchmark for oneDNN
+primitives. This package allows testing oneDNN functionality on target
+hardware without requiring the full build environment.
+
+%package tests
+Summary: unit tests for %{name}
+Requires: %{name}%{?_isa} = %{version}-%{release}
+
+%description tests
+googletest-based unit tests for oneDNN. useful for validating oneDNN
+functionality on target hardware.
+
%prep
%autosetup -p1 -n oneDNN-%{version}
@@ -55,6 +74,7 @@ developing applications that use %{name}.
%cmake \
-DDNNL_ARCH_OPT_FLAGS="" \
-DDNNL_BUILD_EXAMPLES=OFF \
+ -DDNNL_BUILD_TESTS=ON \
-DCMAKE_C_STD=11 \
-DCMAKE_CPP_STD=17 \
-DONEDNN_GPU_RUNTIME=OCL
@@ -68,6 +88,37 @@ developing applications that use %{name}.
# Remove docs
rm -rf %{buildroot}%{_docdir}/dnnl
+# install benchdnn
+install -d %{buildroot}%{_libexecdir}/onednn
+install -pm0755 %{_vpath_builddir}/tests/benchdnn/benchdnn %{buildroot}%{_libexecdir}/onednn/
+chrpath -d %{buildroot}%{_libexecdir}/onednn/benchdnn
+cp -a %{_vpath_builddir}/tests/benchdnn/inputs %{buildroot}%{_libexecdir}/onednn/
+
+# wrapper script for benchdnn
+install -d %{buildroot}%{_bindir}
+cat > %{buildroot}%{_bindir}/benchdnn << 'EOF'
+#!/bin/sh
+exec %{_libexecdir}/onednn/benchdnn "$@"
+EOF
+chmod 0755 %{buildroot}%{_bindir}/benchdnn
+
+# install gtests
+install -d %{buildroot}%{_libexecdir}/onednn/gtests
+find %{_vpath_builddir}/tests/gtests -maxdepth 1 -type f -executable -name 'test_*' \
+ -exec install -pm0755 {} %{buildroot}%{_libexecdir}/onednn/gtests/ \;
+install -pm0755 %{_vpath_builddir}/tests/api-c %{buildroot}%{_libexecdir}/onednn/gtests/
+[ -f %{_vpath_builddir}/tests/test_c_symbols-c ] && \
+ install -pm0755 %{_vpath_builddir}/tests/test_c_symbols-c %{buildroot}%{_libexecdir}/onednn/gtests/ || true
+
+# strip build-tree RUNPATH from test binaries
+find %{buildroot}%{_libexecdir}/onednn/gtests -type f -executable \
+ -exec chrpath -d {} \; 2>/dev/null || true
+
+# test runner script
+sed -e 's|@LIBEXECDIR@|%{_libexecdir}|g' \
+ %{SOURCE1} > %{buildroot}%{_bindir}/onednn-test
+chmod 0755 %{buildroot}%{_bindir}/onednn-test
+
# Some ocl/gpu tests will fails if lacking an appropriate implementation
%{?_with_tests:
@@ -92,5 +143,16 @@ rm -rf %{buildroot}%{_docdir}/dnnl
%{_libdir}/cmake/dnnl/*.cmake
+%files benchdnn
+%{_bindir}/benchdnn
+%{_libexecdir}/onednn/benchdnn
+%{_libexecdir}/onednn/inputs/
+
+
+%files tests
+%{_bindir}/onednn-test
+%{_libexecdir}/onednn/gtests/
+
+
%changelog
%autochangelog
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-23 20:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-23 20:12 [rpms/onednn] rawhide: Build and package benchdnn and the tests Adam Jackson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox