AVX512 does not compile with g++ #412

Closed
opened 2020-06-27 14:27:29 -05:00 by wolfpld · 6 comments
wolfpld commented 2020-06-27 14:27:29 -05:00 (Migrated from github.com)

xxhash passes int where _MM_PERM_ENUM is required, for example:

../../../server/tracy_xxh3.h: In function ‘void XXH3_accumulate_512_avx512(void*, const void*, const void*)’:
../../../server/tracy_xxh3.h:1000:69: error: invalid conversion from ‘int’ to ‘_MM_PERM_ENUM’ [-fpermissive]
 1000 |         __m512i const data_key_lo = _mm512_shuffle_epi32 (data_key, _MM_SHUFFLE(0, 3, 0, 1));
      |                                                                     ^~~~~~~~~~~
      |                                                                     |
      |                                                                     int
In file included from /usr/lib/gcc/x86_64-linux-gnu/9/include/immintrin.h:55,
                 from ../../../server/tracy_xxh3.h:76:
/usr/lib/gcc/x86_64-linux-gnu/9/include/avx512fintrin.h:4364:50: note:   initializing argument 2 of ‘__m512i _mm512_shuffle_epi32(__m512i, _MM_PERM_ENUM)’
 4364 | _mm512_shuffle_epi32 (__m512i __A, _MM_PERM_ENUM __mask)
      |                                    ~~~~~~~~~~~~~~^~~~~~

Fix seems simple enough: github.com/embree/embree@40b9aca266

Relevant discussion: https://developercommunity.visualstudio.com/content/problem/107147/avx512-permute-macros-are-missing.html

xxhash passes `int` where `_MM_PERM_ENUM` is required, for example: ``` ../../../server/tracy_xxh3.h: In function ‘void XXH3_accumulate_512_avx512(void*, const void*, const void*)’: ../../../server/tracy_xxh3.h:1000:69: error: invalid conversion from ‘int’ to ‘_MM_PERM_ENUM’ [-fpermissive] 1000 | __m512i const data_key_lo = _mm512_shuffle_epi32 (data_key, _MM_SHUFFLE(0, 3, 0, 1)); | ^~~~~~~~~~~ | | | int In file included from /usr/lib/gcc/x86_64-linux-gnu/9/include/immintrin.h:55, from ../../../server/tracy_xxh3.h:76: /usr/lib/gcc/x86_64-linux-gnu/9/include/avx512fintrin.h:4364:50: note: initializing argument 2 of ‘__m512i _mm512_shuffle_epi32(__m512i, _MM_PERM_ENUM)’ 4364 | _mm512_shuffle_epi32 (__m512i __A, _MM_PERM_ENUM __mask) | ~~~~~~~~~~~~~~^~~~~~ ``` Fix seems simple enough: https://github.com/embree/embree/commit/40b9aca2668f443cae6bfbfa7cc5a354f1087011 Relevant discussion: https://developercommunity.visualstudio.com/content/problem/107147/avx512-permute-macros-are-missing.html
Cyan4973 commented 2020-06-27 17:18:48 -05:00 (Migrated from github.com)

Thanks for the report @wolfpld .

FYI, I tested -mavx512f with gcc, from 7 to 10, and it compiled fine, at least on Linux.
I note that the link to the discussion mentions Visual Studio.
So which it compiler is it ?

Thanks for the report @wolfpld . FYI, I tested `-mavx512f` with gcc, from 7 to 10, and it compiled fine, at least on Linux. I note that the link to the discussion mentions Visual Studio. So which it compiler is it ?
wolfpld commented 2020-06-27 17:31:37 -05:00 (Migrated from github.com)

I have linked the article talking about MSVC only to give some context about the nature of this issue.

The build that is failing for me was performed on GitHub CI using ubuntu-20.04 image.

I can repro this locally using gcc 9.3.0 with -march=skylake-avx512 -O1. Enabling optimization is somehow needed here.

I have linked the article talking about MSVC only to give some context about the nature of this issue. The build that is failing for me was performed on GitHub CI using `ubuntu-20.04` image. I can repro this locally using gcc 9.3.0 with `-march=skylake-avx512 -O1`. Enabling optimization is somehow needed here.
Cyan4973 commented 2020-06-27 21:17:32 -05:00 (Migrated from github.com)

I'm mystified.
Using exactly the same image ubuntu-20.04, the same compiler gcc 9.3.0 and the same optimization flag -march=skylake-avx512, yet it doesn't produce any warning ...

Not that I doubt it does happen. Just, it's better to be able to reproduce it so that it's controlled in CI.
Currently, it doesn't happen there :
https://travis-ci.org/github/Cyan4973/xxHash/jobs/702755044#L575
though this is using Travis CI instead of Github CI ...

I'm mystified. Using exactly the same image `ubuntu-20.04`, the same compiler `gcc 9.3.0` and the same optimization flag `-march=skylake-avx512`, yet it doesn't produce any warning ... Not that I doubt it does happen. Just, it's better to be able to reproduce it so that it's controlled in CI. Currently, it doesn't happen there : https://travis-ci.org/github/Cyan4973/xxHash/jobs/702755044#L575 though this is using Travis CI instead of Github CI ...
easyaspi314 commented 2020-06-27 21:56:29 -05:00 (Migrated from github.com)

It is to be noted that it seems like GCC is in g++ mode, as -fpermissive/-fno-permissive is only a C++ option.

It is to be noted that it seems like GCC is in `g++` mode, as `-fpermissive`/`-fno-permissive` is only a C++ option.
Cyan4973 commented 2020-06-28 01:24:42 -05:00 (Migrated from github.com)

oh, that's exactly right @easyaspi314 ,
with g++, now I can see the issue.

oh, that's exactly right @easyaspi314 , with `g++`, now I can see the issue.
Cyan4973 commented 2020-07-02 17:50:14 -05:00 (Migrated from github.com)

OK, so the issue is not about _MM_SHUFFLE(),
but rather that _mm512_shuffle_epi32() expects an argument of type _MM_PERM_ENUM,
in contrast with existing equivalent AVX2 and SSE2 variants, which require an int.
Both types are equivalent in C, but different in C++.
Furthermore, the permute macro _MM_SHUFFLE(), which is used for all 3 variants, continue to return an int.

I fail to find a good logic explaining this interface change.
Anyway, assuming type _MM_PERM_ENUM is necessarily defined when _mm512_shuffle_epi32() exists, the fix seems indeed simple enough.

OK, so the issue is not about `_MM_SHUFFLE()`, but rather that `_mm512_shuffle_epi32()` expects an argument of type `_MM_PERM_ENUM`, in contrast with existing equivalent `AVX2` and `SSE2` variants, which require an `int`. Both types are equivalent in `C`, but different in `C++`. Furthermore, the permute macro `_MM_SHUFFLE()`, which is used for all 3 variants, continue to return an `int`. I fail to find a good logic explaining this interface change. Anyway, assuming type `_MM_PERM_ENUM` is necessarily defined when `_mm512_shuffle_epi32()` exists, the fix seems indeed simple enough.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-Cyan4973/xxHash#412
No description provided.