mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
target/arm: Implement bfloat16 dot product (vector)
This is BFDOT for both AArch64 AdvSIMD and SVE, and VDOT.BF16 for AArch32 NEON. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20210525225817.400336-7-richard.henderson@linaro.org Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
60c8f7265d
commit
cb8657f7f9
7 changed files with 89 additions and 0 deletions
|
@ -2412,3 +2412,43 @@ static void do_mmla_b(void *vd, void *vn, void *vm, void *va, uint32_t desc,
|
|||
DO_MMLA_B(gvec_smmla_b, do_smmla_b)
|
||||
DO_MMLA_B(gvec_ummla_b, do_ummla_b)
|
||||
DO_MMLA_B(gvec_usmmla_b, do_usmmla_b)
|
||||
|
||||
/*
|
||||
* BFloat16 Dot Product
|
||||
*/
|
||||
|
||||
static float32 bfdotadd(float32 sum, uint32_t e1, uint32_t e2)
|
||||
{
|
||||
/* FPCR is ignored for BFDOT and BFMMLA. */
|
||||
float_status bf_status = {
|
||||
.tininess_before_rounding = float_tininess_before_rounding,
|
||||
.float_rounding_mode = float_round_to_odd_inf,
|
||||
.flush_to_zero = true,
|
||||
.flush_inputs_to_zero = true,
|
||||
.default_nan_mode = true,
|
||||
};
|
||||
float32 t1, t2;
|
||||
|
||||
/*
|
||||
* Extract each BFloat16 from the element pair, and shift
|
||||
* them such that they become float32.
|
||||
*/
|
||||
t1 = float32_mul(e1 << 16, e2 << 16, &bf_status);
|
||||
t2 = float32_mul(e1 & 0xffff0000u, e2 & 0xffff0000u, &bf_status);
|
||||
t1 = float32_add(t1, t2, &bf_status);
|
||||
t1 = float32_add(sum, t1, &bf_status);
|
||||
|
||||
return t1;
|
||||
}
|
||||
|
||||
void HELPER(gvec_bfdot)(void *vd, void *vn, void *vm, void *va, uint32_t desc)
|
||||
{
|
||||
intptr_t i, opr_sz = simd_oprsz(desc);
|
||||
float32 *d = vd, *a = va;
|
||||
uint32_t *n = vn, *m = vm;
|
||||
|
||||
for (i = 0; i < opr_sz / 4; ++i) {
|
||||
d[i] = bfdotadd(a[i], n[i], m[i]);
|
||||
}
|
||||
clear_tail(d, opr_sz, simd_maxsz(desc));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue