Skip to content

core: fix missing vec_cvfo on IBM POWER9 due to unavailable VSX float64 conversion #27633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 4.x
Choose a base branch
from

Conversation

hillwoodroc
Copy link

@hillwoodroc hillwoodroc commented Aug 6, 2025

#27635

Some POWER9 systems fail to build downstream projects (e.g. ncnn) due to undefined references to vec_cvfo. This happens because POWER9 does not support the VSX float64 conversion instructions introduced in POWER10.

This patch introduces a fallback for vec_cvfo using scalar operations when building on POWER9. All other architectures (including POWER10, x86, ARM) will continue using the optimized VSX conversions.

Fixes: undefined symbol vec_cvfo on POWER9 with OpenCV 4.12.0

Tested on:

  • POWER9 (fallback used, links correctly)
  • POWER10 and x86 (optimized path used as expected)

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@asmorkalov asmorkalov self-requested a review August 6, 2025 12:30
@hillwoodroc hillwoodroc changed the title core: add fallback for float64<->float32 conversion on non-POWER10 VSX targets core: fix missing vec_cvfo on POWER9 due to unavailable VSX float64 conversion Aug 6, 2025
@hillwoodroc hillwoodroc changed the title core: fix missing vec_cvfo on POWER9 due to unavailable VSX float64 conversion core: fix missing vec_cvfo on IBM POWER9 due to unavailable VSX float64 conversion Aug 6, 2025
@asmorkalov asmorkalov added this to the 4.13.0 milestone Aug 7, 2025
@asmorkalov asmorkalov self-assigned this Aug 7, 2025
Comment on lines 280 to 286
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)[1]);
return (vec_double2){r0, r1};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation for vec_floate says: "Converts an input vector to a vector of single-precision numbers. The even-numbered target elements are obtained by converting the source elements to single-precision numbers." So the replacement is not equivalent.

https://www.ibm.com/docs/en/open-xl-c-cpp-zos/2.1.0?topic=rc-vec-floate-vector-convert-from-double-float-even-elements

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, how about this?

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}; 
}

…onversion

Some POWER9 systems fail to build downstream projects (e.g. ncnn) due to
undefined references to `vec_cvfo`. This happens because POWER9 does not
support the VSX float64 conversion instructions introduced in POWER10.

This patch introduces a fallback for `vec_cvfo` using scalar operations
when building on POWER9. All other architectures (including POWER10,
x86, ARM) will continue using the optimized VSX conversions.

Fixes: undefined symbol vec_cvfo on POWER9 with OpenCV 4.12.0

Tested on:
- POWER9 (fallback used, links correctly)
- POWER10 and x86 (optimized path used as expected)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants