Enable SIMD support for Linux SGX platform (#474)

This commit is contained in:
Wenyong Huang
2020-12-21 01:17:36 -06:00
committed by GitHub
parent a2294877f5
commit adb05ea719
5 changed files with 18 additions and 28 deletions

View File

@ -76,12 +76,8 @@ fi
if [ -d "${TF_LITE_BUILD_DIR}/gen" ]; then
rm -fr ${TF_LITE_BUILD_DIR}/gen
fi
if [[ $1 == '--sgx' ]]; then
make -j 4 -C "${TENSORFLOW_DIR}" -f ${TF_LITE_BUILD_DIR}/Makefile
else
export BUILD_WITH_SIMD=true
make -j 4 -C "${TENSORFLOW_DIR}" -f ${TF_LITE_BUILD_DIR}/Makefile
fi
make -j 4 -C "${TENSORFLOW_DIR}" -f ${TF_LITE_BUILD_DIR}/Makefile
# remove patch file and recover emcc libc.a after building
Clear_Before_Exit
@ -102,7 +98,7 @@ make
WAMRC_CMD="$(pwd)/wamrc"
cd ${OUT_DIR}
if [[ $1 == '--sgx' ]]; then
${WAMRC_CMD} -sgx -o benchmark_model.aot benchmark_model.wasm
${WAMRC_CMD} --enable-simd -sgx -o benchmark_model.aot benchmark_model.wasm
else
${WAMRC_CMD} --enable-simd -o benchmark_model.aot benchmark_model.wasm
fi
@ -114,7 +110,7 @@ fi
if [[ $1 == '--sgx' ]]; then
cd ${WAMR_PLATFORM_DIR}/linux-sgx
rm -fr build && mkdir build
cd build && cmake .. -DWAMR_BUILD_LIB_PTHREAD=1 -DWAMR_BUILD_LIBC_EMCC=1
cd build && cmake .. -DWAMR_BUILD_SIMD=1 -DWAMR_BUILD_LIB_PTHREAD=1 -DWAMR_BUILD_LIBC_EMCC=1
make
cd ../enclave-sample
make

View File

@ -1,5 +1,5 @@
diff --git a/tensorflow/lite/tools/make/Makefile b/tensorflow/lite/tools/make/Makefile
index c7ddff5844..17146868f7 100644
index c7ddff58440..ed69c452b67 100644
--- a/tensorflow/lite/tools/make/Makefile
+++ b/tensorflow/lite/tools/make/Makefile
@@ -48,11 +48,7 @@ INCLUDES += -I/usr/local/include
@ -15,15 +15,12 @@ index c7ddff5844..17146868f7 100644
-ldl
# There are no rules for compiling objects for the host system (since we don't
@@ -84,14 +80,24 @@ endif # ifeq ($(HOST_ARCH),$(TARGET_ARCH))
@@ -84,14 +80,21 @@ endif # ifeq ($(HOST_ARCH),$(TARGET_ARCH))
endif # ifeq ($(HOST_OS),$(TARGET))
endif
+BUILD_WITH_SIMD ?= false
+ifeq ($(BUILD_WITH_SIMD), true)
+CFLAGS+=-msimd128
+CXXFLAGS+=-msimd128
+endif
+
+LIBFLAGS += -s TOTAL_STACK=1048576 \
+ -Wl,--export=__data_end -Wl,--export=__heap_base \
@ -42,7 +39,7 @@ index c7ddff5844..17146868f7 100644
# A small example program that shows how to link against the library.
MINIMAL_SRCS := \
@@ -277,12 +283,16 @@ LIB_PATH := $(LIBDIR)$(LIB_NAME)
@@ -277,12 +280,16 @@ LIB_PATH := $(LIBDIR)$(LIB_NAME)
BENCHMARK_LIB := $(LIBDIR)$(BENCHMARK_LIB_NAME)
BENCHMARK_BINARY := $(BINDIR)$(BENCHMARK_BINARY_NAME)
BENCHMARK_PERF_OPTIONS_BINARY := $(BINDIR)$(BENCHMARK_PERF_OPTIONS_BINARY_NAME)
@ -64,7 +61,7 @@ index c7ddff5844..17146868f7 100644
MINIMAL_OBJS := $(addprefix $(OBJDIR), \
$(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(MINIMAL_SRCS))))
diff --git a/tensorflow/lite/tools/make/targets/linux_makefile.inc b/tensorflow/lite/tools/make/targets/linux_makefile.inc
index 222cef9e5f..eea89a38f0 100644
index 222cef9e5ff..eea89a38f01 100644
--- a/tensorflow/lite/tools/make/targets/linux_makefile.inc
+++ b/tensorflow/lite/tools/make/targets/linux_makefile.inc
@@ -2,12 +2,10 @@