From c13c57b5a63e4ea0b8576244901b6ed22c10afe5 Mon Sep 17 00:00:00 2001 From: Jordan Carlin Date: Wed, 18 Sep 2024 17:37:02 -0700 Subject: [PATCH] Refactor floating point testvector Makefile to split up RISCV and IEEE due to Make issues --- tests/fp/vectors/{ => ieee}/Makefile | 22 +++++---- tests/fp/vectors/riscv/Makefile | 74 ++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 9 deletions(-) rename tests/fp/vectors/{ => ieee}/Makefile (78%) create mode 100755 tests/fp/vectors/riscv/Makefile diff --git a/tests/fp/vectors/Makefile b/tests/fp/vectors/ieee/Makefile similarity index 78% rename from tests/fp/vectors/Makefile rename to tests/fp/vectors/ieee/Makefile index 8ef4724ad..5b8280ef2 100755 --- a/tests/fp/vectors/Makefile +++ b/tests/fp/vectors/ieee/Makefile @@ -1,8 +1,13 @@ .DELETE_ON_ERROR: +.SECONDEXPANSION: +.ONESHELL: +# MAKEFLAGS += --no-print-directory + SHELL := /bin/bash -TESTFLOAT_DIR := ${WALLY}/addins/berkeley-testfloat-3/build/Linux-x86_64-GCC -TESTFLOAT_GEN_CMD := ${TESTFLOAT_DIR}/testfloat_gen -tininessafter +VECTOR_TYPE := ieee +TESTFLOAT_DIR := ${WALLY}/tests/fp/testfloat +TESTFLOAT_GEN := ${TESTFLOAT_DIR}/${VECTOR_TYPE}/testfloat_gen # 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 \ @@ -43,7 +48,6 @@ 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 @@ -55,15 +59,15 @@ rnm: $(addsuffix _rnm.tv, $(tests)) # 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 $$level $$exact -$(ROUND_MODE) $(patsubst %_$(ROUND_EXT).tv, %, $@) > $@ + @echo "Creating $(VECTOR_TYPE) $@ vectors" + @if [[ "$*" =~ "to" ]] || [[ "$*" =~ "sqrt" ]] ; then level=2 ; else level=1 ; fi + @if [[ "$*" =~ "to_i" ]] || [[ "$*" =~ "to_u" ]] ; then exact="-exact" ; else exact="" ; fi + ${TESTFLOAT_GEN} -tininessafter -level $$level $$exact -$(ROUND_MODE) $(patsubst %_$(ROUND_EXT).tv, %, $@) > $@ @sed -i 's/ /_/g' $@ -# Generate TestFloat first if necessary +# Appropriate testfloat_gen must exist ${TESTFLOAT_GEN}: - $(MAKE) -C ${WALLY}/tests/fp testfloat + $(MAKE) -C ${TESTFLOAT_DIR} ${VECTOR_TYPE} clean: rm -f *.tv diff --git a/tests/fp/vectors/riscv/Makefile b/tests/fp/vectors/riscv/Makefile new file mode 100755 index 000000000..fe3d029ee --- /dev/null +++ b/tests/fp/vectors/riscv/Makefile @@ -0,0 +1,74 @@ +.DELETE_ON_ERROR: +.SECONDEXPANSION: +.ONESHELL: +# MAKEFLAGS += --no-print-directory + +SHELL := /bin/bash + +VECTOR_TYPE := riscv +TESTFLOAT_DIR := ${WALLY}/tests/fp/testfloat +TESTFLOAT_GEN := ${TESTFLOAT_DIR}/${VECTOR_TYPE}/testfloat_gen + +# 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 \ + 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 +div := f16_div f32_div f64_div f128_div +sqrt := f16_sqrt f32_sqrt f64_sqrt f128_sqrt +eq := f16_eq f32_eq f64_eq f128_eq +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 := $(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 + +all: rne rz ru rd rnm + +# Generate test vectors for each rounding mode +rne: $(addsuffix _rne.tv, $(tests)) +rz: $(addsuffix _rz.tv, $(tests)) +ru: $(addsuffix _ru.tv, $(tests)) +rd: $(addsuffix _rd.tv, $(tests)) +rnm: $(addsuffix _rnm.tv, $(tests)) + +# Rule to generate individual test vectors +%.tv: ${TESTFLOAT_GEN} + @echo "Creating $(VECTOR_TYPE) $@ vectors" + @if [[ "$*" =~ "to" ]] || [[ "$*" =~ "sqrt" ]] ; then level=2 ; else level=1 ; fi + @if [[ "$*" =~ "to_i" ]] || [[ "$*" =~ "to_u" ]] ; then exact="-exact" ; else exact="" ; fi + ${TESTFLOAT_GEN} -tininessafter -level $$level $$exact -$(ROUND_MODE) $(patsubst %_$(ROUND_EXT).tv, %, $@) > $@ + @sed -i 's/ /_/g' $@ + +# Appropriate testfloat_gen must exist +${TESTFLOAT_GEN}: + $(MAKE) -C ${TESTFLOAT_DIR} ${VECTOR_TYPE} + +clean: + rm -f *.tv + rm -f sed*