target/arm: Fixes for SME FMOPA (#2373)
cover target/arm: Fixes for SME FMOPA (#2373)
Hi Daniyal,
Your fix for sme_fmopa_s is correct, but not the FZ16 fix. We represent FZ16 with a separate float_status structure, so all that is needed is to use that.
Thanks for the test cases. I cleaned them up a little, and wired them into the Makefile.
r~
Supercedes: [email protected]
Daniyal Khan (2):
target/arm: Use float_status copy in sme_fmopa_s tests/tcg/aarch64: Add test cases for SME FMOPA (widening)
Richard Henderson (1):
target/arm: Use FPST_F16 for SME FMOPA (widening)
target/arm/tcg/sme_helper.c | 2 +- target/arm/tcg/translate-sme.c | 12 ++++-- tests/tcg/aarch64/sme-fmopa-1.c | 63 +++++++++++++++++++++++++++++++ tests/tcg/aarch64/sme-fmopa-2.c | 51 +++++++++++++++++++++++++ tests/tcg/aarch64/sme-fmopa-3.c | 58 ++++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 5 ++- 6 files changed, 184 insertions(+), 7 deletions(-) create mode 100644 tests/tcg/aarch64/sme-fmopa-1.c create mode 100644 tests/tcg/aarch64/sme-fmopa-2.c create mode 100644 tests/tcg/aarch64/sme-fmopa-3.c
Signature · 1 line
2.43.0
PATCH 1/3 target/arm: Use float_status copy in sme_fmopa_s
From: Daniyal Khan <[email protected]>
We made a copy above because the fp exception flags are not propagated back to the FPST register, but then failed to use the copy.
--- target/arm/tcg/sme_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/tcg/sme_helper.c +1 -1
@@ -916,7 +916,7 @@ void HELPER(sme_fmopa_s)(void *vza, void *vzn, void *vzm, void *vpn,if (pb &1 ) {uint32_t *a = vza_row +H1_4 (col);uint32_t *m = vzm +H1_4 (col); - *a =float32_muladd (n, *m, *a,0 , vst); + *a =float32_muladd (n, *m, *a,0 , &fpst); } col +=4 ; pb >>=4 ;
Signature · 1 line
2.43.0
Re: [PATCH 1/3] target/arm: Use float_status copy in sme_fmopa_s
Quoted 6 lines · Richard Henderson
From: Daniyal Khan <[email protected]>
We made a copy above because the fp exception flags are not propagated back to the FPST register, but then failed to use the copy.
Quoted 8 lines
Fixes 558e956c719 ("target/arm: Implement FMOPA, FMOPS (non-widening)")Signed-off-by Daniyal Khan <[email protected]>[rth: Split from a larger patch]Signed-off-by Richard Henderson <[email protected]>--- target/arm/tcg/sme_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Re: [PATCH 1/3] target/arm: Use float_status copy in sme_fmopa_s
In reply to Richard HendersonQuoted 11 lines · Richard Henderson
From: Daniyal Khan <[email protected]>
We made a copy above because the fp exception flags are not propagated back to the FPST register, but then failed to use the copy.
Fixes 558e956c719 ("target/arm: Implement FMOPA, FMOPS (non-widening)")Signed-off-by Daniyal Khan <[email protected]>[rth: Split from a larger patch]Signed-off-by Richard Henderson <[email protected]>
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
PATCH 2/3 target/arm: Use FPST_F16 for SME FMOPA (widening)
In reply to Richard HendersonThis operation has float16 inputs and thus must use the FZ16 control not the FZ control.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2374
--- target/arm/tcg/translate-sme.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
target/arm/tcg/translate-sme.c +8 -4
@@ -304,6 +304,7 @@ static bool do_outprod(DisasContext *s, arg_op *a, MemOp esz, }static bool do_outprod_fpst (DisasContext *s,arg_op *a,MemOp esz, +ARMFPStatusFlavour e_fpst,gen_helper_gvec_5_ptr *fn) {int svl =streaming_vec_reg_size (s);
@@ -319,15 +320,18 @@ static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz, zm =vec_full_reg_ptr (s, a->zm); pn =pred_full_reg_ptr (s, a->pn); pm =pred_full_reg_ptr (s, a->pm); - fpst =fpstatus_ptr (FPST_FPCR ); + fpst =fpstatus_ptr (e_fpst);fn (za, zn, zm, pn, pm, fpst,tcg_constant_i32 (desc));return true; } -TRANS_FEAT(FMOPA_h, aa64_sme, do_outprod_fpst, a, MO_32, gen_helper_sme_fmopa_h) -TRANS_FEAT(FMOPA_s, aa64_sme, do_outprod_fpst, a, MO_32, gen_helper_sme_fmopa_s) -TRANS_FEAT (FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a,MO_64 , gen_helper_sme_fmopa_d) +TRANS_FEAT (FMOPA_h, aa64_sme, do_outprod_fpst, a, + MO_32, FPST_FPCR_F16, gen_helper_sme_fmopa_h) +TRANS_FEAT (FMOPA_s, aa64_sme, do_outprod_fpst, a, + MO_32, FPST_FPCR, gen_helper_sme_fmopa_s) +TRANS_FEAT (FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a, +MO_64 ,FPST_FPCR , gen_helper_sme_fmopa_d) /* TODO: FEAT_EBF16 */TRANS_FEAT (BFMOPA , aa64_sme, do_outprod, a,MO_32 , gen_helper_sme_bfmopa)
Signature · 1 line
2.43.0
Re: [PATCH 2/3] target/arm: Use FPST_F16 for SME FMOPA (widening)
Quoted 10 lines · Richard Henderson
This operation has float16 inputs and thus must use the FZ16 control not the FZ control.
Reported-by Daniyal Khan <[email protected]>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2374
Signed-off-by Richard Henderson <[email protected]>--- target/arm/tcg/translate-sme.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
r~
Re: [PATCH 2/3] target/arm: Use FPST_F16 for SME FMOPA (widening)
In reply to Richard HendersonQuoted 7 lines · Richard Henderson
This operation has float16 inputs and thus must use the FZ16 control not the FZ control.
Reported-by Daniyal Khan <[email protected]>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2374
Signed-off-by Richard Henderson <[email protected]>
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
PATCH 3/3 tests/tcg/aarch64: Add test cases for SME FMOPA (widening)
In reply to Richard HendersonFrom: Daniyal Khan <[email protected]>
Message-Id: [email protected]
--- tests/tcg/aarch64/sme-fmopa-1.c | 63 +++++++++++++++++++++++++++++++ tests/tcg/aarch64/sme-fmopa-2.c | 51 +++++++++++++++++++++++++ tests/tcg/aarch64/sme-fmopa-3.c | 58 ++++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 5 ++- 4 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 tests/tcg/aarch64/sme-fmopa-1.c create mode 100644 tests/tcg/aarch64/sme-fmopa-2.c create mode 100644 tests/tcg/aarch64/sme-fmopa-3.c
tests/tcg/aarch64/sme-fmopa-1.c new file +63 -0
@@ -0,0 +1,63 @@ +/* +* SME outer product, 1 x 1. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include <stdio.h> + +static void foo (float *dst) +{ + asm(".arch_extension sme\n\t" +"smstart\n\t" +"ptrue p0.s, vl4\n\t" +"fmov z0.s, #1.0\n\t" +/* +* An outer product of a vector of 1.0 by itself should be a matrix of 1.0. +* Note that we are using tile 1 here (za1.s) rather than tile 0. +*/ +"zero {za}\n\t" +"fmopa za1.s, p0/m, p0/m, z0.s, z0.s\n\t" +/* +* Read the first 4x4 sub-matrix of elements from tile 1: +* Note that za1h should be interchangeable here. +*/ +"mov w12, #0\n\t" +"mova z0.s, p0/m, za1v.s[w12, #0]\n\t" +"mova z1.s, p0/m, za1v.s[w12, #1]\n\t" +"mova z2.s, p0/m, za1v.s[w12, #2]\n\t" +"mova z3.s, p0/m, za1v.s[w12, #3]\n\t" +/* +* And store them to the input pointer (dst in the C code): +*/ +"st1w {z0.s}, p0, [%0]\n\t" +"add x0, x0, #16\n\t" +"st1w {z1.s}, p0, [x0]\n\t" +"add x0, x0, #16\n\t" +"st1w {z2.s}, p0, [x0]\n\t" +"add x0, x0, #16\n\t" +"st1w {z3.s}, p0, [x0]\n\t" +"smstop" + : :"r" (dst) + :"x12" ,"d0" ,"d1" ,"d2" ,"d3" ,"memory" ); +} + +int main () +{ +float dst[16 ] = { }; + +foo (dst); + +for (int i =0 ; i <16 ; i++) { +if (dst[i] !=1.0f ) { + goto failure; + } + } +/* success */ +return 0 ; + + failure: +for (int i =0 ; i <16 ; i++) { +printf ("%f%c" , dst[i], i %4 ==3 ?'\n' :' ' ); + } +return 1 ; +}
tests/tcg/aarch64/sme-fmopa-2.c new file +51 -0
51 lines not on this page · raw message
tests/tcg/aarch64/sme-fmopa-3.c new file +58 -0
58 lines not on this page · raw message
tests/tcg/aarch64/Makefile.target +3 -2
@@ -70,8 +70,9 @@ endif # SME Tests ifneq ($(CROSS_AS_HAS_ARMV9_SME),) -AARCH64_TESTS += sme-outprod1 sme-smopa-1 sme-smopa-2 -sme-outprod1 sme-smopa-1 sme-smopa-2: CFLAGS += $(CROSS_AS_HAS_ARMV9_SME) +SME_TESTS = sme-outprod1 sme-smopa-1 sme-smopa-2 sme-fmopa-1 sme-fmopa-2 sme-fmopa-3 +AARCH64_TESTS += $(SME_TESTS) +$(SME_TESTS): CFLAGS += $(CROSS_AS_HAS_ARMV9_SME) endif # System Registers Tests
Signature · 1 line
2.43.0
Re: [PATCH 3/3] tests/tcg/aarch64: Add test cases for SME FMOPA (widening)
Quoted 6 lines · Richard Henderson
From: Daniyal Khan <[email protected]>
Signed-off-by Daniyal Khan <[email protected]>Message-Id: [email protected]
[rth: Split test cases to separate patch, tidy assembly.]Signed-off-by Richard Henderson <[email protected]>
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Re: [PATCH 3/3] tests/tcg/aarch64: Add test cases for SME FMOPA (widening)
In reply to Richard Hendersontests/tcg/aarch64/sme-fmopa-2.c line 2
Quoted 13 lines · Richard Henderson
From: Daniyal Khan <[email protected]>
Signed-off-by Daniyal Khan <[email protected]>Message-Id: [email protected]
[rth: Split test cases to separate patch, tidy assembly.]Signed-off-by Richard Henderson <[email protected]>tests/tcg/aarch64/sme-fmopa-2.c new file +2
-0@@ -0,0 +1,51 @@ +#include <stdint.h> +#include <stdio.h>
Can we have copyright-and-license header comments on all new files, please?
thanks
-- PMM