From 3fab99424af952787f4392796d87ed5debd34015 Mon Sep 17 00:00:00 2001 From: phani Date: Fri, 3 Jan 2020 10:51:27 -0500 Subject: [PATCH] fibonacci test update --- runtime/Makefile | 4 ++-- runtime/tests/Makefile | 22 +++++++++++--------- runtime/tests/Makefile.inc | 29 +++++++++++++++++++------- runtime/tests/fibonacci/get_time.h | 2 +- runtime/tests/fibonacci/main.c | 2 +- runtime/tests/fibonacci/run_fib.sh | 33 ++++++++++++++++++++++++++++++ 6 files changed, 71 insertions(+), 21 deletions(-) create mode 100755 runtime/tests/fibonacci/run_fib.sh diff --git a/runtime/Makefile b/runtime/Makefile index adbc922..b479fb6 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -44,7 +44,7 @@ else ifeq ($(USE_MEM),USE_MEM_VM) CFILES += ${RTDIR}/memory/64bit_nix.c endif -all: clean runtime tools +all: clean runtime #tools runtime: @echo "Compiling runtime" @@ -57,7 +57,7 @@ tools: clean: @rm -f core -# @echo "Cleaning up runtime" + @echo "Cleaning up runtime" @rm -f ${RUNTIME} # @echo "Cleaning up tools" @${MAKE} -C tools clean diff --git a/runtime/tests/Makefile b/runtime/tests/Makefile index 7bc4fd7..de00ce6 100644 --- a/runtime/tests/Makefile +++ b/runtime/tests/Makefile @@ -2,7 +2,7 @@ include Makefile.inc BENCH_DIR=../../silverfish/code_benches/ -TESTS=empty work +TESTS=fibonacci #empty work #TESTS=forever filesys sockserver sockclient empty TESTSRT=$(TESTS:%=%_rt) BENCHES=adpcm basic_math binarytrees bitcount blowfish crc dijkstra fft function_pointers \ @@ -30,23 +30,25 @@ rttests: $(TESTSRT) clean: @rm -rf ${TMP_DIR} - @rm -f ${BIN_DIR}/*_wasm.so + #@rm -f ${BIN_DIR}/*_wasm.so %_sf: @mkdir -p ${TMP_DIR} @echo "Compiling $(@:%_sf=%)" - ${WASMCC} ${$(@:%_sf=%)_CFLAGS} ${WASMCFLAGS} ${OPTFLAGS} ${BENCH_DIR}/$(@:%_sf=%)/*.c -o ${TMP_DIR}/$(@:%_sf=%).wasm + ${WASMCC} ${$(@:%_sf=%)_CFLAGS} ${WASMCFLAGS} ${OPTFLAGS} ${BENCH_DIR}/$(@:%_sf=%)/*.c $(DUMMY) -o ${TMP_DIR}/$(@:%_sf=%).wasm ${SFCC} ${TMP_DIR}/$(@:%_sf=%).wasm -o ${TMP_DIR}/$(@:%_sf=%).bc - ${CC} --shared -fPIC ${OPTFLAGS} -I${RT_INC} -D${USE_MEM} ${TMP_DIR}/$(@:%_sf=%).bc ${MEMC} ${WASMISA} -o ${TMP_DIR}/$(@:%_sf=%)_wasm.so - @cp ${TMP_DIR}/$(@:%_sf=%)_wasm.so ${BIN_DIR} - @rm -rf ${TMP_DIR} + ${CC} ${CFLAGS} ${OPTFLAGS} -D${USE_MEM} ${TMP_DIR}/$(@:%_sf=%).bc ${MEMC} ${RT_LIBC} ${RT_RT} -o ${TMP_DIR}/$(@:%_sf=%)_wasm.out + ${CC} --shared -fPIC ${OPTFLAGS} -I${ART_INC} -D${USE_MEM} ${TMP_DIR}/$(@:%_sf=%).bc ${AMEMC} ${WASMISA} -o ${TMP_DIR}/$(@:%_sf=%)_wasm.so + @cp ${TMP_DIR}/$(@:%_sf=%)_wasm.so ${ABIN_DIR} +# @rm -rf ${TMP_DIR} %_rt: @mkdir -p ${TMP_DIR} @echo "Compiling $(@:%_rt=%)" - ${WASMCC} ${$(@:%_rt=%)_CFLAGS} ${WASMCFLAGS} ${OPTFLAGS} $(@:%_rt=%)/*.c -o ${TMP_DIR}/$(@:%_rt=%).wasm + ${WASMCC} ${$(@:%_rt=%)_CFLAGS} ${WASMCFLAGS} ${OPTFLAGS} $(@:%_rt=%)/*.c $(DUMMY) -o ${TMP_DIR}/$(@:%_rt=%).wasm ${SFCC} ${TMP_DIR}/$(@:%_rt=%).wasm -o ${TMP_DIR}/$(@:%_rt=%).bc - ${CC} --shared -fPIC ${OPTFLAGS} -I${RT_INC} -D${USE_MEM} ${TMP_DIR}/$(@:%_rt=%).bc ${MEMC} ${WASMISA} -o ${TMP_DIR}/$(@:%_rt=%)_wasm.so - @cp ${TMP_DIR}/$(@:%_rt=%)_wasm.so ${BIN_DIR} - @rm -rf ${TMP_DIR} + ${CC} ${CFLAGS} ${OPTFLAGS} -D${USE_MEM} ${TMP_DIR}/$(@:%_rt=%).bc ${MEMC} ${RT_LIBC} ${RT_RT} -o ${TMP_DIR}/$(@:%_rt=%)_wasm.out + ${CC} --shared -fPIC ${OPTFLAGS} -I${ART_INC} -D${USE_MEM} ${TMP_DIR}/$(@:%_rt=%).bc ${AMEMC} ${WASMISA} -o ${TMP_DIR}/$(@:%_rt=%)_wasm.so + @cp ${TMP_DIR}/$(@:%_rt=%)_wasm.so ${ABIN_DIR} +# @rm -rf ${TMP_DIR} diff --git a/runtime/tests/Makefile.inc b/runtime/tests/Makefile.inc index cfbfe07..eaad215 100644 --- a/runtime/tests/Makefile.inc +++ b/runtime/tests/Makefile.inc @@ -8,17 +8,32 @@ OPTFLAGS=-O3 -flto WASMLINKFLAGS=-Wl,-z,stack-size=524288,--allow-undefined,--no-threads,--stack-first,--no-entry,--export-all,--export=main,--export=dummy WASMCFLAGS=${WASMLINKFLAGS} -nostartfiles -BASE_DIR=../../ +MEMC_64=64bit_nix.c +MEMC_NO=no_protection.c +MEMC_GEN=generic.c +MEMC_MPX=mpx.c +MEMC_SEG=segmented.c + +BASE_DIR=../../silverfish/ RT_DIR=${BASE_DIR}/runtime/ -RT_INC=${RT_DIR}/include/ +RT_MEM=${RT_DIR}/memory/ +RT_LIBC=${RT_DIR}/libc/libc_backing.c +RT_RT=${RT_DIR}/runtime.c -USE_MEM=USE_MEM_VM +MEMC=${RT_MEM}/${MEMC_64} +DUMMY=${BASE_DIR}/code_benches/dummy.c + +# for awsm +ABASE_DIR=../../ +ART_DIR=${ABASE_DIR}/runtime/ +ART_INC=${ART_DIR}/include/ +USE_MEM=USE_MEM_VM ifeq ($(USE_MEM),USE_MEM_VM) -MEMC=${RT_DIR}/compiletime/memory/64bit_nix.c +AMEMC=${ART_DIR}/compiletime/memory/${MEMC_64} endif +WASMISA=${ART_DIR}/compiletime/instr.c -WASMISA=${RT_DIR}/compiletime/instr.c - -BIN_DIR=${RT_DIR}/bin/ +ABIN_DIR=${ART_DIR}/bin/ TMP_DIR=tmp/ + diff --git a/runtime/tests/fibonacci/get_time.h b/runtime/tests/fibonacci/get_time.h index 8312a56..a032ef1 100644 --- a/runtime/tests/fibonacci/get_time.h +++ b/runtime/tests/fibonacci/get_time.h @@ -37,7 +37,7 @@ print_time(unsigned long long s, unsigned long long e) #if 0 printf("%llu cycs, %llu us\n", e - s, (e - s) / CPU_FREQ); #else - fprintf(stderr, "%llu us\n", e - s); + fprintf(stdout, "%llu us\n", e - s); #endif } diff --git a/runtime/tests/fibonacci/main.c b/runtime/tests/fibonacci/main.c index c622a98..b271cb5 100644 --- a/runtime/tests/fibonacci/main.c +++ b/runtime/tests/fibonacci/main.c @@ -16,7 +16,7 @@ main(int argc, char **argv) unsigned long long st = get_time(), en; r = fib(n); en = get_time(); - printf("%lu\n", r); + fprintf(stderr, "%lu\n", r); print_time(st, en); return 0; diff --git a/runtime/tests/fibonacci/run_fib.sh b/runtime/tests/fibonacci/run_fib.sh new file mode 100755 index 0000000..3e9439b --- /dev/null +++ b/runtime/tests/fibonacci/run_fib.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +ITERS=$3 + +# before running this benchmark, +# copy fibonacci to fibonacci_native.out + +testeach() +{ + tmp_cnt=${ITERS} + exe_relpath=$1 + + echo "${exe_relpath} ($2) for ${tmp_cnt}" + + while [ ${tmp_cnt} -gt 0 ]; do + bench=$(echo $2 | $exe_relpath 2>/dev/null) + tmp_cnt=$((tmp_cnt - 1)) + echo "$bench" + done + + echo "Done!" +} + +MAXNUM=$2 + +tmp1_cnt=${MAXNUM} + +while [ ${tmp1_cnt} -gt 0 ]; do + testeach ./fibonacci_$1.out ${tmp1_cnt} + tmp1_cnt=$((tmp1_cnt - 1)) +done + +echo "All done!"