Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement AOT static PGO #2243

Merged
merged 11 commits into from
Jun 5, 2023
Merged

Implement AOT static PGO #2243

merged 11 commits into from
Jun 5, 2023

Conversation

wenyongh
Copy link
Contributor

@wenyongh wenyongh commented May 29, 2023

LLVM PGO (Profile-Guided Optimization) allows the compiler to better optimize code
for how it actually runs. This PR implements the AOT static PGO, and is tested on
Linux x86-64 and x86-32. The basic steps are:

  1. Use wamrc --enable-llvm-pgo -o <aot_file_of_pgo> <wasm_file>
    to generate an instrumented aot file.
  2. Compile iwasm with cmake -DWAMR_BUILD_STATIC_PGO=1 and run
    iwasm --gen-prof-file=<raw_profile_file> <aot_file_of_pgo>
    to generate the raw profile file
  3. Run llvm-profdata merge -output=<profile_file> <raw_profile_file>
    to merge the raw profile file into the profile file
  4. Run wamrc --use-prof-file=<profile_file> -o <aot_file> <wasm_file>
    to generate the optimized aot file
  5. Run the optimized aot_file: iwasm <aot_file>

The test scripts are also added for each benchmark, run test_pgo.sh under
each benchmark's folder to test the AOT static pgo.

wenyongh added 10 commits May 9, 2023 14:29
Merge branch main into dev/static_pgo
)

- Uncomment PGO for indirect calls and implement the relocation type
  R_X86_64_GOTPCREL
- Fix issues of flags in raw profile version
- Add LICM pass for wamrc when pgo is enabled
- Add test pgo scripts for benchmark coremark/sightglass/polybench
- Add benchmark dhrystone
- Add test pgo scripts for benchmarks
- Fix benchmark script issues
Explicitly disable static counter allocation for value profiler since it will be allocated by runtime.
x86-32 target was tested with benchmark coremark, dhrystone, sightglass and polybench.
@lum1n0us
Copy link
Collaborator

lum1n0us commented Jun 4, 2023

LGTM

@wenyongh wenyongh merged commit 8d88471 into main Jun 5, 2023
959 checks passed
victoryang00 pushed a commit to victoryang00/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
LLVM PGO (Profile-Guided Optimization) allows the compiler to better optimize code
for how it actually runs. This PR implements the AOT static PGO, and is tested on
Linux x86-64 and x86-32. The basic steps are:

1. Use `wamrc --enable-llvm-pgo -o <aot_file_of_pgo> <wasm_file>`
   to generate an instrumented aot file.
2. Compile iwasm with `cmake -DWAMR_BUILD_STATIC_PGO=1` and run
      `iwasm --gen-prof-file=<raw_profile_file> <aot_file_of_pgo>`
    to generate the raw profile file.
3. Run `llvm-profdata merge -output=<profile_file> <raw_profile_file>`
    to merge the raw profile file into the profile file.
4. Run `wamrc --use-prof-file=<profile_file> -o <aot_file> <wasm_file>`
    to generate the optimized aot file.
5. Run the optimized aot_file: `iwasm <aot_file>`.

The test scripts are also added for each benchmark, run `test_pgo.sh` under
each benchmark's folder to test the AOT static pgo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants