physical-computation / sunflower-embedded-system-emulator

Sunflower Full-System Hardware Emulator and Physical System Simulator for Sensor-Driven Systems. Built-in architecture modeling of Hitachi SH (j-core), RISC-V, and more.
http://sflr.org
BSD 3-Clause "New" or "Revised" License
24 stars 216 forks source link

Currently can't make memory size > 96000. #128

Open JamesTimothyMeech opened 5 years ago

JamesTimothyMeech commented 5 years ago

Describe the bug Currently can't make memory size > 96000.

To Reproduce Attempting to make the memory any larger than 96000 resulted in the following error message:


[ID=1 of 2][PC=0x8000000][3.3E+00V, 6.0E+01MHz] sizemem     9600000
Set memory size to 9375 Kilobytes

    Exiting: Cannot compute required number of covariances without overflow

    Writing all node information to sunflower.out ```

This is currently preventing me from loading a .sr file with a size > 96000.

**Expected behavior**
should be able to make the memory size at least 9600000 from previous evidence 

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Host OS (please complete the following information):**
 - OS: (e.g., macOS 10.9).
 - Browser (e.g., Chrome or Safari).
 - Version (e.g., 22).

**You local changes (please complete the following information):**
 - Output of `git diff`.
- Output of `git remote -v`.

**Additional context**
Add any other context about the problem here.
harrysarson commented 5 years ago

Ah sorry! This one is my fault.

When doing uncertainty propagation in sunflower we need a (fairly huge) amount of memory to store covariances. As the implementation was left after finishing my masters, we support covariances between any two floats stored in memory.

The amount of memory that needs allocating is ((bytes of normal memory) / 4) ^ 2 (I think?) and for fairly small values of (bytes of normal memory) more than 2^32 bytes need allocating causing this failure.

The problem here is sunflower allocates all this memory (easily over 1GB) even when users have no intention of considering uncertainties - even if the user requests less than 960,000 bytes of memory it is still a bug to allocate all this memory that will never be used. I should have made the allocation conditional on a runtime or compile time flag - sorry!

I forget exactly where the offending code is but it should be easily found by grepping for the error message. A tempory solution would be to comment out this code (the allocation not just the assertion).

phillipstanleymarbell commented 4 years ago

Related to #119