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

nemu is not deterministic #8

Open
xieby1 opened this issue Nov 12, 2024 · 4 comments
Open

nemu is not deterministic #8

xieby1 opened this issue Nov 12, 2024 · 4 comments
Assignees

Comments

@xieby1
Copy link
Collaborator

xieby1 commented Nov 12, 2024

The generated checkpoints using nemu are.not.deterministic.
In other words, if generate checkpoints twice, the md5sum of first and second generated checkpoints are different.

@eastonman
Copy link
Member

Recently I encountered a serious problem with NEMU. Running workloads twice on the same NEMU results in different instruction counts, which causes some workloads finish before the last checkpoint start.

[src/checkpoint/serializer.cpp:328,instrsCouldTakeCpt] First cpt @ 2427740000000, now: 2384600000000
[src/checkpoint/serializer.cpp:328,instrsCouldTakeCpt] First cpt @ 2427740000000, now: 2384660000000
[src/checkpoint/serializer.cpp:328,instrsCouldTakeCpt] First cpt @ 2427740000000, now: 2384680000000
[src/checkpoint/serializer.cpp:328,instrsCouldTakeCpt] First cpt @ 2427740000000, now: 2384700000000
[src/checkpoint/serializer.cpp:328,instrsCouldTakeCpt] First cpt @ 2427740000000, now: 2384720000000
[src/checkpoint/serializer.cpp:328,instrsCouldTakeCpt] First cpt @ 2427740000000, now: 2384740000000
[/build/source/src/isa/riscv64/include/../instr/special.h:38,execute] nemu_trap case 0
[src/cpu/cpu-exec.c:734,cpu_exec] nemu: HIT GOOD TRAP at pc = 0x0000000000010522
[src/cpu/cpu-exec.c:740,cpu_exec] trap code:0
[src/cpu/cpu-exec.c:94,monitor_statistic] host time spent = 25768154605 us
[src/cpu/cpu-exec.c:96,monitor_statistic] total guest instructions = 2384825716646
[src/cpu/cpu-exec.c:97,monitor_statistic] vst count = 407850, vst unit count = 407850, vst unit optimized count = 0
[src/cpu/cpu-exec.c:100,monitor_statistic] simulation frequency = 92549340 instr/s
[src/utils/state.c:30,is_exit_status_bad] NEMU exit with good state: 2, halt ret: 0

This is VERY SEVERE. If the instruction count is not deterministic, the interval provided by SimPoint is INVALID.

@Tang-Haojin
Copy link
Member

Tang-Haojin commented Dec 9, 2024

There will be a further PR in NEMU by @cebarobot. OpenXiangShan/NEMU#698 can not actually resolve this problem but causing stuck.

@cebarobot
Copy link
Member

Currently, it seems that CONFIG_DETERMINISTIC would prevent any time interrupt. It's not suprised that software will freeze.

I'm working on this now. I'm trying to link the timer with the instruction count, and also solve the CSR instret/cycle/time problem.

@eastonman
Copy link
Member

According to the code, previously when CONFIG_DETERMINISTIC is set, mtime seems to link with rdtime (or any time read). Whenever rdtime is executed, mtime increases by a certain amount. This causes the kernel to be stuck in a misaligned access speed test, which executes benchmark code while waiting for interrupt.

I've tried linking interrupt intervals with the instruction count. It did solve the stuck issue. However, there is still a risk of breaking software with too many or too few interrupts. I recommend calculating the instruction count interval using mtimecmp related information.

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

No branches or pull requests

4 participants