public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Adam Jackson <ajax@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/onednn] rawhide: Build and package benchdnn and the tests
Date: Wed, 23 Sep 2026 20:12:49 GMT	[thread overview]
Message-ID: <179019436919.1.18262684458391003928.rpms-onednn-bb6a42cef495@fedoraproject.org> (raw)

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

                 reply	other threads:[~2026-09-23 20:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179019436919.1.18262684458391003928.rpms-onednn-bb6a42cef495@fedoraproject.org \
    --to=ajax@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox