Merge pull request #285 from gwsystems/tests-makefile-cleanup

build: Makefile cleanup
master
Sean McBride 3 years ago committed by GitHub
commit b841889846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -101,7 +101,7 @@ jobs:
uses: actions/cache@v2
with:
path: ./runtime/bin/gocr_wasm.so
key: ${{ runner.os }}-gocr2-${{ hashFiles('./runtime/tests/gocr/**', './runtime/compiletime/**') }}
key: ${{ runner.os }}-gocr2-${{ hashFiles('./runtime/tests/Makefile', './runtime/tests/gocr/**', './runtime/compiletime/**', './runtime/compiletime/memory/**') }}
if: success() || failure()
- name: Hyde
run: |
@ -138,7 +138,7 @@ jobs:
uses: actions/cache@v2
with:
path: ./runtime/bin/ekf_wasm.so
key: ${{ runner.os }}-gocr2-${{ hashFiles('./runtime/tests/TinyEKF/**', './runtime/compiletime/**') }}
key: ${{ runner.os }}-gocr2-${{ hashFiles('./runtime/tests/Makefile', './runtime/tests/TinyEKF/**', './runtime/compiletime/**', './runtime/compiletime/memory/**') }}
if: success() || failure()
- name: EKF one iteration
run: |

@ -1,6 +1,7 @@
#include <assert.h>
#include <math.h>
#include <types.h>
#include "types.h"
#define CHAR_BIT 8

@ -0,0 +1,3 @@
*.wasm
*.bc
*.so

