public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/onednn] f45: Fix ppc64le examples build: avoid AltiVec bool clash
@ 2026-11-24 22:56 
  0 siblings, 0 replies; only message in thread
From:  @ 2026-11-24 22:56 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/onednn
            Branch : f45
            Commit : e70c42a61e2fa6af2ff2031536b69ceb57234074
            Author : Miguel Martín <mmartinv@redhat.com>
            Date   : 2026-10-27T13:01:32+01:00
            Stats  : +92/-0 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/onednn/c/e70c42a61e2fa6af2ff2031536b69ceb57234074?branch=f45

            Log:
            Fix ppc64le examples build: avoid AltiVec bool clash

On ppc64 with AltiVec enabled, the bundled OpenCL headers
(dnnl_ocl.h -> CL/cl_platform.h) include <altivec.h>, which aliases bool
to the AltiVec keyword __vector __bool int. examples/example_utils.h
includes <stdbool.h> first, so altivec.h wins and the scalar flags in
read_from_dnnl_memory() and write_to_dnnl_memory() fail to compile,
breaking the examples build with the OpenCL GPU runtime.

Add 0001-examples-work-around-AltiVec-bool-clash-from-OpenCL-.patch,
which switches those three flags to _Bool, which altivec.h does not
alias, and drops the then-unused <stdbool.h>.

This is a workaround for the unnecessary <altivec.h> include in the
OpenCL headers; drop it once OpenCL-Headers#321 lands and
third_party/opencl is updated.

https://github.com/uxlfoundation/oneDNN/issues/6312
https://github.com/KhronosGroup/OpenCL-Headers/issues/320

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---
diff --git a/0001-examples-work-around-AltiVec-bool-clash-from-OpenCL-.patch b/0001-examples-work-around-AltiVec-bool-clash-from-OpenCL-.patch
new file mode 100644
index 0000000..a9c638c
--- /dev/null
+++ b/0001-examples-work-around-AltiVec-bool-clash-from-OpenCL-.patch
@@ -0,0 +1,85 @@
+From 0a1028a095dfe1641cc9a64f9de699add4bd6859 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Miguel=20Mart=C3=ADn?= <mmartinv@redhat.com>
+Date: Wed, 21 Oct 2026 16:49:24 +0200
+Subject: [PATCH] examples: work around AltiVec bool clash from OpenCL headers
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+On ppc64 with AltiVec enabled (__VEC__, implied by -mcpu=power8 and
+later), CL/cl_platform.h includes <altivec.h>, which aliases the short
+AltiVec spellings:
+
+    #define vector __vector
+    #define pixel  __pixel
+    #define bool   __bool
+
+example_utils.h includes <stdbool.h> first and "dnnl_ocl.h" afterwards,
+so altivec.h wins and `bool` becomes `__vector __bool int`. Building the
+examples on Fedora ppc64le with the OpenCL GPU runtime fails with:
+
+    example_utils.h:111:15: error: incompatible types when initializing
+    type '__vector __bool int' using type 'int'
+    example_utils.h:113:30: error: invalid operands to binary ||
+    (have 'int' and '__vector __bool int')
+
+altivec.h does not alias _Bool, so use that for the three scalar flags
+and drop the now-unused <stdbool.h>. C is affected in every dialect;
+C++ is not, because altivec.h skips the aliases for C++ in strict ANSI
+mode.
+
+This is a workaround. The root cause is the unnecessary <altivec.h>
+include in the bundled OpenCL headers, reported upstream as
+KhronosGroup/OpenCL-Headers#320 with a fix proposed in #321. Revert it
+once that lands and third_party/opencl is updated.
+
+Signed-off-by: Miguel Martín <mmartinv@redhat.com>
+Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
+---
+ examples/example_utils.h | 14 ++++++++++----
+ 1 file changed, 10 insertions(+), 4 deletions(-)
+
+diff --git a/examples/example_utils.h b/examples/example_utils.h
+index 1d3e615b3b..8c3bf0337b 100644
+--- a/examples/example_utils.h
++++ b/examples/example_utils.h
+@@ -18,7 +18,6 @@
+ #define EXAMPLE_UTILS_H
+ 
+ #include <assert.h>
+-#include <stdbool.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+@@ -107,7 +106,13 @@ static inline void read_from_dnnl_memory(void *handle, dnnl_memory_t mem) {
+     CHECK(dnnl_memory_get_memory_desc(mem, &md));
+     size_t bytes = dnnl_memory_desc_get_size(md);
+ 
+-    bool is_cpu_sycl
++    // Use _Bool rather than bool: on ppc64 the OpenCL headers pull in
++    // <altivec.h> (dnnl_ocl.h -> CL/cl_platform.h), which aliases bool to the
++    // AltiVec keyword __vector __bool int and breaks scalar use. _Bool is not
++    // aliased. Workaround for
++    // https://github.com/KhronosGroup/OpenCL-Headers/issues/320, remove once
++    // that is fixed upstream and third_party/opencl is updated.
++    _Bool is_cpu_sycl
+             = (DNNL_CPU_RUNTIME == DNNL_RUNTIME_SYCL && eng_kind == dnnl_cpu);
+ 
+     if (eng_kind == dnnl_gpu || is_cpu_sycl) {
+@@ -146,9 +151,10 @@ static inline void write_to_dnnl_memory(void *handle, dnnl_memory_t mem) {
+     size_t bytes = dnnl_memory_desc_get_size(md);
+ 
+ #ifdef DNNL_WITH_SYCL
+-    bool is_cpu_sycl
++    // _Bool rather than bool, see read_from_dnnl_memory() above.
++    _Bool is_cpu_sycl
+             = (DNNL_CPU_RUNTIME == DNNL_RUNTIME_SYCL && eng_kind == dnnl_cpu);
+-    bool is_gpu_sycl
++    _Bool is_gpu_sycl
+             = (DNNL_GPU_RUNTIME == DNNL_RUNTIME_SYCL && eng_kind == dnnl_gpu);
+     if (is_cpu_sycl || is_gpu_sycl) {
+         void *mapped_ptr = NULL;
+-- 
+Miguel Martín
+mmartinv@redhat.com
+

diff --git a/onednn.spec b/onednn.spec
index 5179f5e..9b7d587 100644
--- a/onednn.spec
+++ b/onednn.spec
@@ -20,6 +20,13 @@ URL:               https://github.com/uxlfoundation/oneDNN
 Source0:        %{url}/archive/v%{version}/onednn-%{version}.tar.gz
 Source1:        onednn-test.in
 
+# Workaround for an AltiVec bool clash from the bundled OpenCL headers that
+# breaks the examples build on ppc64le. Drop once OpenCL-Headers#321 lands and
+# third_party/opencl is updated.
+# https://github.com/uxlfoundation/oneDNN/issues/6312
+# https://github.com/KhronosGroup/OpenCL-Headers/issues/320
+Patch0:         0001-examples-work-around-AltiVec-bool-clash-from-OpenCL-.patch
+
 # This package only work in 64bit arches for now
 ExclusiveArch:  x86_64 aarch64 ppc64le s390x
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-24 22:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 22:56 [rpms/onednn] f45: Fix ppc64le examples build: avoid AltiVec bool clash 

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox