Cross-Compiling SPEC2006 benchmarks for Alpha ISA on Ubuntu 12.04 x86-64

Mark Gottscho | Oct 31, 2013 min read

This guide will show you how to cross-compile SPEC2006 for Alpha using your regular old Ubuntu machine running on Intel. In particular, I have done this so that they can be run in gem5 for the Alpha ISA. I assume that you have a copy of the SPEC benchmarks and the input vectors.

Extract SPEC2006 from the tarball to a directory, say, SPEC_UNPACK:

tar -xzf YOUR_SPEC2006.tar.gz /SOME/PATH/TO/SPEC_UNPACK

Change to the unpacked directory.

cd /SOME/PATH/TO/SPEC_UNPACK

OPTIONAL: Use the install script provided with SPEC to copy the relevant files to an installation location. I believe this was originally intended for SPEC distributed on a read-only disk, hence the need to copy. But if you extracted from a tarball, I think the files end up being the same.

./install.sh -d /SOME/PATH/TO/INSTALL

Download and install the cross compilers for Alpha, either pre-compiled or do it yourself. I downloaded the pre-compiled crosstool as suggested by the SPEC2006 page at gem5.org. I placed the pre-compiled binaries in some packages directory I had in my home directory.

Make sure you are in the installation root for SPEC.

Source the SPEC shell setup file to prepare your environment.

source shrc

Create your own configuration file based on linux64-amd64-gcc42.cfg, as there is not one pre-existing for the Alpha ISA.

cd config/
cp linux64-amd64-gcc42.cfg my-alpha-hack.cfg

Modify your new configuration file using your text editor of choice (e.g., vim, emacs, nano…​) to correctly point to your cross-compiler installation. Navigate to to the following lines in the config (yours may have different default paths, these are not the actual locations of the compilers on my Ubuntu system).

CC = /usr/local/sles9/gcc42-0325/bin/gcc
CXX = /usr/local/sles9/gcc42-0325/g++
FC = /usr/local/sles9/gcc42-0325/bin/gfortran

Change these three compiler locations to the appropriate ones installed with crosstool.

CC = YOUR_ALPHA_CROSS_COMPILE_GCC_BINARY
CXX = YOUR_ALPHA_CROSS_COMPILE_G++_BINARY
FC = YOUR_ALPHA_CROSS_COMPILE_GFORTRAN_BINARY

Navigate to the following lines in the configuration:

COPTIMIZE = -O2
CXXOPTIMIZE = -O2
FOPTIMIZE = -O2

Add the static linking flag to the optimization parameters. We want to do this so that gem5 can run the SPEC binaries completely standalone.

COPTIMIZE = -O2 -static
CXXOPTIMIZE = -O2 -static
FOPTIMIZE = -O2 -static

OPTIONAL: Update the rest of the configuration file if you want, but it’s not really important unless you plan to publish official results using SPEC. But since I was targeting a simulated system in gem5, I didn’t care.

Save and exit the config file you edited and navigate back to the root of the SPEC installation.

cd ..

Now try building a SPEC benchmark, e.g. bzip2, and make sure the build completes successfully.

runspec --config=my-alpha-hack.cfg --action=build --tune=base bzip2

Try running the benchmark you built (e.g. bzip2) benchmark with the test data set. Note that since you cross-compiled for Alpha using an x86-64 system, you CANNOT run the binary natively (duh). Use the system that you actually intended to run on (in my case, gem5 simulating an Alpha system, but running SPEC2006 inside gem5 will be the next tutorial, so I’ll omit the details here). Make sure the benchmark completes successfully.

runspec --config=my-alpha-hack.cfg --size=test --noreportable --tune=base --iterations=1 bzip2

Try running bzip2 benchmark with the full data set, now. If this completes, then we are ready to build the whole suite.

runspec --config=my-alpha-hack.cfg --size=ref --noreportable --tune=base --iterations=1 bzip2

Build the rest. In my case, a few of the benchmarks failed to build for various reasons. If this happens, I suggest you Google the error message. Lots of things can go wrong in a software build! =)

runspec --config=my-alpha-hack.cfg --action=build --tune=base all

Good luck! If you have any suggestions or feedback for this tutorial, don’t hesitate to comment below.

comments powered by Disqus