diff mbox series

[meta-oe] opencv: fix build for ppc64

Message ID 20250210071226.1880278-1-yi.zhao@windriver.com
State Accepted
Headers show
Series [meta-oe] opencv: fix build for ppc64 | expand

Commit Message

Yi Zhao Feb. 10, 2025, 7:12 a.m. UTC
Backport a patch to fix build for ppc64:
modules/core/include/opencv2/core/hal/intrin_vsx.hpp:265:75: error: expected primary-expression before 'v'
  265 | template <> inline _Tpvec v_setall_(_Tp v) { return v_setall_##suffix(_Tp v); }       \
      |

Also fix QA issue:
ERROR: QA Issue: File /usr/src/debug/opencv/4.11.0/modules/core/arithm.vsx3.cpp in package opencv-src contains reference to TMPDIR [buildpaths]
ERROR: QA Issue: File /usr/src/debug/opencv/4.11.0/modules/core/convert.vsx3.cpp in package opencv-src contains reference to TMPDIR [buildpaths]

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
 ...-fixed-VSX-intrinsics-implementation.patch | 61 +++++++++++++++++++
 .../recipes-support/opencv/opencv_4.11.0.bb   |  7 +++
 2 files changed, 68 insertions(+)
 create mode 100644 meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch

Comments

Khem Raj Feb. 10, 2025, 5:19 p.m. UTC | #1
On Sun, Feb 9, 2025 at 11:12 PM Yi Zhao via lists.openembedded.org
<yi.zhao=eng.windriver.com@lists.openembedded.org> wrote:
>
> Backport a patch to fix build for ppc64:
> modules/core/include/opencv2/core/hal/intrin_vsx.hpp:265:75: error: expected primary-expression before 'v'
>   265 | template <> inline _Tpvec v_setall_(_Tp v) { return v_setall_##suffix(_Tp v); }       \
>       |
>
> Also fix QA issue:
> ERROR: QA Issue: File /usr/src/debug/opencv/4.11.0/modules/core/arithm.vsx3.cpp in package opencv-src contains reference to TMPDIR [buildpaths]
> ERROR: QA Issue: File /usr/src/debug/opencv/4.11.0/modules/core/convert.vsx3.cpp in package opencv-src contains reference to TMPDIR [buildpaths]
>
> Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
> ---
>  ...-fixed-VSX-intrinsics-implementation.patch | 61 +++++++++++++++++++
>  .../recipes-support/opencv/opencv_4.11.0.bb   |  7 +++
>  2 files changed, 68 insertions(+)
>  create mode 100644 meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch
>
> diff --git a/meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch b/meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch
> new file mode 100644
> index 0000000000..9fc89e4244
> --- /dev/null
> +++ b/meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch
> @@ -0,0 +1,61 @@
> +From 97f3f390661f2fd1168336820b89eb4383ce8528 Mon Sep 17 00:00:00 2001
> +From: Maksim Shabunin <maksim.shabunin@gmail.com>
> +Date: Fri, 10 Jan 2025 18:34:11 +0300
> +Subject: [PATCH] core: fixed VSX intrinsics implementation
> +
> +Upstream-Status: Backport
> +[https://github.com/opencv/opencv/commit/97f3f390661f2fd1168336820b89eb4383ce8528]
> +
> +Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
> +---
> + modules/core/include/opencv2/core/hal/intrin_vsx.hpp | 10 +++++-----
> + 1 file changed, 5 insertions(+), 5 deletions(-)
> +
> +diff --git a/modules/core/include/opencv2/core/hal/intrin_vsx.hpp b/modules/core/include/opencv2/core/hal/intrin_vsx.hpp
> +index 2157e1e870..0a0915a22f 100644
> +--- a/modules/core/include/opencv2/core/hal/intrin_vsx.hpp
> ++++ b/modules/core/include/opencv2/core/hal/intrin_vsx.hpp
> +@@ -262,7 +262,7 @@ OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_float64x2, double)
> + inline _Tpvec v_setzero_##suffix() { return _Tpvec(vec_splats((_Tp)0)); }             \
> + inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec(vec_splats((_Tp)v));}          \
> + template <> inline _Tpvec v_setzero_() { return v_setzero_##suffix(); }               \
> +-template <> inline _Tpvec v_setall_(_Tp v) { return v_setall_##suffix(_Tp v); }       \
> ++template <> inline _Tpvec v_setall_(_Tp v) { return v_setall_##suffix(v); }       \
> + template<typename _Tpvec0> inline _Tpvec v_reinterpret_as_##suffix(const _Tpvec0 &a)  \
> + { return _Tpvec((cast)a.val); }
> +
> +@@ -650,11 +650,11 @@ OPENCV_HAL_IMPL_VSX_SELECT(v_float64x2, vec_bdword2_c)
> + #define OPENCV_HAL_IMPL_VSX_INT_CMP_OP(_Tpvec)                 \
> + inline _Tpvec v_eq(const _Tpvec& a, const _Tpvec& b)           \
> + { return _Tpvec(vec_cmpeq(a.val, b.val)); }                    \
> +-inline _Tpvec V_ne(const _Tpvec& a, const _Tpvec& b)           \
> ++inline _Tpvec v_ne(const _Tpvec& a, const _Tpvec& b)           \
> + { return _Tpvec(vec_cmpne(a.val, b.val)); }                    \
> + inline _Tpvec v_lt(const _Tpvec& a, const _Tpvec& b)           \
> + { return _Tpvec(vec_cmplt(a.val, b.val)); }                    \
> +-inline _Tpvec V_gt(const _Tpvec& a, const _Tpvec& b)           \
> ++inline _Tpvec v_gt(const _Tpvec& a, const _Tpvec& b)           \
> + { return _Tpvec(vec_cmpgt(a.val, b.val)); }                    \
> + inline _Tpvec v_le(const _Tpvec& a, const _Tpvec& b)           \
> + { return _Tpvec(vec_cmple(a.val, b.val)); }                    \
> +@@ -1507,7 +1507,7 @@ inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, cons
> + inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b)
> + { return v_dotprod(a, b); }
> + inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c)
> +-{ return v_int32x4(vec_msum(a.val, b.val, vec_int4_z)) + c; }
> ++{ return v_add(v_int32x4(vec_msum(a.val, b.val, vec_int4_z)), c); }
> + // 32 >> 64
> + inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b)
> + { return v_dotprod(a, b); }
> +@@ -1518,7 +1518,7 @@ inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_
> + inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b)
> + { return v_dotprod_expand(a, b); }
> + inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c)
> +-{ return v_uint32x4(vec_msum(a.val, b.val, vec_uint4_z)) + c; }
> ++{ return v_add(v_uint32x4(vec_msum(a.val, b.val, vec_uint4_z)), c); }
> +
> + inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b)
> + {
> +--
> +2.25.1
> +
> diff --git a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb
> index 07b3a9d9e6..1613b6a3ed 100644
> --- a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb
> +++ b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb
> @@ -31,6 +31,7 @@ SRC_URI = "git://github.com/opencv/opencv.git;name=opencv;branch=4.x;protocol=ht
>             file://download.patch \
>             file://0001-Make-ts-module-external.patch \
>             file://0008-Do-not-embed-build-directory-in-binaries.patch \
> +           file://0001-core-fixed-VSX-intrinsics-implementation.patch \
>             "
>  SRC_URI:append:riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patchdir=contrib"
>
> @@ -208,4 +209,10 @@ do_install:append() {
>      if [ -f ${D}${bindir}/setup_vars_opencv4.sh ]; then
>          rm -rf ${D}${bindir}/setup_vars_opencv4.sh
>      fi
> +
> +    for fn in arithm.vsx3.cpp convert.vsx3.cpp; do
> +        if [ -f ${B}/modules/core/$fn ]; then
> +            sed -i -e 's,${S},/usr/src/debug/${PN}/${PV},g' ${B}/modules/core/$fn
> +        fi

Do we know why the absolute paths are being emitted ?

>  }
> --
> 2.25.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#115326): https://lists.openembedded.org/g/openembedded-devel/message/115326
> Mute This Topic: https://lists.openembedded.org/mt/111098421/1997914
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Yi Zhao Feb. 12, 2025, 6 a.m. UTC | #2
On 2/11/25 01:19, Khem Raj wrote:
> On Sun, Feb 9, 2025 at 11:12 PM Yi Zhao via lists.openembedded.org
> <yi.zhao=eng.windriver.com@lists.openembedded.org> wrote:
>> Backport a patch to fix build for ppc64:
>> modules/core/include/opencv2/core/hal/intrin_vsx.hpp:265:75: error: expected primary-expression before 'v'
>>    265 | template <> inline _Tpvec v_setall_(_Tp v) { return v_setall_##suffix(_Tp v); }       \
>>        |
>>
>> Also fix QA issue:
>> ERROR: QA Issue: File /usr/src/debug/opencv/4.11.0/modules/core/arithm.vsx3.cpp in package opencv-src contains reference to TMPDIR [buildpaths]
>> ERROR: QA Issue: File /usr/src/debug/opencv/4.11.0/modules/core/convert.vsx3.cpp in package opencv-src contains reference to TMPDIR [buildpaths]
>>
>> Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
>> ---
>>   ...-fixed-VSX-intrinsics-implementation.patch | 61 +++++++++++++++++++
>>   .../recipes-support/opencv/opencv_4.11.0.bb   |  7 +++
>>   2 files changed, 68 insertions(+)
>>   create mode 100644 meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch
>>
>> diff --git a/meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch b/meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch
>> new file mode 100644
>> index 0000000000..9fc89e4244
>> --- /dev/null
>> +++ b/meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch
>> @@ -0,0 +1,61 @@
>> +From 97f3f390661f2fd1168336820b89eb4383ce8528 Mon Sep 17 00:00:00 2001
>> +From: Maksim Shabunin <maksim.shabunin@gmail.com>
>> +Date: Fri, 10 Jan 2025 18:34:11 +0300
>> +Subject: [PATCH] core: fixed VSX intrinsics implementation
>> +
>> +Upstream-Status: Backport
>> +[https://github.com/opencv/opencv/commit/97f3f390661f2fd1168336820b89eb4383ce8528]
>> +
>> +Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
>> +---
>> + modules/core/include/opencv2/core/hal/intrin_vsx.hpp | 10 +++++-----
>> + 1 file changed, 5 insertions(+), 5 deletions(-)
>> +
>> +diff --git a/modules/core/include/opencv2/core/hal/intrin_vsx.hpp b/modules/core/include/opencv2/core/hal/intrin_vsx.hpp
>> +index 2157e1e870..0a0915a22f 100644
>> +--- a/modules/core/include/opencv2/core/hal/intrin_vsx.hpp
>> ++++ b/modules/core/include/opencv2/core/hal/intrin_vsx.hpp
>> +@@ -262,7 +262,7 @@ OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_float64x2, double)
>> + inline _Tpvec v_setzero_##suffix() { return _Tpvec(vec_splats((_Tp)0)); }             \
>> + inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec(vec_splats((_Tp)v));}          \
>> + template <> inline _Tpvec v_setzero_() { return v_setzero_##suffix(); }               \
>> +-template <> inline _Tpvec v_setall_(_Tp v) { return v_setall_##suffix(_Tp v); }       \
>> ++template <> inline _Tpvec v_setall_(_Tp v) { return v_setall_##suffix(v); }       \
>> + template<typename _Tpvec0> inline _Tpvec v_reinterpret_as_##suffix(const _Tpvec0 &a)  \
>> + { return _Tpvec((cast)a.val); }
>> +
>> +@@ -650,11 +650,11 @@ OPENCV_HAL_IMPL_VSX_SELECT(v_float64x2, vec_bdword2_c)
>> + #define OPENCV_HAL_IMPL_VSX_INT_CMP_OP(_Tpvec)                 \
>> + inline _Tpvec v_eq(const _Tpvec& a, const _Tpvec& b)           \
>> + { return _Tpvec(vec_cmpeq(a.val, b.val)); }                    \
>> +-inline _Tpvec V_ne(const _Tpvec& a, const _Tpvec& b)           \
>> ++inline _Tpvec v_ne(const _Tpvec& a, const _Tpvec& b)           \
>> + { return _Tpvec(vec_cmpne(a.val, b.val)); }                    \
>> + inline _Tpvec v_lt(const _Tpvec& a, const _Tpvec& b)           \
>> + { return _Tpvec(vec_cmplt(a.val, b.val)); }                    \
>> +-inline _Tpvec V_gt(const _Tpvec& a, const _Tpvec& b)           \
>> ++inline _Tpvec v_gt(const _Tpvec& a, const _Tpvec& b)           \
>> + { return _Tpvec(vec_cmpgt(a.val, b.val)); }                    \
>> + inline _Tpvec v_le(const _Tpvec& a, const _Tpvec& b)           \
>> + { return _Tpvec(vec_cmple(a.val, b.val)); }                    \
>> +@@ -1507,7 +1507,7 @@ inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, cons
>> + inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b)
>> + { return v_dotprod(a, b); }
>> + inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c)
>> +-{ return v_int32x4(vec_msum(a.val, b.val, vec_int4_z)) + c; }
>> ++{ return v_add(v_int32x4(vec_msum(a.val, b.val, vec_int4_z)), c); }
>> + // 32 >> 64
>> + inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b)
>> + { return v_dotprod(a, b); }
>> +@@ -1518,7 +1518,7 @@ inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_
>> + inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b)
>> + { return v_dotprod_expand(a, b); }
>> + inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c)
>> +-{ return v_uint32x4(vec_msum(a.val, b.val, vec_uint4_z)) + c; }
>> ++{ return v_add(v_uint32x4(vec_msum(a.val, b.val, vec_uint4_z)), c); }
>> +
>> + inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b)
>> + {
>> +--
>> +2.25.1
>> +
>> diff --git a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb
>> index 07b3a9d9e6..1613b6a3ed 100644
>> --- a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb
>> +++ b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb
>> @@ -31,6 +31,7 @@ SRC_URI = "git://github.com/opencv/opencv.git;name=opencv;branch=4.x;protocol=ht
>>              file://download.patch \
>>              file://0001-Make-ts-module-external.patch \
>>              file://0008-Do-not-embed-build-directory-in-binaries.patch \
>> +           file://0001-core-fixed-VSX-intrinsics-implementation.patch \
>>              "
>>   SRC_URI:append:riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patchdir=contrib"
>>
>> @@ -208,4 +209,10 @@ do_install:append() {
>>       if [ -f ${D}${bindir}/setup_vars_opencv4.sh ]; then
>>           rm -rf ${D}${bindir}/setup_vars_opencv4.sh
>>       fi
>> +
>> +    for fn in arithm.vsx3.cpp convert.vsx3.cpp; do
>> +        if [ -f ${B}/modules/core/$fn ]; then
>> +            sed -i -e 's,${S},/usr/src/debug/${PN}/${PV},g' ${B}/modules/core/$fn
>> +        fi
> Do we know why the absolute paths are being emitted ?


arithm.vsx3.cpp and convert.vsx3.cpp are wrapper files generated during 
build to include other header files with absolute paths. This is because 
VSX3 feature is enabled by default on ppc64 cpu.


//Yi

>
>>   }
>> --
>> 2.25.1
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#115326): https://lists.openembedded.org/g/openembedded-devel/message/115326
>> Mute This Topic: https://lists.openembedded.org/mt/111098421/1997914
>> Group Owner: openembedded-devel+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
Khem Raj Feb. 12, 2025, 6:05 a.m. UTC | #3
On Tue, Feb 11, 2025 at 10:00 PM Yi Zhao <yi.zhao@windriver.com> wrote:
>
>
> On 2/11/25 01:19, Khem Raj wrote:
> > On Sun, Feb 9, 2025 at 11:12 PM Yi Zhao via lists.openembedded.org
> > <yi.zhao=eng.windriver.com@lists.openembedded.org> wrote:
> >> Backport a patch to fix build for ppc64:
> >> modules/core/include/opencv2/core/hal/intrin_vsx.hpp:265:75: error: expected primary-expression before 'v'
> >>    265 | template <> inline _Tpvec v_setall_(_Tp v) { return v_setall_##suffix(_Tp v); }       \
> >>        |
> >>
> >> Also fix QA issue:
> >> ERROR: QA Issue: File /usr/src/debug/opencv/4.11.0/modules/core/arithm.vsx3.cpp in package opencv-src contains reference to TMPDIR [buildpaths]
> >> ERROR: QA Issue: File /usr/src/debug/opencv/4.11.0/modules/core/convert.vsx3.cpp in package opencv-src contains reference to TMPDIR [buildpaths]
> >>
> >> Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
> >> ---
> >>   ...-fixed-VSX-intrinsics-implementation.patch | 61 +++++++++++++++++++
> >>   .../recipes-support/opencv/opencv_4.11.0.bb   |  7 +++
> >>   2 files changed, 68 insertions(+)
> >>   create mode 100644 meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch
> >>
> >> diff --git a/meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch b/meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch
> >> new file mode 100644
> >> index 0000000000..9fc89e4244
> >> --- /dev/null
> >> +++ b/meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch
> >> @@ -0,0 +1,61 @@
> >> +From 97f3f390661f2fd1168336820b89eb4383ce8528 Mon Sep 17 00:00:00 2001
> >> +From: Maksim Shabunin <maksim.shabunin@gmail.com>
> >> +Date: Fri, 10 Jan 2025 18:34:11 +0300
> >> +Subject: [PATCH] core: fixed VSX intrinsics implementation
> >> +
> >> +Upstream-Status: Backport
> >> +[https://github.com/opencv/opencv/commit/97f3f390661f2fd1168336820b89eb4383ce8528]
> >> +
> >> +Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
> >> +---
> >> + modules/core/include/opencv2/core/hal/intrin_vsx.hpp | 10 +++++-----
> >> + 1 file changed, 5 insertions(+), 5 deletions(-)
> >> +
> >> +diff --git a/modules/core/include/opencv2/core/hal/intrin_vsx.hpp b/modules/core/include/opencv2/core/hal/intrin_vsx.hpp
> >> +index 2157e1e870..0a0915a22f 100644
> >> +--- a/modules/core/include/opencv2/core/hal/intrin_vsx.hpp
> >> ++++ b/modules/core/include/opencv2/core/hal/intrin_vsx.hpp
> >> +@@ -262,7 +262,7 @@ OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_float64x2, double)
> >> + inline _Tpvec v_setzero_##suffix() { return _Tpvec(vec_splats((_Tp)0)); }             \
> >> + inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec(vec_splats((_Tp)v));}          \
> >> + template <> inline _Tpvec v_setzero_() { return v_setzero_##suffix(); }               \
> >> +-template <> inline _Tpvec v_setall_(_Tp v) { return v_setall_##suffix(_Tp v); }       \
> >> ++template <> inline _Tpvec v_setall_(_Tp v) { return v_setall_##suffix(v); }       \
> >> + template<typename _Tpvec0> inline _Tpvec v_reinterpret_as_##suffix(const _Tpvec0 &a)  \
> >> + { return _Tpvec((cast)a.val); }
> >> +
> >> +@@ -650,11 +650,11 @@ OPENCV_HAL_IMPL_VSX_SELECT(v_float64x2, vec_bdword2_c)
> >> + #define OPENCV_HAL_IMPL_VSX_INT_CMP_OP(_Tpvec)                 \
> >> + inline _Tpvec v_eq(const _Tpvec& a, const _Tpvec& b)           \
> >> + { return _Tpvec(vec_cmpeq(a.val, b.val)); }                    \
> >> +-inline _Tpvec V_ne(const _Tpvec& a, const _Tpvec& b)           \
> >> ++inline _Tpvec v_ne(const _Tpvec& a, const _Tpvec& b)           \
> >> + { return _Tpvec(vec_cmpne(a.val, b.val)); }                    \
> >> + inline _Tpvec v_lt(const _Tpvec& a, const _Tpvec& b)           \
> >> + { return _Tpvec(vec_cmplt(a.val, b.val)); }                    \
> >> +-inline _Tpvec V_gt(const _Tpvec& a, const _Tpvec& b)           \
> >> ++inline _Tpvec v_gt(const _Tpvec& a, const _Tpvec& b)           \
> >> + { return _Tpvec(vec_cmpgt(a.val, b.val)); }                    \
> >> + inline _Tpvec v_le(const _Tpvec& a, const _Tpvec& b)           \
> >> + { return _Tpvec(vec_cmple(a.val, b.val)); }                    \
> >> +@@ -1507,7 +1507,7 @@ inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, cons
> >> + inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b)
> >> + { return v_dotprod(a, b); }
> >> + inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c)
> >> +-{ return v_int32x4(vec_msum(a.val, b.val, vec_int4_z)) + c; }
> >> ++{ return v_add(v_int32x4(vec_msum(a.val, b.val, vec_int4_z)), c); }
> >> + // 32 >> 64
> >> + inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b)
> >> + { return v_dotprod(a, b); }
> >> +@@ -1518,7 +1518,7 @@ inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_
> >> + inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b)
> >> + { return v_dotprod_expand(a, b); }
> >> + inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c)
> >> +-{ return v_uint32x4(vec_msum(a.val, b.val, vec_uint4_z)) + c; }
> >> ++{ return v_add(v_uint32x4(vec_msum(a.val, b.val, vec_uint4_z)), c); }
> >> +
> >> + inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b)
> >> + {
> >> +--
> >> +2.25.1
> >> +
> >> diff --git a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb
> >> index 07b3a9d9e6..1613b6a3ed 100644
> >> --- a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb
> >> +++ b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb
> >> @@ -31,6 +31,7 @@ SRC_URI = "git://github.com/opencv/opencv.git;name=opencv;branch=4.x;protocol=ht
> >>              file://download.patch \
> >>              file://0001-Make-ts-module-external.patch \
> >>              file://0008-Do-not-embed-build-directory-in-binaries.patch \
> >> +           file://0001-core-fixed-VSX-intrinsics-implementation.patch \
> >>              "
> >>   SRC_URI:append:riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patchdir=contrib"
> >>
> >> @@ -208,4 +209,10 @@ do_install:append() {
> >>       if [ -f ${D}${bindir}/setup_vars_opencv4.sh ]; then
> >>           rm -rf ${D}${bindir}/setup_vars_opencv4.sh
> >>       fi
> >> +
> >> +    for fn in arithm.vsx3.cpp convert.vsx3.cpp; do
> >> +        if [ -f ${B}/modules/core/$fn ]; then
> >> +            sed -i -e 's,${S},/usr/src/debug/${PN}/${PV},g' ${B}/modules/core/$fn
> >> +        fi
> > Do we know why the absolute paths are being emitted ?
>
>
> arithm.vsx3.cpp and convert.vsx3.cpp are wrapper files generated during
> build to include other header files with absolute paths. This is because
> VSX3 feature is enabled by default on ppc64 cpu.

OK. Are they generated using flex/lex ? there are options in flex
called --noline to remove them during generation phase
Yi Zhao Feb. 12, 2025, 6:20 a.m. UTC | #4
On 2/12/25 14:05, Khem Raj wrote:
> On Tue, Feb 11, 2025 at 10:00 PM Yi Zhao <yi.zhao@windriver.com> wrote:
>>
>> On 2/11/25 01:19, Khem Raj wrote:
>>> On Sun, Feb 9, 2025 at 11:12 PM Yi Zhao via lists.openembedded.org
>>> <yi.zhao=eng.windriver.com@lists.openembedded.org> wrote:
>>>> Backport a patch to fix build for ppc64:
>>>> modules/core/include/opencv2/core/hal/intrin_vsx.hpp:265:75: error: expected primary-expression before 'v'
>>>>     265 | template <> inline _Tpvec v_setall_(_Tp v) { return v_setall_##suffix(_Tp v); }       \
>>>>         |
>>>>
>>>> Also fix QA issue:
>>>> ERROR: QA Issue: File /usr/src/debug/opencv/4.11.0/modules/core/arithm.vsx3.cpp in package opencv-src contains reference to TMPDIR [buildpaths]
>>>> ERROR: QA Issue: File /usr/src/debug/opencv/4.11.0/modules/core/convert.vsx3.cpp in package opencv-src contains reference to TMPDIR [buildpaths]
>>>>
>>>> Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
>>>> ---
>>>>    ...-fixed-VSX-intrinsics-implementation.patch | 61 +++++++++++++++++++
>>>>    .../recipes-support/opencv/opencv_4.11.0.bb   |  7 +++
>>>>    2 files changed, 68 insertions(+)
>>>>    create mode 100644 meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch
>>>>
>>>> diff --git a/meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch b/meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch
>>>> new file mode 100644
>>>> index 0000000000..9fc89e4244
>>>> --- /dev/null
>>>> +++ b/meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch
>>>> @@ -0,0 +1,61 @@
>>>> +From 97f3f390661f2fd1168336820b89eb4383ce8528 Mon Sep 17 00:00:00 2001
>>>> +From: Maksim Shabunin <maksim.shabunin@gmail.com>
>>>> +Date: Fri, 10 Jan 2025 18:34:11 +0300
>>>> +Subject: [PATCH] core: fixed VSX intrinsics implementation
>>>> +
>>>> +Upstream-Status: Backport
>>>> +[https://github.com/opencv/opencv/commit/97f3f390661f2fd1168336820b89eb4383ce8528]
>>>> +
>>>> +Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
>>>> +---
>>>> + modules/core/include/opencv2/core/hal/intrin_vsx.hpp | 10 +++++-----
>>>> + 1 file changed, 5 insertions(+), 5 deletions(-)
>>>> +
>>>> +diff --git a/modules/core/include/opencv2/core/hal/intrin_vsx.hpp b/modules/core/include/opencv2/core/hal/intrin_vsx.hpp
>>>> +index 2157e1e870..0a0915a22f 100644
>>>> +--- a/modules/core/include/opencv2/core/hal/intrin_vsx.hpp
>>>> ++++ b/modules/core/include/opencv2/core/hal/intrin_vsx.hpp
>>>> +@@ -262,7 +262,7 @@ OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_float64x2, double)
>>>> + inline _Tpvec v_setzero_##suffix() { return _Tpvec(vec_splats((_Tp)0)); }             \
>>>> + inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec(vec_splats((_Tp)v));}          \
>>>> + template <> inline _Tpvec v_setzero_() { return v_setzero_##suffix(); }               \
>>>> +-template <> inline _Tpvec v_setall_(_Tp v) { return v_setall_##suffix(_Tp v); }       \
>>>> ++template <> inline _Tpvec v_setall_(_Tp v) { return v_setall_##suffix(v); }       \
>>>> + template<typename _Tpvec0> inline _Tpvec v_reinterpret_as_##suffix(const _Tpvec0 &a)  \
>>>> + { return _Tpvec((cast)a.val); }
>>>> +
>>>> +@@ -650,11 +650,11 @@ OPENCV_HAL_IMPL_VSX_SELECT(v_float64x2, vec_bdword2_c)
>>>> + #define OPENCV_HAL_IMPL_VSX_INT_CMP_OP(_Tpvec)                 \
>>>> + inline _Tpvec v_eq(const _Tpvec& a, const _Tpvec& b)           \
>>>> + { return _Tpvec(vec_cmpeq(a.val, b.val)); }                    \
>>>> +-inline _Tpvec V_ne(const _Tpvec& a, const _Tpvec& b)           \
>>>> ++inline _Tpvec v_ne(const _Tpvec& a, const _Tpvec& b)           \
>>>> + { return _Tpvec(vec_cmpne(a.val, b.val)); }                    \
>>>> + inline _Tpvec v_lt(const _Tpvec& a, const _Tpvec& b)           \
>>>> + { return _Tpvec(vec_cmplt(a.val, b.val)); }                    \
>>>> +-inline _Tpvec V_gt(const _Tpvec& a, const _Tpvec& b)           \
>>>> ++inline _Tpvec v_gt(const _Tpvec& a, const _Tpvec& b)           \
>>>> + { return _Tpvec(vec_cmpgt(a.val, b.val)); }                    \
>>>> + inline _Tpvec v_le(const _Tpvec& a, const _Tpvec& b)           \
>>>> + { return _Tpvec(vec_cmple(a.val, b.val)); }                    \
>>>> +@@ -1507,7 +1507,7 @@ inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, cons
>>>> + inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b)
>>>> + { return v_dotprod(a, b); }
>>>> + inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c)
>>>> +-{ return v_int32x4(vec_msum(a.val, b.val, vec_int4_z)) + c; }
>>>> ++{ return v_add(v_int32x4(vec_msum(a.val, b.val, vec_int4_z)), c); }
>>>> + // 32 >> 64
>>>> + inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b)
>>>> + { return v_dotprod(a, b); }
>>>> +@@ -1518,7 +1518,7 @@ inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_
>>>> + inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b)
>>>> + { return v_dotprod_expand(a, b); }
>>>> + inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c)
>>>> +-{ return v_uint32x4(vec_msum(a.val, b.val, vec_uint4_z)) + c; }
>>>> ++{ return v_add(v_uint32x4(vec_msum(a.val, b.val, vec_uint4_z)), c); }
>>>> +
>>>> + inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b)
>>>> + {
>>>> +--
>>>> +2.25.1
>>>> +
>>>> diff --git a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb
>>>> index 07b3a9d9e6..1613b6a3ed 100644
>>>> --- a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb
>>>> +++ b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb
>>>> @@ -31,6 +31,7 @@ SRC_URI = "git://github.com/opencv/opencv.git;name=opencv;branch=4.x;protocol=ht
>>>>               file://download.patch \
>>>>               file://0001-Make-ts-module-external.patch \
>>>>               file://0008-Do-not-embed-build-directory-in-binaries.patch \
>>>> +           file://0001-core-fixed-VSX-intrinsics-implementation.patch \
>>>>               "
>>>>    SRC_URI:append:riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patchdir=contrib"
>>>>
>>>> @@ -208,4 +209,10 @@ do_install:append() {
>>>>        if [ -f ${D}${bindir}/setup_vars_opencv4.sh ]; then
>>>>            rm -rf ${D}${bindir}/setup_vars_opencv4.sh
>>>>        fi
>>>> +
>>>> +    for fn in arithm.vsx3.cpp convert.vsx3.cpp; do
>>>> +        if [ -f ${B}/modules/core/$fn ]; then
>>>> +            sed -i -e 's,${S},/usr/src/debug/${PN}/${PV},g' ${B}/modules/core/$fn
>>>> +        fi
>>> Do we know why the absolute paths are being emitted ?
>>
>> arithm.vsx3.cpp and convert.vsx3.cpp are wrapper files generated during
>> build to include other header files with absolute paths. This is because
>> VSX3 feature is enabled by default on ppc64 cpu.
> OK. Are they generated using flex/lex ? there are options in flex
> called --noline to remove them during generation phase

Not flex/lex. It uses a  macro ocv_add_dispatched_file defined in cmake 
file: cmake/OpenCVCompilerOptimizations.cmake


//Yi
diff mbox series

Patch

diff --git a/meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch b/meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch
new file mode 100644
index 0000000000..9fc89e4244
--- /dev/null
+++ b/meta-oe/recipes-support/opencv/opencv/0001-core-fixed-VSX-intrinsics-implementation.patch
@@ -0,0 +1,61 @@ 
+From 97f3f390661f2fd1168336820b89eb4383ce8528 Mon Sep 17 00:00:00 2001
+From: Maksim Shabunin <maksim.shabunin@gmail.com>
+Date: Fri, 10 Jan 2025 18:34:11 +0300
+Subject: [PATCH] core: fixed VSX intrinsics implementation
+
+Upstream-Status: Backport
+[https://github.com/opencv/opencv/commit/97f3f390661f2fd1168336820b89eb4383ce8528]
+
+Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
+---
+ modules/core/include/opencv2/core/hal/intrin_vsx.hpp | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/modules/core/include/opencv2/core/hal/intrin_vsx.hpp b/modules/core/include/opencv2/core/hal/intrin_vsx.hpp
+index 2157e1e870..0a0915a22f 100644
+--- a/modules/core/include/opencv2/core/hal/intrin_vsx.hpp
++++ b/modules/core/include/opencv2/core/hal/intrin_vsx.hpp
+@@ -262,7 +262,7 @@ OPENCV_HAL_IMPL_VSX_EXTRACT_N(v_float64x2, double)
+ inline _Tpvec v_setzero_##suffix() { return _Tpvec(vec_splats((_Tp)0)); }             \
+ inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec(vec_splats((_Tp)v));}          \
+ template <> inline _Tpvec v_setzero_() { return v_setzero_##suffix(); }               \
+-template <> inline _Tpvec v_setall_(_Tp v) { return v_setall_##suffix(_Tp v); }       \
++template <> inline _Tpvec v_setall_(_Tp v) { return v_setall_##suffix(v); }       \
+ template<typename _Tpvec0> inline _Tpvec v_reinterpret_as_##suffix(const _Tpvec0 &a)  \
+ { return _Tpvec((cast)a.val); }
+ 
+@@ -650,11 +650,11 @@ OPENCV_HAL_IMPL_VSX_SELECT(v_float64x2, vec_bdword2_c)
+ #define OPENCV_HAL_IMPL_VSX_INT_CMP_OP(_Tpvec)                 \
+ inline _Tpvec v_eq(const _Tpvec& a, const _Tpvec& b)           \
+ { return _Tpvec(vec_cmpeq(a.val, b.val)); }                    \
+-inline _Tpvec V_ne(const _Tpvec& a, const _Tpvec& b)           \
++inline _Tpvec v_ne(const _Tpvec& a, const _Tpvec& b)           \
+ { return _Tpvec(vec_cmpne(a.val, b.val)); }                    \
+ inline _Tpvec v_lt(const _Tpvec& a, const _Tpvec& b)           \
+ { return _Tpvec(vec_cmplt(a.val, b.val)); }                    \
+-inline _Tpvec V_gt(const _Tpvec& a, const _Tpvec& b)           \
++inline _Tpvec v_gt(const _Tpvec& a, const _Tpvec& b)           \
+ { return _Tpvec(vec_cmpgt(a.val, b.val)); }                    \
+ inline _Tpvec v_le(const _Tpvec& a, const _Tpvec& b)           \
+ { return _Tpvec(vec_cmple(a.val, b.val)); }                    \
+@@ -1507,7 +1507,7 @@ inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b, cons
+ inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b)
+ { return v_dotprod(a, b); }
+ inline v_int32x4 v_dotprod_fast(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c)
+-{ return v_int32x4(vec_msum(a.val, b.val, vec_int4_z)) + c; }
++{ return v_add(v_int32x4(vec_msum(a.val, b.val, vec_int4_z)), c); }
+ // 32 >> 64
+ inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b)
+ { return v_dotprod(a, b); }
+@@ -1518,7 +1518,7 @@ inline v_int64x2 v_dotprod_fast(const v_int32x4& a, const v_int32x4& b, const v_
+ inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b)
+ { return v_dotprod_expand(a, b); }
+ inline v_uint32x4 v_dotprod_expand_fast(const v_uint8x16& a, const v_uint8x16& b, const v_uint32x4& c)
+-{ return v_uint32x4(vec_msum(a.val, b.val, vec_uint4_z)) + c; }
++{ return v_add(v_uint32x4(vec_msum(a.val, b.val, vec_uint4_z)), c); }
+ 
+ inline v_int32x4 v_dotprod_expand_fast(const v_int8x16& a, const v_int8x16& b)
+ {
+-- 
+2.25.1
+
diff --git a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb
index 07b3a9d9e6..1613b6a3ed 100644
--- a/meta-oe/recipes-support/opencv/opencv_4.11.0.bb
+++ b/meta-oe/recipes-support/opencv/opencv_4.11.0.bb
@@ -31,6 +31,7 @@  SRC_URI = "git://github.com/opencv/opencv.git;name=opencv;branch=4.x;protocol=ht
            file://download.patch \
            file://0001-Make-ts-module-external.patch \
            file://0008-Do-not-embed-build-directory-in-binaries.patch \
+           file://0001-core-fixed-VSX-intrinsics-implementation.patch \
            "
 SRC_URI:append:riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patchdir=contrib"
 
@@ -208,4 +209,10 @@  do_install:append() {
     if [ -f ${D}${bindir}/setup_vars_opencv4.sh ]; then
         rm -rf ${D}${bindir}/setup_vars_opencv4.sh
     fi
+
+    for fn in arithm.vsx3.cpp convert.vsx3.cpp; do
+        if [ -f ${B}/modules/core/$fn ]; then
+            sed -i -e 's,${S},/usr/src/debug/${PN}/${PV},g' ${B}/modules/core/$fn
+        fi
+    done
 }