Thursday, December 25, 2008

Compiling SimpleScalar Simulator on Linux

SimpleScalar.com provides "fast, flexible and extensible infrastructure for hardware modeling and software analysis."

Their code was last updated in late 2003, but based on 1997 code-base. I got a lot of warnings and errors that prevented the compilation. With some help from twkm from #c on DALnet (IRC), I was able to complete the compilation process (though with warnings still).

I will mention what I have modified in the files, then I'll provide you with a script and .diff files to do the whole patching and compilation process automatically. This also includes the compilation of the SPEC2000int package (compiled against simplesim-ALPHA only).

The files simplesim-3v0d.tgz and SPEC2000int.tgz are hosted on this site (which also provides a guide).

Changes


Open simplesim-3.0/target-alpha/alpha.h: Shift the line 224 to line 239.
-> "extern enum md_opcode md_mask2op[];"
Move it such that it's above this line: "/* enum md_opcode -> description string */"

After extracting SPEC2000int package, the Makefile inside needs one line to point at the directory containing the simplesim-3.0 directory.
-> "/home/students//"
Here's a sample directory hierarchy to understand:
-/
--home
---username
----tmp
-----simplesim-3.0
Your path will be: /home/username/tmp

Scripts & Automagic!


1) Create a directory in your home directory and call it: simtmp
2) Create a file called machine.diff inside simtmp
3) Put the following inside it:
--- simplesim-3.0/target-alpha/alpha.h 2003-10-09 05:14:23.000000000 +0300
+++ simplesim-3.0-fixed/machine.h 2008-12-24 14:02:22.000000000 +0300
@@ -221,7 +221,6 @@
#define MD_MAX_MASK 2048

/* internal decoder state */
-extern enum md_opcode md_mask2op[];
extern unsigned int md_opoffset[];
extern unsigned int md_opmask[];
extern unsigned int md_opshift[];
@@ -236,6 +235,8 @@
OP_MAX /* number of opcodes + NA */
};

+extern enum md_opcode md_mask2op[];
+
/* enum md_opcode -> description string */
#define MD_OP_NAME(OP) (md_op2name[OP])
extern char *md_op2name[];


4) Create a file called setup.sh inside simtmp and put this in it:
#!/bin/bash
echo Extracting simplesim
/bin/tar -xf simplesim-3v0d.tgz

echo Patching simplesim
cd `pwd`
patch -p0 < `pwd`/machine.diff

echo Extracting SPEC
/bin/tar -xf SPEC2000int.tgz

echo Creating results directory
mkdir Results

echo Compile simplesim ALPHA
cd simplesim-3.0
make config-alpha
make

echo Update SPEC Makefile
cd ../
THISDIR=`pwd`
cd SPEC2000int
sed '19s:/home/students/<YOUR USERNAME>/<PATH TO YOUR SIMPLESCALAR DIRECTORY>:'$THISDIR':' ./Makefile > specmake
rm Makefile
mv specmake Makefile

echo Compile SPEC
make


5) cd /home/username/simtmp
Make sure the two packages (simplesim & SPEC2000int) are downloaded here. Don't extract them!
6) chmod +x setup.sh
7) ./setup.sh

That's it. The setup file will extract, patch & compile the programs for you. The result of the spec2000int benchmark will be in a directory called Results in the etderr files.

5 comments:

Anonymous said...

sounds cool, but I didn't understand anything ! would be awesome if you wrote a simple one non-techy paragraph describing of what it does and what applications can benefit from that.

MBH said...

As the first paragraph says: SimpleScalar.com provides "fast, flexible and extensible infrastructure for hardware modeling and software analysis."

There's nothing none technical to share unfortunately since this is a hardware circuit simulator ;)

Yogesh Varma (Yo!) said...
This comment has been removed by the author.
Yogesh Varma (Yo!) said...

Nice instructions. I was able to compile the same for PISA target using various tutorials. However, sstrix- cross compiler that shall be used to compile SPEC apps does not work right away for more than 7 of SPEC200CINT applications. The problem may be that the SS toolset is based on the then (1997) version of gnu-toolchain. Any experiences with compiling SPEC2000 vpr, crafty, eon, gap, etc will be great. The successrate with SPEC2006 is likely to be even less.

Have you also tried MASE (or SimpleScalar 4) toolset? Apparantly MASE has done away with the RUU in favor of more mainstream RoB structure.

MBH said...

I'm not the one who was working on SimpleScalar. I just helped compile the code.

I was able to compile it with PISA without problems though, and without tweaks.

If you need specific help to SimpleScalar or any of the packages that come with it, you could try emailing the authors, or if you face compilation problems you could come to #c or #linux on DALnet and ask the guys there.