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

Use computed-goto to lower instruction dispatch overhead #2

Merged
merged 3 commits into from
Mar 11, 2021

Conversation

sammer1107
Copy link
Contributor

@sammer1107 sammer1107 commented Dec 29, 2020

  • This pull request applies the computed goto technique to the
    main loop. This modification is tested to have 15 to 23
    percent improvement on performance.
  • The old implementation of rv_step can be enabled
    by setting the environment variable ENABLE_COMPUTED_GOTO to 0.
  • Only clang and gcc is supported by computed goto feature,
    ENABLE_COMPUTED_GOTO will be ignored if other compiler is used.
  • An op_unimp handler is also added in order to acheive
    this. This also allows better handling of unimplemented
    opcodes instead of jumping into NULL.

Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Change the subject (of pull request and git commit message) to "Use computed-goto to lower instruction dispatch overhead"

@jserv
Copy link
Contributor

jserv commented Dec 30, 2020

The commit message should be amended, mentioning the benefit of the proposed computed-goto change.

+ This commit applies the computed goto technique to the
main loop. This modification is tested to have 15 to 23
percent improvement on performance.
+ The old implementation of rv_step can be enabled
by setting the environment variable ENABLE_COMPUTED_GOTO to 0.
+ Only clang and gcc is supported by computed goto feature,
ENABLE_COMPUTED_GOTO will be ignored if other compiler is used.
+ An op_unimp handler is also added in order to acheive
this. This also allows better handling of unimplemented
opcodes instead of jumping into NULL.
@sammer1107 sammer1107 changed the title Use computed goto to speed up main loop Use computed-goto to lower instruction dispatch overhead Jan 5, 2021
@sammer1107 sammer1107 requested a review from jserv January 5, 2021 06:44
Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

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

The commit message should provide the measurement (numbers) for speedup.

@jserv
Copy link
Contributor

jserv commented Mar 2, 2021

@sammer1107, would you continue this work recently?

@jserv jserv merged commit 48b9001 into sysprog21:master Mar 11, 2021
@jserv
Copy link
Contributor

jserv commented Mar 11, 2021

Thank @sammer1107 for contributing!

@sysprog21 sysprog21 deleted a comment from sammer1107 Jan 24, 2022
@sysprog21 sysprog21 deleted a comment from sammer1107 Jan 24, 2022
vacantron pushed a commit to vacantron/rv32emu that referenced this pull request Dec 14, 2024
-fsanitize=address report when CTRL+a x exiting:
=================================================================
==297977==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 23400 byte(s) in 117 object(s) allocated from:
    #0 0x761b706fd340 in calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77
    #1 0x633ad9c5e310 in block_translate src/emulate.c:649
    sysprog21#2 0x633ad9c5e310 in block_find_or_translate src/emulate.c:865
    sysprog21#3 0x633ad9c5e310 in rv_step src/emulate.c:1029
    sysprog21#4 0x633ad9c5e310 in rv_run src/riscv.c:498
    sysprog21#5 0x633ad9c5e310 in main src/main.c:279

Direct leak of 3136 byte(s) in 125 object(s) allocated from:
    #0 0x761b706fd9c7 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x633ad9c5fea4 in match_pattern src/emulate.c:767
    sysprog21#2 0x633ad9c5fea4 in block_find_or_translate src/emulate.c:872
    sysprog21#3 0x633ad9c5fea4 in rv_step src/emulate.c:1029
    sysprog21#4 0x633ad9c5fea4 in rv_run src/riscv.c:498
    sysprog21#5 0x633ad9c5fea4 in main src/main.c:279

Register a clean up callback, async_block_clear() to free all the
allocated memory fix this when emulator exits.
vestata pushed a commit to vestata/rv32emu that referenced this pull request Jan 24, 2025
Use computed-goto to lower instruction dispatch overhead
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