fwsGonzo / libriscv

The fastest RISC-V sandbox
BSD 3-Clause "New" or "Revised" License
522 stars 46 forks source link

Add experimental unbounded 32-bit arena support #156

Closed fwsGonzo closed 2 weeks ago

fwsGonzo commented 2 weeks ago

The initial code to map the entire 4GB address space for 32-bit guests in order to avoid bound-checks on memory reads and writes. So far the performance increase is fairly modest, < 10%.

$ VERBOSE=1 ./rvlinux -v ~/github/coremark/coremark-rv32g_b 
* Loading program of size 75145 from 0x7f6ba52ec010 to virtual 0x10000
* Program segment readable: 1 writable: 0  executable: 1
* Loading program of size 1864 from 0x7f6ba52fe59c to virtual 0x2358c
* Program segment readable: 1 writable: 1  executable: 0
* Entry is at 0x109f4
2K performance run parameters for coremark.
CoreMark Size    : 666
Total ticks      : 14508
Total time (secs): 14.508000
Iterations/Sec   : 20678.246485
Iterations       : 300000
Compiler version : GCC13.2.0
Compiler flags   : -O3 -DPERFORMANCE_RUN=1  
Memory location  : Please put data memory location here
            (e.g. code in flash, data on heap etc)
seedcrc          : 0xe9f5
[0]crclist       : 0xe714
[0]crcmatrix     : 0x1fd7
[0]crcstate      : 0x8e3a
[0]crcfinal      : 0xcc42
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 20678.246485 / GCC13.2.0 -O3 -DPERFORMANCE_RUN=1   / Static
>>> Program exited, exit code = 0 (0x0)
Instructions executed: 119355767074  Runtime: 19870.079ms  Insn/s: 6007mi/s
Pages in use: 25 (100 kB virtual memory, total 319 kB)
fwsGonzo commented 2 weeks ago

TCC benefitted from using a static arena pointer, instead of the indirection.

$ VERBOSE=1 ./rvlinux -v ~/github/coremark/coremark-rv32g_b 
* Loading program of size 75145 from 0x79187a6ef010 to virtual 0x10000
* Program segment readable: 1 writable: 0  executable: 1
* Loading program of size 1864 from 0x79187a70159c to virtual 0x2358c
* Program segment readable: 1 writable: 1  executable: 0
Emitted 17963 accelerated instructions and 1312 functions. GP=0x23FF8
* Entry is at 0x109f4
2K performance run parameters for coremark.
CoreMark Size    : 666
Total ticks      : 20269
Total time (secs): 20.269000
Iterations/Sec   : 5427.006759
Iterations       : 110000
Compiler version : GCC13.2.0
Compiler flags   : -O3 -DPERFORMANCE_RUN=1  
Memory location  : Please put data memory location here
            (e.g. code in flash, data on heap etc)
seedcrc          : 0xe9f5
[0]crclist       : 0xe714
[0]crcmatrix     : 0x1fd7
[0]crcstate      : 0x8e3a
[0]crcfinal      : 0x33ff
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 5427.006759 / GCC13.2.0 -O3 -DPERFORMANCE_RUN=1   / Static
>>> Program exited, exit code = 0 (0x0)
Instructions executed: 35161346339  Runtime: 22312.225ms  Insn/s: 1576mi/s
Pages in use: 25 (100 kB virtual memory, total 319 kB)