Lapidary: Crafting more beautiful gem5 simulations

What was our Problem?

Why do we have this Problem?

The Key Insight

Our Solution: Lapidary

  1. Start up the desired program and attach it to the debugger.
  2. Based on a specified interval (usually once a second), interrupt the program through the debugger and (a) take a core dump and (b) gather register information.
  3. Transform the information gathered from gdb into gem5-formatted checkpoints. Broadly, this involves (a) inserting the appropriate register information into a gem5 checkpoint file and (b) formatting the core dump from gdb to correspond to the existing virtual memory mappings.

Some Fun Hacks

An Ongoing Process…

  1. Native integration with cloud services. so that our parallel simulations can occur across a lot of cheap instances rather than on a single massive server.
  2. Compression of checkpoints. As said earlier, we use the SMARTS approach to program sampling, which can generate several hundred checkpoints for a single benchmark. However, this can take up a lot of disk space, as each checkpoint can be up to 1GB in size. We plan on creating checkpoint “key frames”, which are full checkpoints, and then create other checkpoints just as deltas off of those key checkpoints.
  3. Support for custom instructions. Many people who use gem5 use it to prototype new instructions in the ISA. This poses a challenge for our method of creating checkpoints, as we run benchmarks on bare metal — binaries which have been compiled with custom instructions for the sake of running them on gem5 with, obviously, not work so well. Our plan for handling these cases involves (a) changing our GDB processing script to trap properly for these unknown instructions and (b) provide programmable hooks for developers to inject software to emulate these instructions on the running process state. For example, if I implement instruction foo which performs some arithmetic operations on registers r1 and r2, if I encounter instruction foo during gdb execution, I will trap and perform the same operation using combinations of existing instructions. Obviously this may not work for all cases, but we imagine this would be a suitable solution for many cases.

Closing Thoughts




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Crypto is the Github of money

Thanks for following me on Twitter. Check out to see what’s new!

Video: Big Data on Kubernetes — Make It Spark (Hebrew)

5 things to know before coding.

CS371p Spring 2022: Manasi Ramadurgum — Week 10

What you should know about Python Tuple June newsletter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ian Neal

Ian Neal

More from Medium

How I coded a disk speed tester for read/write

Fix MT5 Custom Indicator return infinity value

Retries with Tenacity lib in Python

Class vs Instance Methods