-
Notifications
You must be signed in to change notification settings - Fork 104
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
Allow JIT compilation for system emulation #521
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmarks
Benchmark suite | Current: 09fc945 | Previous: 73b1ba5 | Ratio |
---|---|---|---|
Dhrystone |
1343 Average DMIPS over 10 runs |
1343 Average DMIPS over 10 runs |
1 |
Coremark |
975.239 Average iterations/sec over 10 runs |
979.275 Average iterations/sec over 10 runs |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
330a574
to
73b1ba5
Compare
This file is generated by "tools/gen-jit-template.py" To bring up the Linux Kernel to just-in-time (JIT) compilation, we need to update the memory-related operation with the memory management unit. However, the current "src/rv32_jit.c" was generated by the template. That template reduced the rework for the repeated statements, but also reduced the flexibility and the intuitiveness for bring up the new feature. In this commit, we deprecate that template and just use a regular file for the flexibility.
This commit introduces "satp" field to the block structure in JIT mode to ensure the block cache is replaced correctly. The MOP fusion and T2C are disabled temporarily. Use the following commands to boot Linux Kernel: $ make ENABLE_SYSTEM=1 ENABLE_MOP_FUSION=0 ENABLE_JIT=1 ENABLE_T2C=0 $ ./build/rv32emu -k <image> -i <rootfs> -b <dtb>
73b1ba5
to
09fc945
Compare
#if RV32_HAS(SYSTEM) | ||
if (next_blk && next_blk->satp != rv->csr_satp) | ||
next_blk = NULL; | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comments for SATP.
#if 0 | ||
/* | ||
* This branch lookup updating is unused since we get the PC from it and | ||
* use function "cache_get()" achieve the branch prediction of T1C. | ||
* However, if the structure "branch_table_t" is going to reference the | ||
* block directly, this updating is nacessary to avoid to use the freed | ||
* blocks. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't get it. When is it safe to release the resources?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the comments above, the current workflow is safe. However, if the implementation of branch_table
is changed (e.g. storing the possible blocks directly instead of the program counters), this updating cannot be ignored.
@@ -126,6 +129,18 @@ struct riscv_internal { | |||
riscv_word_t X[N_RV_REGS]; | |||
riscv_word_t PC; | |||
|
|||
#if RV32_HAS(JIT) && RV32_HAS(SYSTEM) | |||
/* | |||
* Aarch encoder only accepts 9 bits signed offset. Do not put this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aarch?
uint32_t is_mmio; /* whether is MMIO or not */ | ||
uint32_t type; /* 0: read, 1: write */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you use bit-fields instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To simplify the emission of load/store instructions of both x86-64
and Aarch64
in src/rv32_jit.c
, I would like to keep them as unsigned integer.
@@ -704,6 +706,7 @@ static inline void remove_next_nth_ir(const riscv_t *rv, | |||
* Strategies are being devised to increase the number of instructions that | |||
* match the pattern, including possible instruction reordering. | |||
*/ | |||
#if RV32_HAS(MOP_FUSION) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap around the comment as well.
Testing Report:x86-64 machine: Kernel message Logs:
Aarch64 machine: |
This patch makes
rv32emu
support the just-in-time (JIT) compilation in system simulation. To achieve this goal, a "satp (supervisor address translation and protection)" field has been introduced to the block structure in JIT mode to ensure the block cache is replaced correctly.The file
src/system.c
has been updated for the easier reuse of functions, and the MOP fusion and T2C are disabled temporarily. To boot the Linux Kernel, try the following commands: