-
Notifications
You must be signed in to change notification settings - Fork 103
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
Improve memory read/write #123
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.
Since the misaligned memory access is optional, we don't have to check it for the internals of emulator. Instead, we can register the callback functions while initializing the emulator.
See async.h and async.c for details.
/* API gateway */
struct __ASYNC_API__ Async = {
.create = async_create,
.signal = async_signal,
.wait = async_wait,
.finish = async_finish,
.run = async_run,
};
Once you prepare the functions specialized for both misaligned memory and strictly-aligned memory access, the proper I/O implementations can be hooked up. Consequently, you don't have to check allow_ misalign
all the time.
What else do you consider it would be beneficial to employ in place of Spike for faster interpreting? |
But the memory I/O implemention for for both misaligned memory and strictly-aligned memory access is the same, the only difference is that we need to handle exception if misaligned memory access is disabled. |
Then, you can hook exception handlers which are aware of misaligned memory access by means of runtime dispatch. |
Does this means send a callback function to memory read/ write? Because we don't need load/store handler if the memory misaligned access is enabled. |
Sort of. In particular, we can shrink the code below: /* SW: Store Word */
RVOP(sw, {
const uint32_t addr = rv->X[ir->rs1] + ir->imm;
if (!rv->is_misaliged_enabled && unlikely(addr & 3)) {
rv->compressed = false;
rv_except_store_misaligned(rv, addr);
return false;
... by replacing with something like the following: /* SW: Store Word */
RVOP(sw, {
const uint32_t addr = rv->X[ir->rs1] + ir->imm;
RV_EXC_MISAGLIN_HANDLER(); /* some macro */ Meanwhile, we can hide the implementation details about |
81c0276
to
d54dd15
Compare
d54dd15
to
5fa2782
Compare
5fa2782
to
21a4036
Compare
21a4036
to
17931d9
Compare
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.
Integrate memory pool in conjunction of proposed memory operation changes.
78aa320
to
a159260
Compare
a159260
to
57069ea
Compare
be35ed3
to
6936a4f
Compare
95b68af
to
3785d16
Compare
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.
Append Close #122
at the end of git commit messages.
e7898e9
to
9a64da0
Compare
src/mpool.h
Outdated
*/ | ||
#pragma once | ||
|
||
#include <stdlib.h> |
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.
Only <stddef.h>
should be included here.
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.
The gcc-12 compiler shows the warning when I only include <stddef.h>
.
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 don't think so.
gcc-12 -c mpool.h -Wall
It compiles without warnings. The actual header inclusion should appear in C source files.
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.
Rephrase the git commit message as following:
After analyzing the data collected during the execution of the Dhrystone benchmark, it was discovered that the primary performance bottleneck lies in memory read/write operations. To address this issue, modifications were made to the implementation of memory read/write operations, eliminating unnecessary checks and replacing slow operations with more efficient ones. Additionally, a simple memory pool was integrated. It is now possible for the user to enable misaligned memory access by launching with option "--misalign".
The enhancements made to the memory I/O resulted in a significant improvement, as observed through performance results obtained by running Dhrystone.
9a64da0
to
c54ba4f
Compare
c54ba4f
to
1a6af78
Compare
After analyzing the data collected during the execution of the Dhrystone benchmark, it was discovered that the primary performance bottleneck lies in memory read/write operations. To address this issue, modifications were made to the implementation of memory read/write operations, eliminating unnecessary checks and replacing slow operations with more efficient ones. Additionally, a simple memory pool was integrated. It is now possible for the user to enable misaligned memory access by launching with option "--misalign". The enhancements made to the memory I/O resulted in a significant improvement, as observed through performance results obtained by running Dhrystone. | Test | 66200d0 | improvement |Speedup| |------------+--------------+-----------------+-------| | Dhrystone | 815 DMIPS | 1245 DMIPS | +52.7%| Close sysprog21#122
1a6af78
to
78112c3
Compare
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.
Append a test item which triggers option --misalign
in GitHub Actions. That is, we shall regularly validate the case when misaligned memory access is allowed for CI pipeline.
After analyzing the data collected during the execution of the Dhrystone benchmark, we found that the primary performance bottleneck lies in memory read/write operations. To address this issue, we modified the implementation of memory read/write by eliminating unnecessary checks and replacing slow operations with more efficient ones. Additionally, we integrated a simple memory pool and resolved the issue of disabled unaligned memory access, the user can add argument
--misalign
to enable misaligned memory access.After analyzing the performance results from running Dhrystone, we observed a significant improvement following our enhancements to the memory I/O.
See: #122