test_pgo.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/sh
  2. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. PLATFORM=$(uname -s | tr A-Z a-z)
  5. if [ "$1" = "--sgx" ] && [ "$PLATFORM" = "linux" ]; then
  6. IWASM="../../../product-mini/platforms/${PLATFORM}-sgx/enclave-sample/iwasm"
  7. WAMRC="../../../wamr-compiler/build/wamrc -sgx"
  8. else
  9. IWASM="../../../product-mini/platforms/${PLATFORM}/build/iwasm"
  10. WAMRC="../../../wamr-compiler/build/wamrc"
  11. fi
  12. if [ ! -e "coremark.wasm" ]; then
  13. echo "coremark.wasm doesn't exist, please run build.sh first"
  14. exit
  15. fi
  16. echo ""
  17. echo "Compile coremark.wasm to coremark.aot .."
  18. ${WAMRC} -o coremark.aot coremark.wasm
  19. echo ""
  20. echo "Compile coremark.wasm to coremark_pgo.aot .."
  21. ${WAMRC} --enable-llvm-pgo -o coremark_pgo.aot coremark.wasm
  22. echo ""
  23. echo "Run coremark_pgo.aot to generate the raw profile data .."
  24. ${IWASM} --gen-prof-file=coremark.profraw coremark_pgo.aot
  25. echo ""
  26. echo "Merge the raw profile data to coremark.profdata .."
  27. rm -f coremark.profdata && llvm-profdata merge -output=coremark.profdata coremark.profraw
  28. echo ""
  29. echo "Compile coremark.wasm to coremark_opt.aot with the profile data .."
  30. ${WAMRC} --use-prof-file=coremark.profdata -o coremark_opt.aot coremark.wasm
  31. echo ""
  32. echo "Run the coremark native"
  33. ./coremark.exe
  34. echo ""
  35. echo "Run the original aot file coremark.aot"
  36. ${IWASM} coremark.aot
  37. echo ""
  38. echo "Run the PGO optimized aot file coremark_opt.aot"
  39. ${IWASM} coremark_opt.aot
  40. # Show the profile data:
  41. # llvm-profdata show --all-functions --detailed-summary --binary-ids --counts \
  42. # --hot-func-list --memop-sizes --show-prof-sym-list coremark.profraw