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

Fix insufficient memory on some platforms #449

Closed

Conversation

tony2037
Copy link

[Problem]
The MEM_SIZE is hard-corded, but on some platforms, memory is insufficient.
Perhaps we should allow user to config accordingly

[Solution]
Expose an environment variable, CONFIG_MEM_SIZE, to allow user config the memory size with it

[Test]

  • before $> make
    $> ./build/rv32emu ./build/hello.elf
    rv32emu: src/riscv.c:199: rv_create: Assertion `attr->mem' failed. Aborted (core dumped)

  • after $> CONFIG_MEM_SIZE=0x40000000 make
    $> ./build/rv32emu ./build/hello.elf
    Hello World!
    Hello World!
    Hello World!
    Hello World!
    Hello World!
    inferior exit code 0

[Reference]
#488

[Problem]
The MEM_SIZE is hard-corded, but on some platforms, memory is
insufficient.
Perhaps we should allow user to config accordingly

[Solution]
Expose an environment variable, CONFIG_MEM_SIZE, to allow user config
the memory size with it

[Test]
* before
$> make
$> ./build/rv32emu ./build/hello.elf
rv32emu: src/riscv.c:199: rv_create: Assertion `attr->mem' failed.
Aborted (core dumped)

* after
$> CONFIG_MEM_SIZE=0x40000000 make
$> ./build/rv32emu ./build/hello.elf
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
inferior exit code 0

[Reference]
[sysprog21#488](sysprog21#448)
@jserv
Copy link
Contributor

jserv commented May 27, 2024

I don't think the proposed change resolves the insufficient memory issue because it just relies on compile-time configurations instead of an adaptive approach to acquire the necessary system resources based on the requirements of RISC-V programs during instruction simulation.

@qwe661234, can you comment this?

@qwe661234
Copy link
Collaborator

This issue arises when the memory size is insufficient, especially when running rv32emu on a VM. However, arbitrarily setting a MEM_SIZE to pass specific tests can cause segmentation faults in other tests. A better solution is to revert to the original virtual memory implementation when memory size is insufficient, allocating memory only as needed for read or write operations.

@qwe661234
Copy link
Collaborator

qwe661234 commented Jun 3, 2024

After investigation, you can set MEM_SIZE to 0x80000 to run the benchmarks in directory tests. However, if you want to run some video games like doom or quake, the 4G memory is required.

@jserv jserv requested a review from henrybear327 June 17, 2024 14:18
@jserv jserv added this to the release-2024.1 milestone Sep 1, 2024
@jserv
Copy link
Contributor

jserv commented Sep 1, 2024

Reworked in commit feca1de

@jserv jserv closed this Sep 1, 2024
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.

4 participants