simd-everywhere / simde

Implementations of SIMD instruction sets for systems which don't natively support them.
https://simd-everywhere.github.io/blog/
MIT License
2.32k stars 239 forks source link

Invalid type conversions on M1 Mac #1125

Closed aberthel closed 5 months ago

aberthel commented 7 months ago

Hello! I have been trying to use simd-everywhere to compile the RADULS sorting library for a Mac with an M1 chip. I am running into a problem that seems to originate from sse4.2.h, where a conversion between incompatible types is taking place. I get the following error message:

gcc-13 -IRaduls -Wall -fopenmp -O3 -march=armv8.5-a+fp+simd+crc+crypto -fno-ipa-ra -fno-tree-vrp -fno-tree-pre -m64 -std=c++14 -pthread  -c Example/main.cpp -o Example/main.o
In file included from Raduls/simde/x86/sse4.2.h:34,
                 from Raduls/simde/x86/avx.h:32,
                 from Raduls/raduls.h:19,
                 from Example/main.cpp:11:
/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin21/13/include/arm_acle.h: In function 'int __rndr(uint64_t*)':
/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin21/13/include/arm_acle.h:282:34: error: invalid conversion from 'uint64_t*' {aka 'long long unsigned int*'} to 'long unsigned int*' [-fpermissive]
  282 |   return __builtin_aarch64_rndr (__res);
      |                                  ^~~~~
      |                                  |
      |                                  uint64_t* {aka long long unsigned int*}
<built-in>: note:   initializing argument 1 of 'int __builtin_aarch64_rndr(long unsigned int*)'
/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin21/13/include/arm_acle.h: In function 'int __rndrrs(uint64_t*)':
/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/current/gcc/aarch64-apple-darwin21/13/include/arm_acle.h:289:36: error: invalid conversion from 'uint64_t*' {aka 'long long unsigned int*'} to 'long unsigned int*' [-fpermissive]
  289 |   return __builtin_aarch64_rndrrs (__res);
      |                                    ^~~~~
      |                                    |
      |                                    uint64_t* {aka long long unsigned int*}
<built-in>: note:   initializing argument 1 of 'int __builtin_aarch64_rndrrs(long unsigned int*)'
make: *** [Example/main.o] Error 1

I'm not really a C programmer, just trying to get this library compiled for use in another project, and I haven't been able to figure out the root cause of the issue. Any insights would be much appreciated.

mr-c commented 7 months ago

Hello @aberthel

Which SIMDe function is this? Alas the compiler output doesn't say..

aberthel commented 7 months ago

It's throwing errors at the #include <arm_acle.h> directive (ARM C Language Extensions). Within that file, the __builtin_aarch64_rndr and __builtin_aarch64_rndrrs intrinsics (which I think have some RNG function) seem to be returning 64-bit ints when something earlier up the line expected 32-bit ints. I haven't been able to figure out what that "something" is yet.

mr-c commented 5 months ago

@aberthel Can you test again using #1148 ?

mr-c commented 5 months ago

I believe this has been fixed, please let us know if not