RiP-Sim is an innovative 32-bit RISC-V (RV32IM) Simulator, currently under active development. This project stands out by integrating Reservoir Computing into branch prediction, a novel approach in the realm of processor simulation. As a Work in Progress, RiP-Sim invites contributions and feedback from the community, particularly from those interested in processor architecture or reservoir computing.
A notable feature of RiP-Sim is its Python wrapper, which allows users to test and develop their own branch predictor models. This interface provides good accessibility and customization. Users can implement and evaluate complex branch prediction algorithms, like reservoir computing models, directly within the simulation environment.
rbp = ESN_RLS(reservoir_dim=100, input_dim=input_dim, output_dim=1)
while True:
trap = rsim.proceed()
if trap == RIPSimulator.Trap.EBREAK:
break
elif trap == RIPSimulator.Trap.BRANCH_PRED:
rbp.train(rsim.previous_branch_result)
inputs = create_inputs(rsim)
rsim.predict(rbp.predict(inputs))
else:
assert False, "unreachable!"
This aspect of RiP-Sim allows for the exploration of complex algorithms within the simulator, offering an extra layer of experimentation and customization for enthusiasts and researchers.
The project requires cmake, ninja-build as dependencies. On Ubuntu/Debian, use
sudo apt-get install cmake ninja-build
or on mac, use
brew install cmake ninja-build
to install dependencies.
git submodule update --init
cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release
ninja -Cbuild
or you can use debug build with/without sanitizers to see a tons of simulation dumps.
cmake -GNinja -Bbuild -DSANITIZE=ON -DCMAKE_BUILD_TYPE=Debug
ninja -Cbuild
ninja -Cbuild unittests
ninja -Cbuild sim-unittests
ninja -Cbuild rip-unittests
ninja -Cbuild pytest
$ ./build/bin/rip-sim rip-tests/dhry.bin --dram-size=268435456 --stats
break happens
========== BEGIN STATS ============
Total stages: 122543
...
$ ./build/bin/rip-sim rip-tests/dhry.bin --dram-size=268435456 --stats -b=onebit
break happens
========== BEGIN STATS ============
Total stages: 121692
...
BP accuracy: 0.692761 (Hit :10938, Miss :4851)
=========== END STATS =============
$ ./build/bin/rip-sim rip-tests/dhry.bin --dram-size=268435456 --stats -b=twobit
break happens
========== BEGIN STATS ============
Total stages: 119889
...
BP accuracy: 0.754893 (Hit :11919, Miss :3870)
=========== END STATS =============
$ ./build/bin/rip-sim rip-tests/dhry.bin --dram-size=268435456 --stats -b=gshare
break happens
========== BEGIN STATS ============
Total stages: 116617
...
BP accuracy: 0.88986 (Hit :14050, Miss :1739)
=========== END STATS =============
$ ./build/bin/rip-sim rip-tests/dhry.bin --dram-size=268435456 --stats -b=perceptron
break happens
========== BEGIN STATS ============
Num Stages= 116298
...
BP accuracy: 0.917474 (Hit :14486, Miss :1303)
=========== END STATS =============
$ ./build/bin/rip-sim rip-tests/dhry.bin --dram-size=268435456 --stats -b=perceptron
break happens
========== BEGIN STATS ============
Num Stages= 115996
...
BP accuracy: 0.931028 (Hit :14700, Miss :1089)
=========== END STATS =============
break happens
========== BEGIN STATS ============
Num Stages= 115821
...
BP accuracy: 0.940148 (Hit :14844, Miss :945)
=========== END STATS =============
break happens
========== BEGIN STATS ============
Num Stages= 115797
...
BP accuracy: 0.941352 (Hit :14863, Miss :926)
=========== END STATS =============