Skip to content
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

Invalid reinterpret_cast when building on RISC-V #11868

Open
wangpc-pp opened this issue Dec 16, 2024 · 1 comment
Open

Invalid reinterpret_cast when building on RISC-V #11868

wangpc-pp opened this issue Dec 16, 2024 · 1 comment
Labels
build triage Newly created issue that needs attention.

Comments

@wangpc-pp
Copy link

Problem description

Hi, I just met an issue when trying to build velox on RISC-V, it reported:

error: reinterpret_cast from 'register_type' (aka 'xsimd::types::detail::rvv_bool<long, 128>') to 'xsimd::batch_bool<double, xsimd::default_arch>::register_type' (aka 'xsimd::types::detail::rvv_bool<double, 128>') is not allowed
   58 |   return reinterpret_cast<
      |          ^~~~~~~~~~~~~~~~~
   59 |       xsimd::batch_bool<double, xsimd::default_arch>::register_type>(
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   60 |       leadingMask64[i].data);
      |       ~~~~~~~~~~~~~~~~~~~~~~

It is because we are trying to reinterpret_cast a bool vector of long to a bool vector of double, but the underlying type is a struct template for RISC-V (see also here).

template <>
inline xsimd::batch_bool<double, xsimd::default_arch> leadingMask(
int i,
const xsimd::default_arch&) {
return reinterpret_cast<
xsimd::batch_bool<double, xsimd::default_arch>::register_type>(
leadingMask64[i].data);
}

It works if we change to static_cast.

System information

Velox System Info v0.0.2
Commit: 2c9a42e
CMake Version: 3.26.4
System: Linux-5.15.152.bsk.1-amd64
Arch: x86_64
C++ Compiler: /usr/bin/c++
C++ Compiler Version: 12.2.0
C Compiler: /usr/bin/cc
C Compiler Version: 12.2.0
CMake Prefix Path: /usr/local;/usr;/;/data00/wpc/software/cmake;/usr/local;/usr/X11R6;/usr/pkg;/opt

CMake log

Please see: https://godbolt.org/z/oYvTeoebr
@serge-sans-paille
Copy link

I think this should be using xsimd::bit_cast instead, see https://godbolt.org/z/aohazPMM6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build triage Newly created issue that needs attention.
Projects
None yet
Development

No branches or pull requests

2 participants