Path: blob/main/contrib/llvm-project/clang/lib/Headers/amxavx512intrin.h
213766 views
/*===--------------------- amxavx512intrin.h - AMXAVX512 --------------------===1*2* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3* See https://llvm.org/LICENSE.txt for license information.4* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5*6*===------------------------------------------------------------------------===7*/8#ifndef __IMMINTRIN_H9#error "Never use <amxavx512intrin.h> directly; include <immintrin.h> instead."10#endif // __IMMINTRIN_H1112#ifndef __AMX_AVX512INTRIN_H13#define __AMX_AVX512INTRIN_H14#if defined(__x86_64__) && defined(__SSE2__)1516#define __DEFAULT_FN_ATTRS_AVX512 \17__attribute__((__always_inline__, __nodebug__, \18__target__("amx-avx512,avx10.2-512")))1920/// Moves a row from a tile register to a zmm destination register, converting21/// the int32 source elements to fp32. The row of the tile is selected by a22/// 32b GPR.23///24/// \headerfile <x86intrin.h>25///26/// \code27/// __m512i _tile_cvtrowd2ps(__tile tsrc, unsigned int row);28/// \endcode29///30/// \code{.operation}31/// VL := 51232/// VL_bytes := VL >> 333/// row_index := row & 0xffff34/// row_chunk := ((row >> 16) & 0xffff) * VL_bytes35/// FOR i := 0 TO (VL_bytes / 4) - 136/// IF i + row_chunk / 4 >= tsrc.colsb / 437/// dst.dword[i] := 038/// ELSE39/// dst.f32[i] := CONVERT_INT32_TO_FP32(tsrc.row[row_index].dword[row_chunk/4+i], RNE)40/// FI41/// ENDFOR42/// dst[MAX_VL-1:VL] := 043/// zero_tileconfig_start()44/// \endcode45///46/// This intrinsic corresponds to the \c TCVTROWD2PS instruction.47///48/// \param tsrc49/// The source tile. Max size is 1024 Bytes.50/// \param row51/// The row of the source tile52#define _tile_cvtrowd2ps(tsrc, row) __builtin_ia32_tcvtrowd2ps(tsrc, row)5354/// Moves a row from a tile register to a zmm destination register, converting55/// the fp32 source elements to bf16. It places the resulting bf16 elements56/// in the high 16 bits within each dword. The row of the tile is selected57/// by a 32b GPR.58///59/// \headerfile <x86intrin.h>60///61/// \code62/// __m512i _tile_cvtrowps2bf16h(__tile tsrc, unsigned int row);63/// \endcode64///65/// \code{.operation}66/// VL := 51267/// VL_bytes := VL >> 368/// row_index := row & 0xffff69/// row_chunk := ((row >> 16) & 0xffff) * VL_bytes70/// FOR i := 0 TO (VL_bytes / 4) - 171/// IF i + row_chunk / 4 >= tsrc.colsb / 472/// dst.dword[i] := 073/// ELSE74/// dst.word[2*i+0] := 075/// dst.bf16[2*i+1] := CONVERT_FP32_TO_BF16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE)76/// FI77/// ENDFOR78/// dst[MAX_VL-1:VL] := 079/// zero_tileconfig_start()80/// \endcode81///82/// This intrinsic corresponds to the \c TCVTROWPS2BF16H instruction.83///84/// \param tsrc85/// The source tile. Max size is 1024 Bytes.86/// \param row87/// The the row of the source tile.88#define _tile_cvtrowps2bf16h(tsrc, row) \89__builtin_ia32_tcvtrowps2bf16h(tsrc, row)9091/// Moves a row from a tile register to a zmm destination register, converting92/// the fp32 source elements to bf16. It places the resulting bf16 elements93/// in the low 16 bits within each dword. The row of the tile is selected94/// by a 32b GPR.95///96/// \headerfile <x86intrin.h>97///98/// \code99/// __m512i _tile_cvtrowps2bf16l(__tile tsrc, unsigned int row);100/// \endcode101///102/// \code{.operation}103/// VL := 512104/// VL_bytes := VL >> 3105/// row_index := row & 0xffff106/// row_chunk := ((row >> 16) & 0xffff) * VL_bytes107/// FOR i := 0 TO (VL_bytes / 4) - 1108/// IF i + row_chunk / 4 >= tsrc.colsb / 4109/// dst.dword[i] := 0110/// ELSE111/// dst.word[2*i+1] := 0112/// dst.bf16[2*i+0] := CONVERT_FP32_TO_BF16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE)113/// FI114/// ENDFOR115/// dst[MAX_VL-1:VL] := 0116/// zero_tileconfig_start()117/// \endcode118///119/// This intrinsic corresponds to the \c TCVTROWPS2BF16L instruction.120///121/// \param tsrc122/// The source tile. Max size is 1024 Bytes.123/// \param row124/// The the row of the source tile.125#define _tile_cvtrowps2bf16l(tsrc, row) \126__builtin_ia32_tcvtrowps2bf16l(tsrc, row)127128/// Moves a row from a tile register to a zmm destination register, converting129/// the fp32 source elements to fp16. It places the resulting fp16 elements130/// in the high 16 bits within each dword. The row of the tile is selected131/// by a 32b GPR.132///133/// \headerfile <x86intrin.h>134///135/// \code136/// __m512i _tile_cvtrowps2phh(__tile tsrc, unsigned int row);137/// \endcode138///139/// \code{.operation}140/// VL := 512141/// VL_bytes := VL >> 3142/// row_index := row & 0xffff143/// row_chunk := ((row >> 16) & 0xffff) * VL_bytes144/// FOR i := 0 TO (VL_bytes / 4) - 1145/// IF i + row_chunk / 4 >= tsrc.colsb / 4146/// dst.dword[i] := 0147/// ELSE148/// dst.word[2*i+0] := 0149/// dst.fp16[2*i+1] := CONVERT_FP32_TO_FP16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE)150/// FI151/// ENDFOR152/// dst[MAX_VL-1:VL] := 0153/// zero_tileconfig_start()154/// \endcode155///156/// This intrinsic corresponds to the \c TCVTROWPS2PHH instruction.157///158/// \param tsrc159/// The source tile. Max size is 1024 Bytes.160/// \param row161/// The the row of the source tile.162#define _tile_cvtrowps2phh(tsrc, row) __builtin_ia32_tcvtrowps2phh(tsrc, row)163164/// Moves a row from a tile register to a zmm destination register, converting165/// the fp32 source elements to fp16. It places the resulting fp16 elements166/// in the low 16 bits within each dword. The row of the tile is selected167/// by a 32b GPR.168///169/// \headerfile <x86intrin.h>170///171/// \code172/// __m512i _tile_cvtrowps2phl(__tile tsrc, unsigned int row);173/// \endcode174///175/// \code{.operation}176/// VL := 512177/// VL_bytes := VL >> 3178/// row_index := row & 0xffff179/// row_chunk := ((row >> 16) & 0xffff) * VL_bytes180/// FOR i := 0 TO (VL_bytes / 4) - 1181/// IF i + row_chunk / 4 >= tsrc.colsb / 4182/// dst.dword[i] := 0183/// ELSE184/// dst.word[2*i+1] := 0185/// dst.fp16[2*i+0] := CONVERT_FP32_TO_FP16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE)186/// FI187/// ENDFOR188/// dst[MAX_VL-1:VL] := 0189/// zero_tileconfig_start()190/// \endcode191///192/// This intrinsic corresponds to the \c TCVTROWPS2PHL instruction.193///194/// \param tsrc195/// The source tile. Max size is 1024 Bytes.196/// \param row197/// The the row of the source tile.198#define _tile_cvtrowps2phl(tsrc, row) __builtin_ia32_tcvtrowps2phl(tsrc, row)199200/// Move one row of a tile data to a v16f32 data.201/// The row of the tile is selected by a 32b GPR.202///203/// \headerfile <immintrin.h>204///205/// \code206/// __m512 _tile_movrow(__tile a, unsigned b);207/// \endcode208///209/// This intrinsic corresponds to the <c> TILEMOVROW </c> instruction.210///211/// \param a212/// The 1st source tile. Max size is 1024 Bytes.213/// \param b214/// The 2nd source r32. Size is 4 Bytes.215/// \returns216/// The destination v16f32 data. Size is 64 Bytes.217///218/// \code{.operation}219/// VL := 512220/// VL_bytes := VL>>3221/// row_index := b&0xffff222/// row_chunk := ((b>>16)&0xffff) * VL_bytes223/// FOR i := 0 TO (VL_bytes-1)224/// IF (row_chunk + i >= a.colsb)225/// dst.byte[i] := 0226/// ELSE227/// dst.byte[i] := a.row[row_index].byte[row_chunk+i]228/// ENDFOR229/// \endcode230#define _tile_movrow(a, b) ((__m512i)__builtin_ia32_tilemovrow(a, b))231232/// This is internal intrinsic. C/C++ user should avoid calling it directly.233234static __inline__ __m512 __DEFAULT_FN_ATTRS_AVX512 _tile_cvtrowd2ps_internal(235unsigned short m, unsigned short n, _tile1024i src, unsigned u) {236return __builtin_ia32_tcvtrowd2ps_internal(m, n, src, u);237}238239static __inline__ __m512bh __DEFAULT_FN_ATTRS_AVX512240_tile_cvtrowps2bf16h_internal(unsigned short m, unsigned short n,241_tile1024i src, unsigned u) {242return __builtin_ia32_tcvtrowps2bf16h_internal(m, n, src, u);243}244245static __inline__ __m512bh __DEFAULT_FN_ATTRS_AVX512246_tile_cvtrowps2bf16l_internal(unsigned short m, unsigned short n,247_tile1024i src, unsigned u) {248return __builtin_ia32_tcvtrowps2bf16l_internal(m, n, src, u);249}250251static __inline__ __m512h __DEFAULT_FN_ATTRS_AVX512 _tile_cvtrowps2phh_internal(252unsigned short m, unsigned short n, _tile1024i src, unsigned u) {253return __builtin_ia32_tcvtrowps2phh_internal(m, n, src, u);254}255256static __inline__ __m512h __DEFAULT_FN_ATTRS_AVX512 _tile_cvtrowps2phl_internal(257unsigned short m, unsigned short n, _tile1024i src, unsigned u) {258return __builtin_ia32_tcvtrowps2phl_internal(m, n, src, u);259}260261static __inline__ __m512i __DEFAULT_FN_ATTRS_AVX512 _tile_movrow_internal(262unsigned short m, unsigned short n, _tile1024i src, unsigned u) {263return (__m512i)__builtin_ia32_tilemovrow_internal(m, n, src, u);264}265266/// Move a row from a tile (src0) to a v16f32 dst, converting the int32 source267/// elements to fp32. No SIMD exceptions are generated. Rounding is done as if268/// MXCSR.RC=RNE. Embedded rounding is not supported.269/// The row and chunk elements of tile is fetched from 32bit src1.270///271/// \headerfile <immintrin.h>272///273/// This intrinsic corresponds to the <c> TCVTROWD2PS </c> instruction.274///275/// \param src0276/// The 1st source tile. Max size is 1024 Bytes.277/// \param src1278/// The 2nd source r32. Size is 4 Bytes.279/// \returns280/// The destination v16f32 data. Size is 64 Bytes.281__DEFAULT_FN_ATTRS_AVX512282static __m512 __tile_cvtrowd2ps(__tile1024i src0, unsigned src1) {283return _tile_cvtrowd2ps_internal(src0.row, src0.col, src0.tile, src1);284}285286/// Move a row from a tile (src0) to a v32bf16 dst, converting the fp32 source287/// elements to bf16 at high 16-bits of each dword.288/// The row and chunk elements of tile is fetched from 32bit src1.289///290/// \headerfile <immintrin.h>291///292/// This intrinsic corresponds to the <c> TCVTROWPS2BF16H </c> instruction.293///294/// \param src0295/// The 1st source tile. Max size is 1024 Bytes.296/// \param src1297/// The 2nd source r32. Size is 4 Bytes.298/// \returns299/// The destination v32bf16 data. Size is 64 Bytes.300__DEFAULT_FN_ATTRS_AVX512301static __m512bh __tile_cvtrowps2bf16h(__tile1024i src0, unsigned src1) {302return _tile_cvtrowps2bf16h_internal(src0.row, src0.col, src0.tile, src1);303}304305/// Move a row from a tile (src0) to a v32bf16 dst, converting the fp32 source306/// elements to bf16 at low 16-bits of each dword.307/// The row and chunk elements of tile is fetched from 32bit src1.308///309/// \headerfile <immintrin.h>310///311/// This intrinsic corresponds to the <c> TCVTROWPS2BF16L </c> instruction.312///313/// \param src0314/// The 1st source tile. Max size is 1024 Bytes.315/// \param src1316/// The 2nd source r32. Size is 4 Bytes.317/// \returns318/// The destination v32bf16 data. Size is 64 Bytes.319__DEFAULT_FN_ATTRS_AVX512320static __m512bh __tile_cvtrowps2bf16l(__tile1024i src0, unsigned src1) {321return _tile_cvtrowps2bf16l_internal(src0.row, src0.col, src0.tile, src1);322}323324/// Move a row from a tile (src0) to a v32fp16 dst, converting the fp32 source325/// elements to fp16 at high 16-bits of each dword.326/// The row and chunk elements of tile is fetched from 32bit src1.327///328/// \headerfile <immintrin.h>329///330/// This intrinsic corresponds to the <c> TCVTROWPS2PHH </c> instruction.331///332/// \param src0333/// The 1st source tile. Max size is 1024 Bytes.334/// \param src1335/// The 2nd source r32. Size is 4 Bytes.336/// \returns337/// The destination v32fp16 data. Size is 64 Bytes.338__DEFAULT_FN_ATTRS_AVX512339static __m512h __tile_cvtrowps2phh(__tile1024i src0, unsigned src1) {340return _tile_cvtrowps2phh_internal(src0.row, src0.col, src0.tile, src1);341}342343/// Move a row from a tile (src0) to a v32fp16 dst, converting the fp32 source344/// elements to fp16 at low 16-bits of each dword.345/// The row and chunk elements of tile is fetched from 32bit src1.346///347/// \headerfile <immintrin.h>348///349/// This intrinsic corresponds to the <c> TCVTROWPS2PHL </c> instruction.350///351/// \param src0352/// The 1st source tile. Max size is 1024 Bytes.353/// \param src1354/// The 2nd source r32. Size is 4 Bytes.355/// \returns356/// The destination v32fp16 data. Size is 64 Bytes.357__DEFAULT_FN_ATTRS_AVX512358static __m512h __tile_cvtrowps2phl(__tile1024i src0, unsigned src1) {359return _tile_cvtrowps2phl_internal(src0.row, src0.col, src0.tile, src1);360}361362/// Move one row of a tile data to a v16f32 data.363/// The row of the tile is selected by a 32b GPR.364///365/// \headerfile <immintrin.h>366///367/// This intrinsic corresponds to the <c> TILEMOVROW </c> instruction.368///369/// \param src0370/// The 1st source tile. Max size is 1024 Bytes.371/// \param src1372/// The 2nd source r32. Size is 4 Bytes.373/// \returns374/// The destination v16i32 data. Size is 64 Bytes.375__DEFAULT_FN_ATTRS_AVX512376static __m512i __tile_movrow(__tile1024i src0, unsigned src1) {377return (__m512i)_tile_movrow_internal(src0.row, src0.col, src0.tile, src1);378}379380#endif // __x86_64__ && __SSE2__381#endif // __AMX_AVX512INTRIN_H382383384