Path: blob/main/contrib/llvm-project/clang/lib/Headers/amxbf16transposeintrin.h
213766 views
/*===----- amxbf16transposeintrin.h - AMX-BF16 and AMX-TRANSPOSE ------------===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*/89#ifndef __IMMINTRIN_H10#error \11"Never use <amxbf16transposeintrin.h> directly; use <immintrin.h> instead."12#endif /* __IMMINTRIN_H */1314#ifndef __AMX_BF16TRANSPOSEINTRIN_H15#define __AMX_BF16TRANSPOSEINTRIN_H16#ifdef __x86_64__1718/* Define the default attributes for the functions in this file. */19#define __DEFAULT_FN_ATTRS \20__attribute__((__always_inline__, __nodebug__, \21__target__("amx-bf16,amx-transpose")))2223/// Compute transpose and dot-product of BF16 (16-bit) floating-point pairs in24/// tiles \a a and \a b, accumulating the intermediate single-precision25/// (32-bit) floating-point elements with elements in \a dst, and store the26/// 32-bit result back to tile \a dst.27///28/// \headerfile <immintrin.h>29///30/// \code31/// void _tile_tdpbf16ps (__tile dst, __tile a, __tile b)32/// \endcode33///34/// \code{.operation}35/// FOR m := 0 TO dst.rows - 136/// tmp := dst.row[m]37/// FOR k := 0 TO (a.colsb / 4) - 138/// FOR n := 0 TO (dst.colsb / 4) - 139/// tmp.bf32[n] += FP32(a.row[m].bf16[2*k+0]) *40/// FP32(b.row[k].bf16[2*n+0])41/// tmp.bf32[n] += FP32(a.row[m].bf16[2*k+1]) *42/// FP32(b.row[k].bf16[2*n+1])43/// ENDFOR44/// ENDFOR45/// write_row_and_zero(dst, m, tmp, dst.colsb)46/// ENDFOR47/// zero_upper_rows(dst, dst.rows)48/// zero_tileconfig_start()49/// \endcode50///51/// This intrinsic corresponds to the \c TTDPBF16PS instruction.52///53/// \param dst54/// The destination tile. Max size is 1024 Bytes.55/// \param a56/// The 1st source tile. Max size is 1024 Bytes.57/// \param b58/// The 2nd source tile. Max size is 1024 Bytes.59#define _tile_tdpbf16ps(dst, a, b) __builtin_ia32_ttdpbf16ps((dst), (a), (b))6061/// This is internal intrinsic. C/C++ user should avoid calling it directly.62static __inline__ _tile1024i __DEFAULT_FN_ATTRS63_tile_tdpbf16ps_internal(unsigned short m, unsigned short n, unsigned short k,64_tile1024i dst, _tile1024i src1, _tile1024i src2) {65return __builtin_ia32_ttdpbf16ps_internal(m, n, k, dst, src1, src2);66}6768/// Compute transpose and dot-product of BF16 (16-bit) floating-point pairs in69/// tiles src0 and src1, accumulating the intermediate single-precision70/// (32-bit) floating-point elements with elements in "dst", and store the71/// 32-bit result back to tile "dst".72///73/// \headerfile <immintrin.h>74///75/// This intrinsic corresponds to the <c> TTDPBF16PS </c> instruction.76///77/// \param dst78/// The destination tile. Max size is 1024 Bytes.79/// \param src080/// The 1st source tile. Max size is 1024 Bytes.81/// \param src182/// The 2nd source tile. Max size is 1024 Bytes.83__DEFAULT_FN_ATTRS84static __inline__ void __tile_tdpbf16ps(__tile1024i *dst, __tile1024i src0,85__tile1024i src1) {86dst->tile = _tile_tdpbf16ps_internal(src0.row, src1.col, src0.col, dst->tile,87src0.tile, src1.tile);88}8990#undef __DEFAULT_FN_ATTRS9192#endif /* __x86_64__ */93#endif /* __AMX_BF16TRANSPOSEINTRIN_H */949596