@ -1,60 +1,84 @@
include Makefile.inc
AWSMCC=awsm
CC=clang
TESTS=fibonacci empty empty
OPTFLAGS=-O3 -flto
TESTSRT=$(TESTS:%=%_rt)
# Compiletime Components to link into *.so
SLEDGE_BASE_DIR=../../
SLEDGE_RT_DIR=${SLEDGE_BASE_DIR}/runtime/
SLEDGE_COMPILETIME_INC=${SLEDGE_RT_DIR}/include
SLEDGE_COMPILETIME_SRC=${SLEDGE_RT_DIR}/compiletime/instr.c ${SLEDGE_RT_DIR}/compiletime/memory/64bit_nix.c
.PHONY: all
all: rttests tinyekf cifar10 gocr sod
@echo "Test Compilation done!"
ALL=fibonacci empty ekf cifar10 gocr lpd resize
ALL_COPY_DEST=$(ALL:%=../../runtime/bin/%_wasm.so)
.PHONY: rttests
rttests: $(TESTSRT)
.PHONY: all
all: $(ALL_COPY_DEST)
.PHONY: clean
clean:
@echo "Cleaning Test Applications"
@rm -rf ${TMP_DIR}
@make clean -C ./fibonacci
@make clean -C ./empty
@make clean -C ./TinyEKF/extras/c/ -f wasm.mk
@make clean -C ./CMSIS_5_NN/ -f Makefile
@make clean -C ./gocr/src/ -f wasm.mk
@make clean -C ./sod/
@rm -f ../../runtime/bin/*.so
fibonacci.wasm:
@make fibonacci.wasm -C ./fibonacci
@cp ./fibonacci/fibonacci.wasm fibonacci.wasm
empty.wasm:
@make empty.wasm -C ./empty
@cp ./empty/empty.wasm empty.wasm
ekf.wasm:
@make gps_ekf_fn.wasm -C ./TinyEKF/extras/c/ -f wasm.mk
@cp ./TinyEKF/extras/c/gps_ekf_fn.wasm ekf.wasm
cifar10.wasm:
@make cifar10.wasm -C ./CMSIS_5_NN/ -f Makefile
@cp ./CMSIS_5_NN/cifar10.wasm cifar10.wasm
gocr.wasm:
@make gocr.wasm -C ./gocr/src/ -f wasm.mk
@cp ./gocr/src/gocr.wasm gocr.wasm
lpd.wasm:
@make dir license_plate_detection.wasm -C ./sod/
@cp ./sod/bin/license_plate_detection.wasm lpd.wasm
resize.wasm:
@make dir resize_image.wasm -C ./sod/
@cp ./sod/bin/resize_image.wasm resize.wasm
%.bc: %.wasm
${AWSMCC} --inline-constant-globals --runtime-globals $^ -o $@
%_wasm.so: %.bc ${SLEDGE_COMPILETIME_SRC}
${CC} --shared -fPIC ${OPTFLAGS} -I${SLEDGE_COMPILETIME_INC} $^ -o $@
../../runtime/bin/%.so: %.so
cp $^ $@
.PHONY: fibonacci.install
fibonacci.install: ../../runtime/bin/fibonacci_wasm.so
.PHONY: empty.install
empty.install: ../../runtime/bin/empty_wasm.so
.PHONY: ekf.install
ekf.install: ../../runtime/bin/ekf_wasm.so
.PHONY: cifar10.install
cifar10.install: ../../runtime/bin/cifar10_wasm.so
.PHONY: gocr.install
gocr.install: ../../runtime/bin/gocr_wasm.so
.PHONY: tinyekf
tinyekf:
@echo "Making and Installing tinyekf"
@make gps_ekf_fn.so -C ./TinyEKF/extras/c/ -f wasm.mk
@cp ./TinyEKF/extras/c/gps_ekf_fn.so ${SLEDGE_BIN_DIR}/ekf_wasm.so
.PHONY: cifar10
cifar10:
@echo "Making and Installing cifar10"
@make cifar10.so -C ./CMSIS_5_NN/ -f Makefile
@cp ./CMSIS_5_NN/cifar10.so ${SLEDGE_BIN_DIR}/cifar10_wasm.so
.PHONY: gocr
gocr:
@echo "Making and Installing gocr"
@make gocr.so -C ./gocr/src/ -f wasm.mk
@cp ./gocr/src/gocr.so ${SLEDGE_BIN_DIR}/gocr_wasm.so
.PHONY: sod
sod:
@echo "Making and Installing license_plate_detection and image_resize"
@make dir samples.so -C ./sod/
@cp ./sod/bin/license_plate_detection.so ${SLEDGE_BIN_DIR}/lpd_wasm.so
@cp ./sod/bin/resize_image.so ${SLEDGE_BIN_DIR}/resize_wasm.so
%_rt:
@mkdir -p ${TMP_DIR}
# Compile the wasm file
@echo "Compiling $(@:%_rt=%)"
${WASMCC} ${$(@:%_rt=%)_CFLAGS} ${WASMCFLAGS} ${OPTFLAGS} $(@:%_rt=%)/*.c $(AWSM_DUMMY) -o ${TMP_DIR}/$(@:%_rt=%).wasm
# Compile the *.bc file
${AWSM_NAME} --inline-constant-globals --runtime-globals ${TMP_DIR}/$(@:%_rt=%).wasm -o ${TMP_DIR}/$(@:%_rt=%).bc
# Compile the *.so file
${CC} --shared -fPIC ${OPTFLAGS} -I${SLEDGE_RT_INC} -D${USE_MEM} ${TMP_DIR}/$(@:%_rt=%).bc ${SLEDGE_MEMC} ${SLEDGE_WASMISA} -o ${TMP_DIR}/$(@:%_rt=%)_wasm.so
# Copy the *.so file to the binary directory
@cp ${TMP_DIR}/$(@:%_rt=%)_wasm.so ${SLEDGE_BIN_DIR}
# @rm -rf ${TMP_DIR}
.PHONY: lpd.install
lpd.install: ../../runtime/bin/lpd_wasm.so
.PHONY: resize.install
resize.install: ../../runtime/bin/resize_wasm.so

@ -1,42 +0,0 @@
ARCH := $(shell uname -m)
CC=clang # Source -> Native
WASMCC=wasm32-unknown-unknown-wasm-clang # Source -> WebAssembly
OPTFLAGS=-O3 -flto
MEMC_64=64bit_nix.c
# MEMC_NO=no_protection.c
# MEMC_GEN=generic.c
# MEMC_MPX=mpx.c
# MEMC_SEG=segmented.c
TMP_DIR=tmp/
# same stack-size for all
WASMLINKFLAGS=-Wl,-z,stack-size=524288,--allow-undefined,--no-threads,--stack-first,--no-entry,--export-all,--export=main,--export=dummy
WASMCFLAGS=${WASMLINKFLAGS} -nostartfiles
# aWsm Compiler Runtime (WebAssembly -> LLVM Bitcode)
AWSM_NAME=awsm
AWSM_BASE_DIR=../../${AWSM_NAME}
AWSM_RT_DIR=${AWSM_BASE_DIR}/runtime/
AWSM_RT_MEM=${AWSM_RT_DIR}/memory/
AWSM_RT_LIBC=${AWSM_RT_DIR}/libc/libc_backing.c
AWSM_RT_RT=${AWSM_RT_DIR}/runtime.c
AWSM_RT_ENV=${AWSM_RT_DIR}/libc/env.c
# Is seems like the arch specific code no longer exists
# AWSM_RT_ENV=${AWSM_RT_DIR}/libc/env.c ${AWSM_RT_DIR}/libc/env_${ARCH}.c
AWSM_MEMC=${AWSM_RT_MEM}/${MEMC_64}
AWSM_DUMMY=${AWSM_BASE_DIR}/code_benches/dummy.c
# for SLEdge
SLEDGE_BASE_DIR=../../
SLEDGE_RT_DIR=${SLEDGE_BASE_DIR}/runtime/
SLEDGE_RT_INC=${SLEDGE_RT_DIR}/include/
SLEDGE_BIN_DIR=${SLEDGE_RT_DIR}/bin/
SLEDGE_WASMISA=${SLEDGE_RT_DIR}/compiletime/instr.c
USE_MEM=USE_MEM_VM
ifeq ($(USE_MEM),USE_MEM_VM)
SLEDGE_MEMC=${SLEDGE_RT_DIR}/compiletime/memory/${MEMC_64}
endif

@ -1 +1 @@
Subproject commit fe4d4600a3b02f313b74892990595354dfc98913
Subproject commit 8c2654d622e39b0eee84a3fd00174c2cfb5996ee

@ -0,0 +1,12 @@
WASMCC=wasm32-unknown-unknown-wasm-clang
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
all: empty.wasm
clean:
rm -rf empty.wasm
empty.wasm: *.c
${WASMCC} ${WASMCFLAGS} ${OPTFLAGS} $^ -o $@

@ -0,0 +1,15 @@
// !!! HACK ALERT !!!
// We need the __init_libc symbol in the output executable (so the runtime can initialize libc)
// We can't directly export it since it's in a linked library
// Thus we export a dummy function that uses it, forcing it to be included
#define IMPORT __attribute__((visibility("default")))
#define EXPORT __attribute__((visibility("default")))
IMPORT void __init_libc(char **, char *);
EXPORT void
dummy()
{
__init_libc(0, 0);
}

@ -0,0 +1,12 @@
WASMCC=wasm32-unknown-unknown-wasm-clang
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
all: fibonacci.wasm
clean:
rm -rf fibonacci.wasm
fibonacci.wasm: *.c
${WASMCC} ${WASMCFLAGS} ${OPTFLAGS} $^ -o $@

@ -1,44 +0,0 @@
#ifndef GET_TIME_H
#define GET_TIME_H
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
#ifndef WASM
#ifndef CPU_FREQ
#define CPU_FREQ 1000
#endif
#endif
static unsigned long long
get_time()
{
#if 0
unsigned long long int ret = 0;
unsigned int cycles_lo;
unsigned int cycles_hi;
__asm__ volatile ("rdtsc" : "=a" (cycles_lo), "=d" (cycles_hi));
ret = (unsigned long long int)cycles_hi << 32 | cycles_lo;
return ret;
#else
struct timeval Tp;
int stat;
stat = gettimeofday(&Tp, NULL);
if (stat != 0) printf("Error return from gettimeofday: %d", stat);
return (Tp.tv_sec * 1000000 + Tp.tv_usec);
#endif
}
static inline void
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(stdout, "%llu us\n", e - s);
#endif
}
#endif /* GET_TIME_H */

