From ec8302d597645450e01484658c171f6a1655c2e5 Mon Sep 17 00:00:00 2001 From: Jordan Carlin Date: Sat, 14 Sep 2024 20:11:09 -0700 Subject: [PATCH 1/3] Split up cvtint and cvtfp tests --- tests/fp/vectors/Makefile | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/fp/vectors/Makefile b/tests/fp/vectors/Makefile index 8d61c85ef..cbd111aa5 100755 --- a/tests/fp/vectors/Makefile +++ b/tests/fp/vectors/Makefile @@ -5,18 +5,18 @@ TESTFLOAT_DIR := ${WALLY}/addins/TestFloat-3e/build/Linux-x86_64-GCC TESTFLOAT_GEN_CMD := ${TESTFLOAT_DIR}/testfloat_gen -tininessafter -level # List of testvectors to generate. Each rounding mode will be generated for each test. -convert := ui32_to_f16 ui32_to_f32 ui32_to_f64 ui32_to_f128 \ - ui64_to_f16 ui64_to_f32 ui64_to_f64 ui64_to_f128 \ - i32_to_f16 i32_to_f32 i32_to_f64 i32_to_f128 \ - i64_to_f16 i64_to_f32 i64_to_f64 i64_to_f128 \ - f16_to_ui32 f32_to_ui32 f64_to_ui32 f128_to_ui32 \ - f16_to_ui64 f32_to_ui64 f64_to_ui64 f128_to_ui64 \ - f16_to_i32 f32_to_i32 f64_to_i32 f128_to_i32 \ - f16_to_i64 f32_to_i64 f64_to_i64 f128_to_i64 \ - f16_to_f32 f16_to_f64 f16_to_f128 \ - f32_to_f16 f32_to_f64 f32_to_f128 \ - f64_to_f16 f64_to_f32 f64_to_f128 \ - f128_to_f16 f128_to_f32 f128_to_f64 +cvtint := ui32_to_f16 ui32_to_f32 ui32_to_f64 ui32_to_f128 \ + ui64_to_f16 ui64_to_f32 ui64_to_f64 ui64_to_f128 \ + i32_to_f16 i32_to_f32 i32_to_f64 i32_to_f128 \ + i64_to_f16 i64_to_f32 i64_to_f64 i64_to_f128 \ + f16_to_ui32 f32_to_ui32 f64_to_ui32 f128_to_ui32 \ + f16_to_ui64 f32_to_ui64 f64_to_ui64 f128_to_ui64 +cvtfp := f16_to_i32 f32_to_i32 f64_to_i32 f128_to_i32 \ + f16_to_i64 f32_to_i64 f64_to_i64 f128_to_i64 \ + f16_to_f32 f16_to_f64 f16_to_f128 \ + f32_to_f16 f32_to_f64 f32_to_f128 \ + f64_to_f16 f64_to_f32 f64_to_f128 \ + f128_to_f16 f128_to_f32 f128_to_f64 add := f16_add f32_add f64_add f128_add sub := f16_sub f32_sub f64_sub f128_sub mul := f16_mul f32_mul f64_mul f128_mul From d2ef362761fc856eb4dbf9648bdd541b9c020aae Mon Sep 17 00:00:00 2001 From: Jordan Carlin Date: Sat, 14 Sep 2024 20:16:28 -0700 Subject: [PATCH 2/3] Fix testfloat cvtint generation --- tests/fp/vectors/Makefile | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/fp/vectors/Makefile b/tests/fp/vectors/Makefile index cbd111aa5..6a20ec813 100755 --- a/tests/fp/vectors/Makefile +++ b/tests/fp/vectors/Makefile @@ -27,7 +27,7 @@ le := f16_le f32_le f64_le f128_le lt := f16_lt f32_lt f64_lt f128_lt mulAdd := f16_mulAdd f32_mulAdd f64_mulAdd f128_mulAdd -tests := $(convert) $(add) $(sub) $(mul) $(div) $(sqrt) $(eq) $(le) $(lt) $(mulAdd) +tests := $(cvtfp) $(cvtint) $(add) $(sub) $(mul) $(div) $(sqrt) $(eq) $(le) $(lt) $(mulAdd) .PHONY: all rne rz ru rd rnm clean @@ -45,31 +45,36 @@ rnm: $(addsuffix _rnm.tv, $(tests)) %_rne.tv: ${TESTFLOAT_GEN} @echo Creating $*_rne.tv vectors @if [[ "$*" =~ "to" ]] || [[ "$*" =~ "sqrt" ]] ; then level=2 ; else level=1 ; fi ; \ - ${TESTFLOAT_GEN_CMD} $$level -rnear_even $* > $@ + if [[ "$*" =~ "to_i" ]] || [[ "$*" =~ "to_u" ]] ; then exact="-exact" ; else exact="" ; fi ; \ + ${TESTFLOAT_GEN_CMD} $$level $$exact -rnear_even $* > $@ @sed -i 's/ /_/g' $@ %_rz.tv: ${TESTFLOAT_GEN} @echo Creating $*_rz.tv vectors @if [[ "$*" =~ "to" ]] || [[ "$*" =~ "sqrt" ]] ; then level=2 ; else level=1 ; fi ; \ - ${TESTFLOAT_GEN_CMD} $$level -rminMag $* > $@ + if [[ "$*" =~ "to_i" ]] || [[ "$*" =~ "to_u" ]] ; then exact="-exact" ; else exact="" ; fi ; \ + ${TESTFLOAT_GEN_CMD} $$level $$exact -rminMag $* > $@ @sed -i 's/ /_/g' $@ %_ru.tv: ${TESTFLOAT_GEN} @echo Creating $*_ru.tv vectors @if [[ "$*" =~ "to" ]] || [[ "$*" =~ "sqrt" ]] ; then level=2 ; else level=1 ; fi ; \ - ${TESTFLOAT_GEN_CMD} $$level -rmax $* > $@ + if [[ "$*" =~ "to_i" ]] || [[ "$*" =~ "to_u" ]] ; then exact="-exact" ; else exact="" ; fi ; \ + ${TESTFLOAT_GEN_CMD} $$level $$exact -rmax $* > $@ @sed -i 's/ /_/g' $@ %_rd.tv: ${TESTFLOAT_GEN} @echo Creating $*_rd.tv vectors @if [[ "$*" =~ "to" ]] || [[ "$*" =~ "sqrt" ]] ; then level=2 ; else level=1 ; fi ; \ - ${TESTFLOAT_GEN_CMD} $$level -rmin $* > $@ + if [[ "$*" =~ "to_i" ]] || [[ "$*" =~ "to_u" ]] ; then exact="-exact" ; else exact="" ; fi ; \ + ${TESTFLOAT_GEN_CMD} $$level $$exact -rmin $* > $@ @sed -i 's/ /_/g' $@ %_rnm.tv: ${TESTFLOAT_GEN} @echo Creating $*_rnm.tv vectors @if [[ "$*" =~ "to" ]] || [[ "$*" =~ "sqrt" ]] ; then level=2 ; else level=1 ; fi ; \ - ${TESTFLOAT_GEN_CMD} $$level -rnear_maxMag $* > $@ + if [[ "$*" =~ "to_i" ]] || [[ "$*" =~ "to_u" ]] ; then exact="-exact" ; else exact="" ; fi ; \ + ${TESTFLOAT_GEN_CMD} $$level $$exact -rnear_maxMag $* > $@ @sed -i 's/ /_/g' $@ # Generate TestFloat first if necessary From f7b93ac7009976191b14c196df4cc56d70df6182 Mon Sep 17 00:00:00 2001 From: Jordan Carlin Date: Sat, 14 Sep 2024 20:59:00 -0700 Subject: [PATCH 3/3] More simplification of fp testvector makefile --- tests/fp/vectors/Makefile | 50 +++++++++++++-------------------------- 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/tests/fp/vectors/Makefile b/tests/fp/vectors/Makefile index 6a20ec813..7f464f2e6 100755 --- a/tests/fp/vectors/Makefile +++ b/tests/fp/vectors/Makefile @@ -2,7 +2,7 @@ SHELL := /bin/bash TESTFLOAT_DIR := ${WALLY}/addins/TestFloat-3e/build/Linux-x86_64-GCC -TESTFLOAT_GEN_CMD := ${TESTFLOAT_DIR}/testfloat_gen -tininessafter -level +TESTFLOAT_GEN_CMD := ${TESTFLOAT_DIR}/testfloat_gen -tininessafter # List of testvectors to generate. Each rounding mode will be generated for each test. cvtint := ui32_to_f16 ui32_to_f32 ui32_to_f64 ui32_to_f128 \ @@ -29,9 +29,21 @@ mulAdd := f16_mulAdd f32_mulAdd f64_mulAdd f128_mulAdd tests := $(cvtfp) $(cvtint) $(add) $(sub) $(mul) $(div) $(sqrt) $(eq) $(le) $(lt) $(mulAdd) +# Set rounding modes and extensions +rne: ROUND_MODE := rnear_even +rne: ROUND_EXT := rne +rz: ROUND_MODE := rminMag +rz: ROUND_EXT := rz +ru: ROUND_MODE := rmax +ru: ROUND_EXT := ru +rd: ROUND_MODE := rmin +rd: ROUND_EXT := rd +rnm: ROUND_MODE := rnear_maxMag +rnm: ROUND_EXT := rnm .PHONY: all rne rz ru rd rnm clean +# Generate all test vectors all: rne rz ru rd rnm # Generate test vectors for each rounding mode @@ -41,40 +53,12 @@ ru: $(addsuffix _ru.tv, $(tests)) rd: $(addsuffix _rd.tv, $(tests)) rnm: $(addsuffix _rnm.tv, $(tests)) -# Rules to generate individual test vectors, broken up by rounding mode -%_rne.tv: ${TESTFLOAT_GEN} - @echo Creating $*_rne.tv vectors +# Rule to generate individual test vectors +%.tv: ${TESTFLOAT_GEN} + @echo Creating $@ vectors @if [[ "$*" =~ "to" ]] || [[ "$*" =~ "sqrt" ]] ; then level=2 ; else level=1 ; fi ; \ if [[ "$*" =~ "to_i" ]] || [[ "$*" =~ "to_u" ]] ; then exact="-exact" ; else exact="" ; fi ; \ - ${TESTFLOAT_GEN_CMD} $$level $$exact -rnear_even $* > $@ - @sed -i 's/ /_/g' $@ - -%_rz.tv: ${TESTFLOAT_GEN} - @echo Creating $*_rz.tv vectors - @if [[ "$*" =~ "to" ]] || [[ "$*" =~ "sqrt" ]] ; then level=2 ; else level=1 ; fi ; \ - if [[ "$*" =~ "to_i" ]] || [[ "$*" =~ "to_u" ]] ; then exact="-exact" ; else exact="" ; fi ; \ - ${TESTFLOAT_GEN_CMD} $$level $$exact -rminMag $* > $@ - @sed -i 's/ /_/g' $@ - -%_ru.tv: ${TESTFLOAT_GEN} - @echo Creating $*_ru.tv vectors - @if [[ "$*" =~ "to" ]] || [[ "$*" =~ "sqrt" ]] ; then level=2 ; else level=1 ; fi ; \ - if [[ "$*" =~ "to_i" ]] || [[ "$*" =~ "to_u" ]] ; then exact="-exact" ; else exact="" ; fi ; \ - ${TESTFLOAT_GEN_CMD} $$level $$exact -rmax $* > $@ - @sed -i 's/ /_/g' $@ - -%_rd.tv: ${TESTFLOAT_GEN} - @echo Creating $*_rd.tv vectors - @if [[ "$*" =~ "to" ]] || [[ "$*" =~ "sqrt" ]] ; then level=2 ; else level=1 ; fi ; \ - if [[ "$*" =~ "to_i" ]] || [[ "$*" =~ "to_u" ]] ; then exact="-exact" ; else exact="" ; fi ; \ - ${TESTFLOAT_GEN_CMD} $$level $$exact -rmin $* > $@ - @sed -i 's/ /_/g' $@ - -%_rnm.tv: ${TESTFLOAT_GEN} - @echo Creating $*_rnm.tv vectors - @if [[ "$*" =~ "to" ]] || [[ "$*" =~ "sqrt" ]] ; then level=2 ; else level=1 ; fi ; \ - if [[ "$*" =~ "to_i" ]] || [[ "$*" =~ "to_u" ]] ; then exact="-exact" ; else exact="" ; fi ; \ - ${TESTFLOAT_GEN_CMD} $$level $$exact -rnear_maxMag $* > $@ + ${TESTFLOAT_GEN_CMD} -level $$level $$exact -$(ROUND_MODE) $(patsubst %_$(ROUND_EXT).tv, %, $@) > $@ @sed -i 's/ /_/g' $@ # Generate TestFloat first if necessary