test_pgo.sh 1.7 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 "dhrystone.wasm" ]; then
  13. echo "dhrystone.wasm doesn't exist, please run build.sh first"
  14. exit
  15. fi
  16. echo ""
  17. echo "Compile dhrystone.wasm to dhrystone.aot .."
  18. ${WAMRC} -o dhrystone.aot dhrystone.wasm
  19. echo ""
  20. echo "Compile dhrystone.wasm to dhrystone_pgo.aot .."
  21. ${WAMRC} --enable-llvm-pgo -o dhrystone_pgo.aot dhrystone.wasm
  22. echo ""
  23. echo "Run dhrystone_pgo.aot to generate the raw profile data .."
  24. ${IWASM} --gen-prof-file=dhrystone.profraw dhrystone_pgo.aot
  25. echo ""
  26. echo "Merge the raw profile data to dhrystone.profdata .."
  27. rm -f dhrystone.profdata && llvm-profdata merge -output=dhrystone.profdata dhrystone.profraw
  28. echo ""
  29. echo "Compile dhrystone.wasm to dhrystone_opt.aot with the profile data .."
  30. ${WAMRC} --use-prof-file=dhrystone.profdata -o dhrystone_opt.aot dhrystone.wasm
  31. echo ""
  32. echo "Run the dhrystone native"
  33. ./dhrystone_native
  34. echo ""
  35. echo "Run the original aot file dhrystone.aot"
  36. ${IWASM} dhrystone.aot
  37. echo ""
  38. echo "Run the PGO optimized aot file dhrystone_opt.aot"
  39. ${IWASM} dhrystone_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 dhrystone.profraw