Skip to content

Conversation

@lum1n0us
Copy link
Collaborator

@lum1n0us lum1n0us commented Sep 4, 2022

It includes:

  • Remove code with MCJIT APIs. Embrance ORC.
    • WASM_ENABLE_LAZY_JIT only represent lazy compilation. It won't specify
      ORC or MCJIT
    • Remove runtime ORC compilation threads and move all aot functions
      into one module
    • Current LLVM ORC JIT implements eagel compilation. Will add lazy
      compilation later
  • JIT and AOT both apply the new pass manager

@lum1n0us lum1n0us force-pushed the remove_mcjit branch 3 times, most recently from d672ec9 to d3035ab Compare September 5, 2022 02:57
@lum1n0us lum1n0us force-pushed the remove_mcjit branch 3 times, most recently from d10091e to ea04105 Compare September 5, 2022 07:01
/* LLVM execution engine required by JIT */
#if WASM_ENABLE_LAZY_JIT != 0
LLVMOrcLLJITRef orc_lazyjit;
LLVMOrcLLJITRef orc_jit;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that we don't use the WAMR_BUILD_JIT macro to control the fields and the code in core/iwasm/compilation?

@lum1n0us lum1n0us force-pushed the remove_mcjit branch 3 times, most recently from 11a468d to 79273ef Compare September 6, 2022 00:26
It includes:
- Remove code with MCJIT APIs. Embrance ORC.
  - WASM_ENABLE_LAZY_JIT only represent lazy compilation. It won't specify
    ORC or MCJIT
  - Remove runtime ORC compilation threads and move all aot functions
    into one module
  - Current LLVM ORC JIT implements eagel compilation. Will add lazy
    compilation later
- JIT and AOT both apply the new pass manager
  - All JIT passes are in IRTransferLayer

P.S.
| Varient impl.           | Norm. Score | Norm. (ms) |
| ----------------------- | ----------- | ---------- |
| Original                | 1.0         | 1.0        |
| Apply the new PM        | 1.01        | 1.007      |
| Opt in IRTransformLayer | 0.997       | 1.04       |
}
}
else {
#if WASM_ENABLE_LAZY_JIT == 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not remove the code of if branch, which is the operation of AOT compiler mode and eager JIT mode. Removing the code may impact the performance of AOT.

How about adding a flag:

bool is_lazy_jit = false;
#if WASM_ENABLE_LAZY_JIT != 0
if (comp_ctx->is_jit_mode) {
    is_lazy_jit = true;
}
#endif

if (!is_lazy_jit) {
    func = func_ctxes[func_idx - import_func_count]->func;
}
else {
    code of original #else branch
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right.
Second thoughts, there will be only one module even in 'lazy compilation' and the code of original #else branch may not be necessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very sure, how about keeping the code currently and testing it when implementing ORCv2?

1. Register the `AAManager` and `buildDefaultAAPipeline`
2. Use function pointers in `aot_compile_op_call` and `aot_compile_op_indirect_call`
   instead of `lookup_orcjit_func`

CoreMark Score:
| Varient impl.           | Norm. Score | Norm. (ms) |
| ----------------------- | ----------- | ---------- |
| Original                | 1.0         | 1.0        |
| Apply the new PM        | 1.01        | 1.007      |
| Opt in IRTransformLayer | 0.997       | 1.04       |
| Tuning#1                | 1.01        | 0.83       |
@lum1n0us
Copy link
Collaborator Author

lum1n0us commented Sep 6, 2022

I have uploaded a new improvement which includes:

  1. Register the AAManager and buildDefaultAAPipeline
  2. Use function pointers in aot_compile_op_call and aot_compile_op_indirect_call instead of lookup_orcjit_func

If it is OK, I will remove lookup_orcjit_func related stuff. For now, the branch is commented for now.

@lum1n0us lum1n0us mentioned this pull request Sep 6, 2022
@wenyongh wenyongh merged commit 5db3412 into bytecodealliance:dev/refactor_llvm_jit Sep 7, 2022
@lum1n0us lum1n0us deleted the remove_mcjit branch October 1, 2022 11:41
@wenyongh wenyongh mentioned this pull request Oct 11, 2022
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.

2 participants