@ -1,7 +1,8 @@
#include <stdio.h>
// #include "get_time.h"
unsigned long int
fib(unsigned long int n)
#include <stdint.h>
uint32_t
fib(uint32_t n)
{
if (n <= 1) return n;
return fib(n - 1) + fib(n - 2);
@ -10,13 +11,10 @@ fib(unsigned long int n)
int
main(int argc, char **argv)
{
unsigned long n = 0, r;
scanf("%lu", &n);
// unsigned long long st = get_time(), en;
r = fib(n);
// en = get_time();
printf("%lu\n", r);
uint32_t n = 0;
scanf("%u", &n);
// print_time(st, en);
uint32_t result = fib(n);
printf("%u\n", result);
return 0;
}

@ -1,32 +0,0 @@
#!/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 28 ]; do
testeach ./fibonacci_$1.out ${tmp1_cnt}
tmp1_cnt=$((tmp1_cnt - 1))
done
echo "All done!"

@ -0,0 +1,15 @@
// !!! HACK ALERT !!!
// We need the __init_libc symbol in the output executable (so the runtime can initialize libc)
// We can't directly export it since it's in a linked library
// Thus we export a dummy function that uses it, forcing it to be included
#define IMPORT __attribute__((visibility("default")))
#define EXPORT __attribute__((visibility("default")))
IMPORT void __init_libc(char **, char *);
EXPORT void
dummy()
{
__init_libc(0, 0);
}

@ -24,7 +24,6 @@ declare -ra tests=(
lpd_by_plate_count
bimodal
concurrency
payload
)
declare -a failed_tests=()
@ -32,11 +31,7 @@ declare -a failed_tests=()
# OCR Tests
# FIXME: OCR tests seem to sporadically fail and then work on rerun.
ocr_hyde() {
# FIXME: This check is a hack because GitHub Actions is caching
# the *.so file in the destination file, not the subodule it built from
if [[ ! -f "$base_dir/runtime/bin/gocr_wasm.so" ]]; then
make gocr -C "$base_dir/runtime/tests" || exit 1
fi
make gocr.install -C "$base_dir/runtime/tests" || exit 1
pushd "$base_dir/runtime/experiments/applications/ocr/hyde" || exit 1
./run.sh || failed_tests+=("ocr_hyde")
popd || exit 1
@ -44,9 +39,7 @@ ocr_hyde() {
}
ocr_handwriting() {
if [[ ! -f "$base_dir/runtime/bin/gocr_wasm.so" ]]; then
make gocr -C "$base_dir/runtime/tests" || exit 1
fi
make gocr.install -C "$base_dir/runtime/tests" || exit 1
pushd "$base_dir/runtime/experiments/applications/ocr/handwriting" || exit 1
./run.sh || failed_tests+=("ocr_handwriting")
popd || exit 1
@ -54,9 +47,7 @@ ocr_handwriting() {
}
ocr_fivebyeight() {
if [[ ! -f "$base_dir/runtime/bin/gocr_wasm.so" ]]; then
make gocr -C "$base_dir/runtime/tests" || exit 1
fi
make gocr.install -C "$base_dir/runtime/tests" || exit 1
pushd "$base_dir/runtime/experiments/applications/ocr/fivebyeight" || exit 1
./run.sh || failed_tests+=("ocr_fivebyeight")
popd || exit 1
@ -64,9 +55,7 @@ ocr_fivebyeight() {
}
ocr_by_word() {
if [[ ! -f "$base_dir/runtime/bin/gocr_wasm.so" ]]; then
make gocr -C "$base_dir/runtime/tests" || exit 1
fi
make gocr.install -C "$base_dir/runtime/tests" || exit 1
pushd "$base_dir/runtime/experiments/applications/ocr/by_word" || exit 1
# ./install.sh || exit 1
./run.sh || failed_tests+=("ocr_by_word")
@ -75,9 +64,7 @@ ocr_by_word() {
}
ocr_by_font() {
if [[ ! -f "$base_dir/runtime/bin/gocr_wasm.so" ]]; then
make gocr -C "$base_dir/runtime/tests" || exit 1
fi
make gocr.install -C "$base_dir/runtime/tests" || exit 1
pushd "$base_dir/runtime/experiments/applications/ocr/by_font" || exit 1
# ./install.sh || exit 1
./run.sh || failed_tests+=("ocr_by_font")
@ -86,9 +73,7 @@ ocr_by_font() {
}
ocr_by_dpi() {
if [[ ! -f "$base_dir/runtime/bin/gocr_wasm.so" ]]; then
make gocr -C "$base_dir/runtime/tests" || exit 1
fi
make gocr.install -C "$base_dir/runtime/tests" || exit 1
pushd "$base_dir/runtime/experiments/applications/ocr/by_dpi" || exit 1
# ./install.sh || exit 1
./run.sh || failed_tests+=("ocr_by_dpi")
@ -98,9 +83,7 @@ ocr_by_dpi() {
# EKF Tests
ekf_by_iteration() {
if [[ ! -f "$base_dir/runtime/bin/ekf_wasm.so" ]]; then
make tinyekf -C "$base_dir/runtime/tests" || exit 1
fi
make ekf.install -C "$base_dir/runtime/tests" || exit 1
pushd "$base_dir/runtime/experiments/applications/ekf/by_iteration" || exit 1
./run.sh || failed_tests+=("ekf_by_iteration")
popd || exit 1
@ -108,9 +91,7 @@ ekf_by_iteration() {
}
ekf_one_iteration() {
if [[ ! -f "$base_dir/runtime/bin/ekf_wasm.so" ]]; then
make tinyekf -C "$base_dir/runtime/tests" || exit 1
fi
make ekf.install -C "$base_dir/runtime/tests" || exit 1
pushd "$base_dir/runtime/experiments/applications/ekf/one_iteration" || exit 1
./run.sh || failed_tests+=("ekf_one_iteration")
popd || exit 1
@ -119,9 +100,7 @@ ekf_one_iteration() {
# cifar10 Tests
image_classification() {
if [[ ! -f "$base_dir/runtime/bin/cifar10_wasm.so" ]]; then
make cifar10 -C "$base_dir/runtime/tests" || exit 1
fi
make cifar10.install -C "$base_dir/runtime/tests" || exit 1
pushd "$base_dir/runtime/experiments/applications/imageclassification" || exit 1
./run.sh || failed_tests+=("image_classification")
popd || exit 1
@ -129,9 +108,7 @@ image_classification() {
}
image_resize() {
if [[ ! -f "$base_dir/runtime/bin/resize_wasm.so" ]]; then
make sod -C "$base_dir/runtime/tests" || exit 1
fi
make resize.install -C "$base_dir/runtime/tests" || exit 1
pushd "$base_dir/runtime/experiments/applications/imageresize/test" || exit 1
# ./install.sh || exit 1
./run.sh || failed_tests+=("image_resize")
@ -140,9 +117,7 @@ image_resize() {
}
image_resize_by_resolution() {
if [[ ! -f "$base_dir/runtime/bin/resize_wasm.so" ]]; then
make sod -C "$base_dir/runtime/tests" || exit 1
fi
make resize.install -C "$base_dir/runtime/tests" || exit 1
pushd "$base_dir/runtime/experiments/applications/imageresize/by_resolution" || exit 1
# ./install.sh || exit 1
./run.sh || failed_tests+=("image_resize_resolution")
@ -151,9 +126,7 @@ image_resize_by_resolution() {
}
lpd_by_plate_count() {
if [[ ! -f "$base_dir/runtime/bin/lpd_wasm.so" ]]; then
make sod -C "$base_dir/runtime/tests" || exit 1
fi
make lpd.install -C "$base_dir/runtime/tests" || exit 1
pushd "$base_dir/runtime/experiments/applications/licenseplate/by_plate_count" || exit 1
./run.sh || failed_tests+=("lpd_by_plate_count")
popd || exit 1
@ -162,9 +135,7 @@ lpd_by_plate_count() {
bimodal() {
echo "Bimodal"
if [[ ! -f "$base_dir/runtime/bin/fibonacci_wasm.so" ]]; then
make rttests -C "$base_dir/runtime/tests" || exit 1
fi
make fibonacci.install -C "$base_dir/runtime/tests" || exit 1
pushd "$base_dir/runtime/experiments/bimodal/" || exit 1
# ./install.sh || exit 1
./run.sh || failed_tests+=("bimodal")
@ -174,9 +145,7 @@ bimodal() {
concurrency() {
echo "Concurrency"
if [[ ! -f "$base_dir/runtime/bin/empty_wasm.so" ]]; then
make rttests -C "$base_dir/runtime/tests" || exit 1
fi
make empty.install -C "$base_dir/runtime/tests" || exit 1
pushd "$base_dir/runtime/experiments/concurrency/" || exit 1
# ./install.sh || exit 1
./run.sh || failed_tests+=("concurrency")
@ -184,22 +153,6 @@ concurrency() {
return 0
}
payload() {
echo "Payload"
if [[ ! -f "$base_dir/runtime/bin/work1k_wasm.so" ]] \
|| [[ ! -f "$base_dir/runtime/bin/work10k_wasm.so" ]] \
|| [[ ! -f "$base_dir/runtime/bin/work100k_wasm.so" ]] \
|| [[ ! -f "$base_dir/runtime/bin/work1m_wasm.so" ]]; then
make rttests -C "$base_dir/runtime/tests" || exit 1
fi
# TODO: Make Dependency "work1k_wasm.so" "work10k_wasm.so" "work100k_wasm.so" "work1m_wasm.so"
pushd "$base_dir/runtime/experiments/payload/" || exit 1
# ./install.sh || exit 1
./run.sh || failed_tests+=("payload")
popd || exit 1
return 0
}
main() {
cd "$base_dir/awsm" && cargo build --release || exit 1
make all -C "$base_dir/runtime" || exit 1

Loading…
Cancel
Save