Difference between revisions of "BBench-gem5"

From gem5
Jump to: navigation, search
(Running BBench on Android with gem5)
 
(104 intermediate revisions by 8 users not shown)
Line 1: Line 1:
This page provides everything you need to get Android, and BBench, working on gem5. BBench is a new web-page rendering benchmark; you can read about it here: [[BBench]]. We have provided pre-compiled disk images and an Android kernel, as well as step-by-step instructions on how to get Android running on gem5 using the ARM ISA.
+
Note that the ICS images are deprecated. Please see the instructions for [[Android_KitKat|running Android on gem5]] and [[WA-gem5|how to use workload automation]].
  
== Running BBench on Android with gem5 ==
+
== Tips for Making Your Disk Image gem5 Friendly ==
Everything required to run BBench on gem5 is provided in the next section. You will need the kernel, the disk image (containing BBench), and the rcS script.
+
====Speeding Up the Boot Process====
 +
When a fresh Android image is booted it generates a lot of files and does a lot of JIT compiling; this can slow down the boot process significantly. gem5 uses a copy-on-write (COW) layer between the simulator and the actual disk image, because of this COW layer none of the changes are stored to the disk image. To make these changes permanent, and avoid having to repeat them in the future, you can remove the COW layer during the first boot of an image. This will significantly speedup future runs. To do so make the following changes to <code>configs/common/FSConfig.py</code>:
  
# Create a directory where you will place your gem5 full-system files, call this directory ''system''. Inside this directory create two separate directories, one called ''binaries'' and the other called ''disks''. This can be the same directory in which you already have gem5 full-system files that you downloaded from the [[Download]] page.
+
<code>
# Point the <code>M5_PATH</code> environment variable to this location. E.g, type <code>export M5_PATH=path_to_gem5_system/system/</code>
+
    class RawIdeDisk(IdeDisk):
# Place the kernel in the <code>path_to_gem5_system/system/binaries/</code> directory
+
        image = RawDiskImage(read_only=False)
# Place the disk image in the <code>path_to_gem5_system/system/disks/</code> directory
+
        def childImage(self, ci):
# Build the ARM bootloader and place it in the same directory as the kernel. The code for the bootloader is typically in <code>path_to_gem5_root/system/arm/simple_bootloader/</code>. Simply type <code>make</code> in this directory and the bootloader will be compiled. Copy the resulting <code>boot.arm</code> file to the same directory where you kernel is located. E.g., <code>path_to_gem5_system/system/binaries/</code>. Note this is also available within the ARM Full system files on the [[Download]] page.
+
            self.image.image_file=ci
# The default gem5 scripts look for a kernel called <code>vmlinux.arm.smp.fb.2.6.38.8</code> and a disk image called <code>android-mbr.img</code>. You will have to either rename the files or create softlinks to them once you have downloaded and untarred them.
+
</code>
# The <code>bbench.rcS</code> file should be placed wherever you keep your rcS scripts. This is typically <code>path_to_gem5_root/configs/boot/</code>.
 
# You will also need to modify your Benchmarks.py file to include bbench, i.e., include a line like the following: <code>'bbench':    [SysConfig('bbench.rcS', '256MB', 'ARMv7a-Gingerbread-Android.SMP.mouse.nolock.img')]</code>
 
# Assuming you have followed the steps above, and built a full-system version of gem5 for ARM, you should be able to type <code>/path_to_gem5_root/build/ARM_FS/m5.fast configs/example/fs.py -b bbench --vmlinux=vmlinux.smp.mouse.arm</code> to run BBench on Android using ARM.
 
  
'''Note: These instructions and images are only for Android on the ARM ISA.'''
+
Then, inside of <code>makeArmSystem()</code>, change from:
  
== Android Full-System Files ==
+
<code>
These files contain everything you need to get Android, and BBench, up and running on gem5.
+
    self.c0 = CowIdeDisk(driveID='master')
 +
</code>
  
