xtensor-stack / xsimd

C++ wrappers for SIMD intrinsics and parallelized, optimized mathematical functions (SSE, AVX, AVX512, NEON, SVE))
https://xsimd.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
2.22k stars 258 forks source link

Argument must be an 8-bit immediate #349

Open tdegeus opened 4 years ago

tdegeus commented 4 years ago

I'm getting the following build error on my CI:

In file included from /usr/lib/gcc/x86_64-linux-gnu/6/include/immintrin.h:45:0,
                 from /usr/lib/gcc/x86_64-linux-gnu/6/include/x86intrin.h:48,
                 from /home/travis/miniconda/include/xsimd/config/xsimd_include.hpp:19,
                 from /home/travis/miniconda/include/xsimd/types/xsimd_types_include.hpp:14,
                 from /home/travis/miniconda/include/xsimd/types/xsimd_traits.hpp:17,
                 from /home/travis/miniconda/include/xsimd/xsimd.hpp:16,
                 from /home/travis/miniconda/include/xtensor/xtensor_config.hpp:84,
                 from /home/travis/miniconda/include/xtensor/xbuffer_adaptor.hpp:21,
                 from /home/travis/miniconda/include/xtensor/xtensor.hpp:19,
                 from /home/travis/build/tdegeus/GooseEYE/include/GooseEYE/config.h:26,
                 from /home/travis/build/tdegeus/GooseEYE/include/GooseEYE/GooseEYE.h:10,
                 from /home/travis/build/tdegeus/GooseEYE/test/main.cpp:2:
/home/travis/miniconda/include/xsimd/types/xsimd_avx512_int64.hpp: In function ‘xsimd::batch<long int, 8ul> xsimd::operator<<(const xsimd::batch<long int, 8ul>&, int32_t)’:
/home/travis/miniconda/include/xsimd/types/xsimd_avx512_int64.hpp:412:16: error: the last argument must be an 8-bit immediate
         return _mm512_slli_epi64(lhs, rhs);
                ^
/home/travis/miniconda/include/xsimd/types/xsimd_avx512_int64.hpp: In function ‘xsimd::batch<long int, 8ul> xsimd::operator>>(const xsimd::batch<long int, 8ul>&, int32_t)’:
/home/travis/miniconda/include/xsimd/types/xsimd_avx512_int64.hpp:417:16: error: the last argument must be an 8-bit immediate
         return _mm512_srli_epi64(lhs, rhs);
                ^
JohanMabille commented 4 years ago

I ran into this issue at some point. The last argument of _mm512_slli_epi64 and _mm512_srli_epi64 must be known at compile time. However, when this code is called, the compiler can figure out by itself the value of the constant (if called with a constant).

Do you call (indirectly) this code (it is the vectorization of shift operators)? Or do you have this error as soon as you include xismd?

tdegeus commented 4 years ago

Alright. As far as your question is concerned, I'm not entirely sure. It is a bit cumbersome to debug on travis as many of these errors are hardware dependent. Will let you know!

JohanMabille commented 4 years ago

Given that the error message does not print something like "required from here", I think checking GooseEYE/config.h:26and GooseEYE.h:10 should be enough. If they are include statements, then you do not call directly these methods and the compiler complains before knowing if he can determine the second argument (which is super weird).

Out of curiosity, which compiler do you use? And which distribution of Ubuntu?

serge-sans-paille commented 1 year ago

@JohanMabille we could provide a new type named xsimd::imm8<N> to provide an explicit immediate, do you think it's worth the effort?