Got it here: http://ce.et.tudelft.nl/~pepijn/doc/sesc.html
http://dongrui-she.net/dokuwiki/doku.php?id=notes:simulators:sesc:multi-thread-howto
Assume we have a multi-threaded program like this:
#include <pthread.h> #include <stdio.h> #define NUM_THREADS 5 void *print_hello_world(void *threadid) { printf("/n%d: Hello World!/n", threadid); pthread_exit(NULL); } int main() { pthread_t threads[NUM_THREADS]; int t; for(t=0;t<NUM_THREADS;t++){ printf("Creating thread %d/n", t); pthread_create(&threads[t], NULL, print_hello_world, (void *)t); } pthread_exit(NULL); }To make the program work under SESC, we have to make some adjustments. First, the program should start with a sesc_init(). Then, we also have to replace the pthread_create() pthread_exit() statements with sesc_spawn() and sesc_exit(), respectively. The program then becomes:
#include "sescapi.h" #include <stdio.h> #define NUM_THREADS 5 void *print_hello_world(void *threadid) { printf("/n%d: Hello World!/n", threadid); sesc_exit(0); } int main() { //pthread_t threads[NUM_THREADS]; int t; sesc_init(); for(t=0;t<NUM_THREADS;t++){ printf("Creating thread %d/n", t); sesc_spawn((void*) *print_hello_world,(void *) t,0); } sesc_exit(0); }
In order to compile this correctly, you have to link it againstlibapp.a according to the documentation. The sources to this library can be found in the src tree of the simulator itself. By default, it is not build. Building it withmake obj/Linux_obj/libapp.a will work, but then you have it compiled for the host system instead of forSESC.
Compile it with the following options
mipseb-linux-gcc -g -mips2 -mabi=32 -Wa,-non_shared -mno-abicalls -c -o sesc_thread.o sesc_thread.c
And link it with:
mipseb-linux-gcc -o hello.sesc hello.c -g -mips2 -mabi=32 -Wa,-non_shared -mno-abicalls sesc_thread.oComment:If you get error:ERROR: .ctors data sections not contiguous Segmentation fault
Then try to compile as follows (use -static and --script):mipseb-linux-gcc -g -mips2 -mabi=32 -Wa,-non_shared -Wl,--script=$(sescutils_HOME)/install/mipseb-linux/lib/ldscripts/mint.x -static -mno-abicalls sesc_thread.o hello.c -o hello.sesc
===
相关:
http://khawajahashim.wordpress.com/2010/06/05/configuration-of-sesc-simulator-with-power-model-smp/
The official site of SESC is from http://sesc.sourceforge.net/download.html. To download SESC simulator package use following instructions on LINUX shell. The package will be downloaded in ‘home’ directory.
cvs -d:pserver:[email protected]:/cvsroot/sesc login (When password is requested, just press enter)
cvs -z3 -d:pserver:[email protected]:/cvsroot/sesc co -P sesc
The next step is to configure SESC simulator with Power Model for SMP. Create ‘build’ directory for configured files.
> mkdir build
> cd build
Configure SESC from the build directory by providing the path of SESC package
> ../esesc/configure –enable-smp –enable-power
> make
Possible errors during make:
Test Simulation:
> make testsim
Customized Simulation:
> make sesc.conf
- ‘cactify’; for clock frequency, capacitance and power calculation
- ‘wattchify’; for energy calculation
> make cactify
> make wattchify
This configuration file (‘sesc.conf’) will be used by the simulator in order to perform simulation. In this project the following parameters will be simulated;
The instructions ‘> make cactify’ and ‘> make wattchify’ will be executed every time on changing configuration file for clock, power and energy calculation.
SPEC2000 benchmark consists of different applications that can be run on SESC Simulator in order to evaluate cycles, power, and energy performance according to the parameters set in configuration file (sesc.conf).
The following instructions will be used to obtain simulation results.
As we are in build directory containing SESC simulator files.
Make ‘benchmark’ directory in ‘build’ directory, containing applications to be run for simulation. I will use fft.mips.
> ./wattchify sesc.conf Wsesc.conf
> ./cactify Wsesc.conf CWsesc.conf
> ./sesc.smp -cCWsesc.conf -dsesc_out -fconf ../benchmark/fft.mips -p2
The switch -p2 means that run the application with 2 processors. The number of processors associated to switch -p should be the same as provided in ‘sesc.conf’ file.
The output file will be created named as ‘sesc_out.conf’, containing lot of information but we are concerned with only cycles, energy and power.
===
We need sescutils to compile our own application in SESC
http://sourceforge.net/projects/sesc/
Untar it in your home folder.
cd $HOME
tar -jxvf sescutils.tar.bz2
cd $HOME/sescutils/build-mipseb-linux
Edit build-common and change $HOME to your sescutils environment as in,
GNUSRC=/home/ram/sescutils/src
PREFIX=/home/ram/sescutils/install
Execute the 5 build scripts(sequence is very very important) as :
./build-1-binutils
You might get an error here saying "source ./build-common" not recognized(This problem might arise for all 5 build steps. Do the same carpentary work) . IN that case change #!/bin/sh to #!/bin/bash by
gedit build-1-binutils
./build-2-gcc-core
will not give you a problem. If the same problem occurs (as above) do the same.
In case
./build-3-glibc
throws an error like this :
checking build system type... Invalid configuration `unknown-linux': machine `unknown' not recognized
configure: error: /bin/bash /home/ram/sescutils/src/glibc-2.3.2/scripts/config.sub unknown-linux failed
make: *** No rule to make target `all'. Stop.
Then edit build-3-glibc
$GNUSRC/$GLIBC/configure --build=i686-linux --host=${TARGET} --prefix=${PREFIX}/${TARGET} /
--disable-shared --with-headers=$KERNHEADERS --enable-add-ons --enable-static-nss /
--disable-profile 2>&1 | tee ../glibc.conf.log
Make this change (I Found my machine's config as i686 with uname -a )
Then do a: locate version.c
/home/ram/sescutils/src/glibc-2.3.2/csu/version.c
and comment : version-info.h
It takes several minutes to complete..
Other two builds should not give you any problem
gdb configure error: no termcap library found
If you get this, then do
sudo apt-get install ncurses-developer
It should not be a problem after this:)
If you do a mipseb-linux-gcc you will get command not found
Its location is /home/ram/sescutils/install/bin/mipseb-linux-gcc
Type the following is the shell
gedit ~/.bashrc
bashrc opens. Now add the following line to the end of the file
export PATH=$PATH:/home/ram/sescutils/install/bin
save. Close the shell and restart the shell.
Do
echo $PATH
The output be some thing like
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/ram/sescutils/install/bin
You're finally done:):)
=======
Compile libapp.a:
https://lists.soe.ucsc.edu/pipermail/sesc/2010-November/000812.html
https://lists.soe.ucsc.edu/pipermail/sesc/2007-October/000309.html
Assuming that SESCUTILS_DIR is the directory where you have your sescutils package installed. 1. First, comile all sources: mipseb-linux-gcc *.c -c -ISESCUTILS_DIR/install/lib/gcc/mipseb-linux/3.4.4/include -mips2 -mabi=32 -Wa,-non_shared -mno-abicalls -ISESCUTILS_DIR/install/mipseb-linux/include 2. Create a static library: mipseb-linux-ar rcs libapp.a *.o In order to compile your own program for running in SESC you have to use a similar routine to the above one and link it with libapp (-lapp).
References:
http://khawajahashim.blogspot.com/2011/11/splash2-benchmark-kernels-applications.html