Multi-threaded Program on SESC

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:

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: 

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

And link it with:

Comment: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


Issues

  • pthread_create returns -1 on an error. Since sesc_spawn returns the number of the thread, it is not possible to detect errors here.

===

相关:

 

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:anonymous@sesc.cvs.sourceforge.net:/cvsroot/sesc login (When password is requested, just press enter)

cvs -z3 -d:pserver:anonymous@sesc.cvs.sourceforge.net:/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:

  • Be sure that flex and bison is already instaled.
  • Error: USHRT_CHAR undefined
    • Solution: Add #include file in esesc/src/libcore/FetchEngine.cpp file.
  • Error: linux/dirent.h: No such file or directory
    • Solution: Change #include <linux/dirent.h> to #include at line 52
  • Error: ‘uint32_t’ was not declared in this scope
    • Solution: add #include <stdint.h> wherever you see this error.
  • Error: “/usr/bin/ld: cannot find -lz”
    • Solution: sudo apt-get install zlib1g-dev

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;

  • Number of Processors [2-32]
  • Processor Issue Width [1-8]
  • L1 Instr. Cache Size [2048-16384]
  • L1 Data Cache Size [2048-16384]
  • L2 Private Cache Size [32768-262144]
  • L1 Instr. Cache Associativity  [1-8]
  • L1 Data Cache Associativity [1-8]
  • L2 Data Cache Associativity [1-8]
  • I/D/L2 Cache Block Size [16-32]

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.

 

===

Compiling your own application using SESCUtils

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值