[clang] [llvm] [X86][AMX] Support AMX-AVX512 (PR #114070)

Alan Zhao via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 8 16:12:55 PST 2024


alanzhao1 wrote:

Figured out a repro - `immintrin.h` doesn't compile if both `-msse` and `-mno-sse2` are passed to clang:

```
$ cat ~/src/test-mac.c
#include<immintrin.h>

$ bin/clang -msse -mno-sse2 -o /dev/null -c ~/src/test-mac.c
In file included from /usr/local/google/home/ayzhao/src/test-mac.c:1:
In file included from /usr/local/google/home/ayzhao/src/llvm-project/build/lib/clang/20/include/immintrin.h:660:
/usr/local/google/home/ayzhao/src/llvm-project/build/lib/clang/20/include/amxavx512intrin.h:240:19: error: unknown type name '__m512bh'
  240 | static __inline__ __m512bh __DEFAULT_FN_ATTRS_AVX512
      |                   ^
/usr/local/google/home/ayzhao/src/llvm-project/build/lib/clang/20/include/amxavx512intrin.h:243:10: error: returning '__attribute__((__vector_size__(32 * sizeof(__bf16)))) __bf16' (vector of 32 '__bf16' values) from a function with incompatible result type 'int'
  243 |   return __builtin_ia32_tcvtrowps2pbf16h_internal(m, n, src, u);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/ayzhao/src/llvm-project/build/lib/clang/20/include/amxavx512intrin.h:246:19: error: unknown type name '__m512bh'
  246 | static __inline__ __m512bh __DEFAULT_FN_ATTRS_AVX512
      |                   ^
/usr/local/google/home/ayzhao/src/llvm-project/build/lib/clang/20/include/amxavx512intrin.h:249:10: error: returning '__attribute__((__vector_size__(32 * sizeof(__bf16)))) __bf16' (vector of 32 '__bf16' values) from a function with incompatible result type 'int'
  249 |   return __builtin_ia32_tcvtrowps2pbf16l_internal(m, n, src, u);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/ayzhao/src/llvm-project/build/lib/clang/20/include/amxavx512intrin.h:252:19: error: unknown type name '__m512h'
  252 | static __inline__ __m512h __DEFAULT_FN_ATTRS_AVX512 _tile_cvtrowps2phh_internal(
      |                   ^
/usr/local/google/home/ayzhao/src/llvm-project/build/lib/clang/20/include/amxavx512intrin.h:254:10: error: returning '__attribute__((__vector_size__(32 * sizeof(_Float16)))) _Float16' (vector of 32 '_Float16' values) from a function with incompatible result type 'int'
  254 |   return __builtin_ia32_tcvtrowps2phh_internal(m, n, src, u);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/ayzhao/src/llvm-project/build/lib/clang/20/include/amxavx512intrin.h:257:19: error: unknown type name '__m512h'
  257 | static __inline__ __m512h __DEFAULT_FN_ATTRS_AVX512 _tile_cvtrowps2phl_internal(
      |                   ^
/usr/local/google/home/ayzhao/src/llvm-project/build/lib/clang/20/include/amxavx512intrin.h:259:10: error: returning '__attribute__((__vector_size__(32 * sizeof(_Float16)))) _Float16' (vector of 32 '_Float16' values) from a function with incompatible result type 'int'
  259 |   return __builtin_ia32_tcvtrowps2phl_internal(m, n, src, u);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/ayzhao/src/llvm-project/build/lib/clang/20/include/amxavx512intrin.h:302:8: error: unknown type name '__m512bh'
  302 | static __m512bh __tile_cvtrowps2pbf16h(__tile1024i src0, unsigned src1) {
      |        ^
/usr/local/google/home/ayzhao/src/llvm-project/build/lib/clang/20/include/amxavx512intrin.h:321:8: error: unknown type name '__m512bh'
  321 | static __m512bh __tile_cvtrowps2pbf16l(__tile1024i src0, unsigned src1) {
      |        ^
/usr/local/google/home/ayzhao/src/llvm-project/build/lib/clang/20/include/amxavx512intrin.h:340:8: error: unknown type name '__m512h'
  340 | static __m512h __tile_cvtrowps2phh(__tile1024i src0, unsigned src1) {
      |        ^
/usr/local/google/home/ayzhao/src/llvm-project/build/lib/clang/20/include/amxavx512intrin.h:359:8: error: unknown type name '__m512h'
  359 | static __m512h __tile_cvtrowps2phl(__tile1024i src0, unsigned src1) {
      |        ^
12 errors generated.
```

Test was on an x64 linux system.

https://github.com/llvm/llvm-project/pull/114070


More information about the cfe-commits mailing list