test_pgo.sh 1.6 KB

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