Update build scripts and documents of workload samples for wasi-sdk-12.0 (#484)
Update the build scripts of sample workloads (meshoptimizer/bwa/wasm-av1) to use the wasi-sdk-12.0 firstly to build the workload and discard clang-11, as wasi-sdk-12 supports wasi, simd and pthread better. And update the related documents. Also modify wasm mini loader to sync up with the change of wasm normal loader. Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
This commit is contained in:
@ -5,6 +5,38 @@ cmake_minimum_required (VERSION 3.0)
|
||||
|
||||
project(bench-meshoptimizer)
|
||||
|
||||
################ WASI-SDK ################
|
||||
find_path(WASI_SDK_HOME
|
||||
NAMES wasi-sdk
|
||||
PATHS /opt/
|
||||
REQUIRED
|
||||
)
|
||||
|
||||
if (NOT WASI_SDK_HOME)
|
||||
message(FATAL_ERROR
|
||||
"can not find wasi-sdk. "
|
||||
"please download it from "
|
||||
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz "
|
||||
"and install it under /opt/wasi-sdk"
|
||||
)
|
||||
endif()
|
||||
|
||||
#
|
||||
# check clang version
|
||||
execute_process(COMMAND
|
||||
${WASI_SDK_HOME}/wasi-sdk/bin/clang --version
|
||||
OUTPUT_VARIABLE clang_full_version_string
|
||||
)
|
||||
string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1"
|
||||
CLANG_VERSION_STRING ${clang_full_version_string}
|
||||
)
|
||||
message("cur clang version is ${CLANG_VERSION_STRING}")
|
||||
if(CLANG_VERSION_STRING VERSION_LESS 11.0)
|
||||
message(FATAL_ERROR
|
||||
"please install latest wai-sdk to get a clang-11 at least"
|
||||
)
|
||||
endif()
|
||||
|
||||
################ BINARYEN ################
|
||||
find_program(WASM_OPT
|
||||
NAMES wasm-opt
|
||||
@ -33,7 +65,10 @@ ExternalProject_Add(codecbench
|
||||
UPDATE_COMMAND git clean -fd && git checkout -- *
|
||||
&& ${CMAKE_COMMAND} -E echo "Applying patch"
|
||||
&& git apply ${CMAKE_CURRENT_SOURCE_DIR}/codecbench.patch
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/../cmake/toolchain.cmake ${CMAKE_CURRENT_SOURCE_DIR}/meshoptimizer
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND}
|
||||
-DWASI_SDK_PREFIX=${WASI_SDK_HOME}/wasi-sdk
|
||||
-DCMAKE_TOOLCHAIN_FILE=${WASI_SDK_HOME}/wasi-sdk/share/cmake/wasi-sdk.cmake
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/meshoptimizer
|
||||
BUILD_COMMAND make codecbench.opt
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ./codecbench.opt.wasm ${CMAKE_CURRENT_SOURCE_DIR}/build/codecbench.wasm
|
||||
)
|
||||
|
||||
@ -8,7 +8,7 @@ WebAssembly with simd support and run it with iwasm.
|
||||
|
||||
please refer to [installation instructions](../README.md).
|
||||
|
||||
## Build with clang-11 and wasi-sdk
|
||||
## Build with wasi-sdk
|
||||
|
||||
``` shell
|
||||
$ mkdir build && cd build
|
||||
@ -18,15 +18,15 @@ $ make
|
||||
$ ls codecbench.wasm
|
||||
```
|
||||
|
||||
## Or build with EMCC
|
||||
## Or build with EMSDK
|
||||
|
||||
EMCC is another toolchain to compile C code to WASM. In this case, will have
|
||||
a higher performance with EMCC.
|
||||
EMSDK is another toolchain to compile C/C++ code to WASM. In this case, the output wasm file
|
||||
might have a higher performance than the file generated by wasi-sdk.
|
||||
|
||||
``` shell
|
||||
$ git clone https://github.com/zeux/meshoptimizer.git
|
||||
$ cd messoptimizer
|
||||
$ emcc tools/codecbench.cpp src/vertexcodec.cpp src/vertexfilter.cpp \
|
||||
$ em++ tools/codecbench.cpp src/vertexcodec.cpp src/vertexfilter.cpp \
|
||||
src/overdrawanalyzer.cpp src/indexgenerator.cpp src/vcacheoptimizer.cpp \
|
||||
src/clusterizer.cpp src/indexcodec.cpp src/vfetchanalyzer.cpp \
|
||||
src/spatialorder.cpp src/allocator.cpp src/vcacheanalyzer.cpp \
|
||||
@ -51,9 +51,7 @@ $ make
|
||||
Then compile wasm file to aot file and run:
|
||||
|
||||
``` shell
|
||||
$ cd <wamr dir>/wamr-compiler/build
|
||||
$ ./wamrc --enable-simd -o codecbench.aot codecbench.wasm
|
||||
$ cd <wamr dir>/product-mini/platforms/linux/
|
||||
$ ./iwasm codecbench.aot
|
||||
$ <wamr dir>/wamr-compiler/build/wamrc --enable-simd -o codecbench.aot codecbench.wasm
|
||||
$ <wamr dir>/product-mini/platforms/linux/build/iwasm codecbench.aot
|
||||
```
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index eccc49e..dac126c 100644
|
||||
index ffdb4da..536a5c8 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -127,3 +127,42 @@ install(FILES
|
||||
@@ -127,3 +127,43 @@ install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/meshoptimizerConfig.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/meshoptimizerConfigVersion.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/meshoptimizer)
|
||||
@ -16,6 +16,7 @@ index eccc49e..dac126c 100644
|
||||
+
|
||||
+target_compile_options(codecbench
|
||||
+ PUBLIC
|
||||
+ -O3 -msimd128
|
||||
+ -std=c++11
|
||||
+ -Wno-unused-function
|
||||
+ -Wno-unused-variable
|
||||
|
||||
Reference in New Issue
Block a user