parent
79ca1f04ae
commit
01bca00be4
@ -0,0 +1,3 @@
|
||||
*.wasm
|
||||
*.bc
|
||||
*.so
|
@ -1,60 +1,63 @@
|
||||
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 $@
|
||||
|
||||
.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}
|
||||
%_wasm.so: %.bc ${SLEDGE_COMPILETIME_SRC}
|
||||
${CC} --shared -fPIC ${OPTFLAGS} -I${SLEDGE_COMPILETIME_INC} $^ -o $@
|
||||
|
||||
../../runtime/bin/%.so: %.so
|
||||
cp $^ $@
|
||||
|
@ -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,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);
|
||||
}
|
Loading…
Reference in new issue