* [http://www.gem5.org/dist/current/bbench/vmlinux_and_config_arm.tgz Kernel] -- Pre-compiled Android kernel and config file.
+
to
  
* [http://www.gem5.org/dist/current/bbench/Gingerbread_disk_image.tgz Disk Image] -- Disk image with a pre-compiled Android Gingerbread file system. This disk image contains all of the files generated during initial boot, as well as a self-terminating version of BBench and BusyBox.
+
<code>
 +
    self.c0 = RawIdeDisk(driveID='master')
 +
</code>
  
* [http://www.gem5.org/dist/current/bbench/Gingerbread_disk_image_clean.tgz Clean Disk Image] -- Disk image containing only the pre-compiled Android Gingerbread file system. This disk image contains no benchmarks and has never been booted.
+
Be careful when doing this. Any changes made to the disk image will be permanent when using the raw ide disk. To ensure that all the changes are written to the disk image properly you can use the <code>sync</code> and <code>halt</code> Linux commands. These are not available on Android so it is recommended that you use something like [http://busybox.net BusyBox]. Once the image has finished booting and has settled, you can run <code>busybox sync</code> and <code>busybox halt -f</code> from a gem5 terminal to write all changes to the disk and halt it properly. You will likely get a panic when the simulator exits regarding an unrecognized byte, however, this doesn't seem to cause any problems. Remember to re-enable the COW layer once you've finished setting up your disk image.
  
* [http://www.gem5.org/dist/current/bbench/bbench.rcS rcS Script] -- Script for automating a BBench run on gem5. The disk images above contain modified startup scripts that load and execute rcS scripts.
+
====BusyBox====
 +
[http://busybox.net BusyBox] is a useful tool providing many common Linux utilities for embedded systems. To build busybox, download the source and compile statically using the following commands:
 +
# <code>make CROSS_COMPILE=arm-none-linux-gnueabi- defconfig</code>
 +
# <code>LDFLAGS="--static" make CROSS_COMPILE=arm-none-linux-gnueabi- -jn</code>
  
== Building Your Own Android File System and Kernel ==
+
Place the busybox binary into the <code>/sbin/</code> directory of your Android file-system. Run <code>busybox --help</code> to see a full list of the available utilities.
Coming Soon!
+
 
 +
====Android Init Process====
 +
To have your benchmarks start automatically you will likely need to modify the <code>init.rc</code> script located in the file-system's root directory. You can see the changes made to the <code>init.rc</code> script for BBench by looking at the <code>init.rc</code> script in the images we distribute with BBench, this may be a useful template. Another useful resource for understanding the init process is located [http://www.kandroid.org/online-pdk/guide/bring_up.html here].
 +
 
 +
====m5 Utility====
 +
You will likely need the <code>m5</code> utility, whose source is located in <code>util/m5/</code>, to do anything useful with your disk image. Build this (statically) and place it in the <code>/sbin/</code> directory of your Android file-system.
  
 
== Publications ==
 
== Publications ==
If you use BBench or any of our benchmarks in your work please cite our [http://www.eecs.umich.edu/~atgutier/bbench/iiswc_2011.pdf IISWC 2011 paper]:
+
If you use BBench in your work please cite our [http://dx.doi.org/10.1109/IISWC.2011.6114205 IISWC 2011 paper]:
  
 
A. Gutierrez, R.G. Dreslinski, T.F. Wenisch, T. Mudge, A. Saidi, C. Emmons, and N. Paver. Full-System Analysis and Characterization of Interactive Smartphone Applications. ''IEEE International Symposium on Workload Characterization'', pages 81-90, Austin, TX, November 2011.
 
A. Gutierrez, R.G. Dreslinski, T.F. Wenisch, T. Mudge, A. Saidi, C. Emmons, and N. Paver. Full-System Analysis and Characterization of Interactive Smartphone Applications. ''IEEE International Symposium on Workload Characterization'', pages 81-90, Austin, TX, November 2011.

Latest revision as of 05:58, 20 March 2016

Note that the ICS images are deprecated. Please see the instructions for running Android on gem5 and how to use workload automation.

Tips for Making Your Disk Image gem5 Friendly

Speeding Up the Boot Process

When a fresh Android image is booted it generates a lot of files and does a lot of JIT compiling; this can slow down the boot process significantly. gem5 uses a copy-on-write (COW) layer between the simulator and the actual disk image, because of this COW layer none of the changes are stored to the disk image. To make these changes permanent, and avoid having to repeat them in the future, you can remove the COW layer during the first boot of an image. This will significantly speedup future runs. To do so make the following changes to configs/common/FSConfig.py:

   class RawIdeDisk(IdeDisk):
       image = RawDiskImage(read_only=False)
       def childImage(self, ci):
           self.image.image_file=ci

Then, inside of makeArmSystem(), change from:

   self.c0 = CowIdeDisk(driveID='master')

to

   self.c0 = RawIdeDisk(driveID='master')

Be careful when doing this. Any changes made to the disk image will be permanent when using the raw ide disk. To ensure that all the changes are written to the disk image properly you can use the sync and halt Linux commands. These are not available on Android so it is recommended that you use something like BusyBox. Once the image has finished booting and has settled, you can run busybox sync and busybox halt -f from a gem5 terminal to write all changes to the disk and halt it properly. You will likely get a panic when the simulator exits regarding an unrecognized byte, however, this doesn't seem to cause any problems. Remember to re-enable the COW layer once you've finished setting up your disk image.

BusyBox

BusyBox is a useful tool providing many common Linux utilities for embedded systems. To build busybox, download the source and compile statically using the following commands:

  1. make CROSS_COMPILE=arm-none-linux-gnueabi- defconfig
  2. LDFLAGS="--static" make CROSS_COMPILE=arm-none-linux-gnueabi- -jn

Place the busybox binary into the /sbin/ directory of your Android file-system. Run busybox --help to see a full list of the available utilities.

Android Init Process

To have your benchmarks start automatically you will likely need to modify the init.rc script located in the file-system's root directory. You can see the changes made to the init.rc script for BBench by looking at the init.rc script in the images we distribute with BBench, this may be a useful template. Another useful resource for understanding the init process is located here.

m5 Utility

You will likely need the m5 utility, whose source is located in util/m5/, to do anything useful with your disk image. Build this (statically) and place it in the /sbin/ directory of your Android file-system.

Publications

If you use BBench in your work please cite our IISWC 2011 paper:

A. Gutierrez, R.G. Dreslinski, T.F. Wenisch, T. Mudge, A. Saidi, C. Emmons, and N. Paver. Full-System Analysis and Characterization of Interactive Smartphone Applications. IEEE International Symposium on Workload Characterization, pages 81-90, Austin, TX, November 2011.