4 Commits

3 changed files with 65 additions and 1 deletions

View File

@@ -0,0 +1,46 @@
diff -Nur opencv-3.4.20/modules/core/include/opencv2/core/vsx_utils.hpp opencv-3.4.20-new/modules/core/include/opencv2/core/vsx_utils.hpp
--- opencv-3.4.20/modules/core/include/opencv2/core/vsx_utils.hpp 2023-06-27 19:29:13.000000000 +0800
+++ opencv-3.4.20-new/modules/core/include/opencv2/core/vsx_utils.hpp 2025-08-07 21:18:01.161909977 +0800
@@ -5,6 +5,13 @@
#ifndef OPENCV_HAL_VSX_UTILS_HPP
#define OPENCV_HAL_VSX_UTILS_HPP
+#if defined(__x86_64__) || defined(__riscv) || defined(__s390x__) || defined(__aarch64__) || defined(__loongarch64) \
+ || defined(__POWER10__) || (defined(__powerpc64__) && defined(__ARCH_PWR10__))
+ #define CV_VSX_HAS_FLOAT64_CONVERT 1
+#else
+ #define CV_VSX_HAS_FLOAT64_CONVERT 0
+#endif
+
#include "opencv2/core/cvdef.h"
#ifndef SKIP_INCLUDES
@@ -257,8 +264,26 @@
VSX_IMPL_1VRG(vec_udword2, vec_dword2, vpopcntd, vec_popcntu)
// converts between single and double-precision
-VSX_REDIRECT_1RG(vec_float4, vec_double2, vec_cvfo, __builtin_vsx_xvcvdpsp)
-VSX_REDIRECT_1RG(vec_double2, vec_float4, vec_cvfo, __builtin_vsx_xvcvspdp)
+#if CV_VSX_HAS_FLOAT64_CONVERT
+// Use VSX double<->float conversion instructions (if supported by the architecture)
+ VSX_REDIRECT_1RG(vec_float4, vec_double2, vec_cvfo, vec_floate)
+ VSX_REDIRECT_1RG(vec_double2, vec_float4, vec_cvfo, vec_doubleo)
+#else
+// Fallback: implement vec_cvfo using scalar operations (to ensure successful linking)
+ static inline vec_float4 vec_cvfo(const vec_double2& a)
+ {
+ float r0 = static_cast<float>(reinterpret_cast<const double*>(&a)[0]);
+ float r1 = static_cast<float>(reinterpret_cast<const double*>(&a)[1]);
+ return (vec_float4){r0, r1, 0.f, 0.f};
+ }
+
+ static inline vec_double2 vec_cvfo(const vec_float4& a)
+ {
+ double r0 = static_cast<double>(reinterpret_cast<const float*>(&a)[0]);
+ double r1 = static_cast<double>(reinterpret_cast<const float*>(&a)[2]);
+ return (vec_double2){r0, r1};
+ }
+#endif
// converts word and doubleword to double-precision
#undef vec_ctd

View File

@@ -1,3 +1,15 @@
-------------------------------------------------------------------
Wed Aug 6 12:09:57 UTC 2025 - Hillwood Yang <hillwood@opensuse.org>
- Add opencv-ppc64le-power9.patch, fix missing vec_cvfo on POWER9 due to
unavailable VSX float64 conversion
-------------------------------------------------------------------
Wed May 7 10:02:57 UTC 2025 - Simon Lees <sflees@suse.de>
- export CMAKE_POLICY_VERSION_MINIMUM="3.5" to ignore cmakes
minimum version warnings
-------------------------------------------------------------------
Tue Mar 11 12:29:00 UTC 2025 - Atri Bhattacharya <badshah400@gmail.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package opencv3
#
# Copyright (c) 2025 SUSE LLC
# Copyright (c) 2025 SUSE LLC and contributors
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -49,6 +49,9 @@ Source1: https://github.com/opencv/opencv_contrib/archive/%{version}.tar.
Patch1: opencv-build-compare.patch
# PATCH-FIX-UPSTREAM
Patch2: https://github.com/opencv/opencv/commit/00ca8f455e6a5588d905e3a0b268f18ee3fda5dd.patch#/opencv3-drop-numpy-distutils.patch
# PATCH-FIX-UPSTREAM opencv-ppc64le-power9.patch hillwood@opensuse.org - Fix missing vec_cvfo on POWER9 due to unavailable VSX float64 conversion
# https://github.com/opencv/opencv/pull/27633
Patch3: opencv-ppc64le-power9.patch
BuildRequires: cmake
BuildRequires: fdupes
BuildRequires: libeigen3-devel
@@ -180,6 +183,9 @@ cp opencv_contrib-%{version}/LICENSE LICENSE.contrib
rm -f doc/packaging.txt
%build
# Remove cmake4 error due to not setting
# min cmake version - sflees.de
export CMAKE_POLICY_VERSION_MINIMUM=3.5
# Dynamic dispatch: https://github.com/opencv/opencv/wiki/CPU-optimizations-build-options
# x86: disable SSE on 32bit, do not dispatch AVX and later - SSE3
# is the highest extension available on any non-64bit x86 CPU