build.sh 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #!/bin/bash
  2. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. source /opt/emsdk/emsdk_env.sh
  5. PLATFORM=$(uname -s | tr A-Z a-z)
  6. WORK_DIR=$PWD
  7. OUT_DIR=$PWD/out
  8. WAMRC_CMD=$PWD/../../../wamr-compiler/build/wamrc
  9. JETSTREAM_DIR=$PWD/perf-automation/benchmarks/JetStream2/wasm
  10. mkdir -p ${OUT_DIR}
  11. if [[ $1 != "--no-simd" ]];then
  12. NATIVE_SIMD_FLAGS="-msse2 -msse3 -msse4"
  13. WASM_SIMD_FLAGS="-msimd128"
  14. else
  15. NATIVE_SIMD_FLAGS=""
  16. WASM_SIMD_FLAGS=""
  17. fi
  18. if [ ! -d perf-automation ]; then
  19. git clone https://github.com/mozilla/perf-automation.git
  20. echo "Patch source files .."
  21. cd perf-automation
  22. patch -p1 -N < ../jetstream.patch
  23. fi
  24. cd ${JETSTREAM_DIR}
  25. # Build gcc-loops
  26. echo "Build gcc-loops with g++ .."
  27. g++ -O3 ${NATIVE_SIMD_FLAGS} -o ${OUT_DIR}/gcc-loops_native gcc-loops.cpp
  28. echo "Build gcc-loops with em++ .."
  29. em++ -O3 -s STANDALONE_WASM=1 ${WASM_SIMD_FLAGS} \
  30. -s INITIAL_MEMORY=1048576 \
  31. -s TOTAL_STACK=32768 \
  32. -s "EXPORTED_FUNCTIONS=['_main']" \
  33. -s ERROR_ON_UNDEFINED_SYMBOLS=0 \
  34. -o ${OUT_DIR}/gcc-loops.wasm gcc-loops.cpp
  35. echo "Compile gcc-loops.wasm to gcc-loops.aot"
  36. ${WAMRC_CMD} -o ${OUT_DIR}/gcc-loops.aot ${OUT_DIR}/gcc-loops.wasm
  37. if [[ ${PLATFORM} == "linux" ]]; then
  38. echo "Compile gcc-loops.wasm to gcc-loops_segue.aot"
  39. ${WAMRC_CMD} --enable-segue -o ${OUT_DIR}/gcc-loops_segue.aot ${OUT_DIR}/gcc-loops.wasm
  40. fi
  41. # Build quicksort
  42. echo "Build quicksort with gcc .."
  43. gcc -O3 ${NATIVE_SIMD_FLAGS} -o ${OUT_DIR}/quicksort_native quicksort.c
  44. echo "Build quicksort with emcc .."
  45. emcc -O3 -s STANDALONE_WASM=1 ${WASM_SIMD_FLAGS} \
  46. -s INITIAL_MEMORY=1048576 \
  47. -s TOTAL_STACK=32768 \
  48. -s "EXPORTED_FUNCTIONS=['_main']" \
  49. -o ${OUT_DIR}/quicksort.wasm quicksort.c
  50. echo "Compile quicksort.wasm to quicksort.aot"
  51. ${WAMRC_CMD} -o ${OUT_DIR}/quicksort.aot ${OUT_DIR}/quicksort.wasm
  52. if [[ ${PLATFORM} == "linux" ]]; then
  53. echo "Compile quicksort.wasm to quicksort_segue.aot"
  54. ${WAMRC_CMD} --enable-segue -o ${OUT_DIR}/quicksort_segue.aot ${OUT_DIR}/quicksort.wasm
  55. fi
  56. # Build HashSet
  57. echo "Build HashSet with g++ .."
  58. g++ -O3 ${NATIVE_SIMD_FLAGS} -o ${OUT_DIR}/HashSet_native HashSet.cpp \
  59. -lstdc++
  60. echo "Build HashSet with em++ .."
  61. em++ -O3 -s STANDALONE_WASM=1 ${WASM_SIMD_FLAGS} \
  62. -s INITIAL_MEMORY=1048576 \
  63. -s TOTAL_STACK=32768 \
  64. -s "EXPORTED_FUNCTIONS=['_main']" \
  65. -o ${OUT_DIR}/HashSet.wasm HashSet.cpp
  66. echo "Compile HashSet.wasm to HashSet.aot"
  67. ${WAMRC_CMD} -o ${OUT_DIR}/HashSet.aot ${OUT_DIR}/HashSet.wasm
  68. if [[ ${PLATFORM} == "linux" ]]; then
  69. echo "Compile HashSet.wasm to HashSet_segue.aot"
  70. ${WAMRC_CMD} --enable-segue -o ${OUT_DIR}/HashSet_segue.aot ${OUT_DIR}/HashSet.wasm
  71. fi
  72. # Build float-mm
  73. cd ${JETSTREAM_DIR}/../simple
  74. echo "Build float-mm with gcc .."
  75. gcc -O3 ${NATIVE_SIMD_FLAGS} -o ${OUT_DIR}/float-mm_native float-mm.c
  76. echo "Build float-mm with emcc .."
  77. emcc -O3 -s STANDALONE_WASM=1 ${WASM_SIMD_FLAGS} \
  78. -s INITIAL_MEMORY=1048576 \
  79. -s TOTAL_STACK=32768 \
  80. -s "EXPORTED_FUNCTIONS=['_main']" \
  81. -o ${OUT_DIR}/float-mm.wasm float-mm.c
  82. echo "Compile float-mm.wasm to float-mm.aot"
  83. ${WAMRC_CMD} -o ${OUT_DIR}/float-mm.aot ${OUT_DIR}/float-mm.wasm
  84. if [[ ${PLATFORM} == "linux" ]]; then
  85. echo "Compile float-mm.wasm to float-mm_segue.aot"
  86. ${WAMRC_CMD} --enable-segue -o ${OUT_DIR}/float-mm_segue.aot ${OUT_DIR}/float-mm.wasm
  87. fi
  88. # Build tsf
  89. cd ${JETSTREAM_DIR}/TSF
  90. tsf_srcs="tsf_asprintf.c tsf_buffer.c tsf_error.c tsf_reflect.c tsf_st.c \
  91. tsf_type.c tsf_io.c tsf_native.c tsf_generator.c tsf_st_typetable.c \
  92. tsf_parser.c tsf_buf_writer.c tsf_buf_reader.c tsf_primitive.c \
  93. tsf_type_table.c tsf_copier.c tsf_destructor.c tsf_gpc_code_gen.c \
  94. gpc_code_gen_util.c gpc_threaded.c gpc_intable.c gpc_instruction.c \
  95. gpc_program.c gpc_proto.c gpc_stack_height.c tsf_serial_in_man.c \
  96. tsf_serial_out_man.c tsf_type_in_map.c tsf_type_out_map.c \
  97. tsf_stream_file_input.c tsf_stream_file_output.c tsf_sort.c \
  98. tsf_version.c tsf_named_type.c tsf_io_utils.c tsf_zip_attr.c \
  99. tsf_zip_reader.c tsf_zip_writer.c tsf_zip_abstract.c tsf_limits.c \
  100. tsf_ra_type_man.c tsf_adaptive_reader.c tsf_sha1.c tsf_sha1_writer.c \
  101. tsf_fsdb.c tsf_fsdb_protocol.c tsf_define_helpers.c tsf_ir.c \
  102. tsf_ir_different.c tsf_ir_speed.c"
  103. echo "Build tsf with gcc .."
  104. gcc \
  105. -o ${OUT_DIR}/tsf_native -O3 ${NATIVE_SIMD_FLAGS} \
  106. -I. -DTSF_BUILD_SYSTEM=1 \
  107. ${tsf_srcs} -lm
  108. echo "Build tsf standalone with wasi-sdk .."
  109. /opt/wasi-sdk/bin/clang -O3 ${WASM_SIMD_FLAGS} -z stack-size=1048576 \
  110. -Wl,--initial-memory=52428800 \
  111. -Wl,--export=main \
  112. -Wl,--export=__heap_base,--export=__data_end \
  113. -I. -DTSF_BUILD_SYSTEM=1 \
  114. -Wl,--allow-undefined \
  115. -o ${OUT_DIR}/tsf.wasm \
  116. ${tsf_srcs}
  117. echo "Compile tsf.wasm to tsf.aot"
  118. ${WAMRC_CMD} -o ${OUT_DIR}/tsf.aot ${OUT_DIR}/tsf.wasm
  119. if [[ ${PLATFORM} == "linux" ]]; then
  120. echo "Compile tsf.wasm to tsf_segue.aot"
  121. ${WAMRC_CMD} --enable-segue -o ${OUT_DIR}/tsf_segue.aot ${OUT_DIR}/tsf.wasm
  122. fi