Multi-threaded Program on SESC
来源:互联网 发布:山东省广电网络集团 编辑:程序博客网 时间:2024/06/05 01:02
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 contiguousSegmentation 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 yoursescutils 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/include2. Create a static library:mipseb-linux-ar rcs libapp.a *.oIn order to compile your own program for running in SESC you have touse 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
- Multi-threaded Program on SESC
- Using libssh2 in a multi-threaded program/library
- Using OpenMP (一) Write a multi threaded program
- Using Multi-Threaded Tests
- Multi-threaded design patterns -- Single Threaded Execution
- Installing SESC simulator on Fedora 13
- Multi-threaded (/MT) 和Multi-threaded DLL (/MD)的区别
- heap mgmt and multi-threaded.
- Introduction to Multi-threaded Code
- Multi-Threaded Libevent Server Example
- Implements a multi-threaded Web proxy server
- Boost Asio multi-threaded blocking server/client
- centos源码安装多线程memcached multi-threaded
- Volatile: Almost Useless for Multi-Threaded Programming
- Multi-threaded Client/Server Socket Class
- Multi-threaded Client/Server Socket Class
- Multi-threaded Client/Server Socket Class
- CWnd Derived MFC Objects and Multi-threaded Applications
- 【Android应用开发】-(17)获取Google天气预报通过Xml和JSON解析数据
- 关于javascript的继承
- 同步传输和异步传输有什么区别?
- 为什么证书和配置文件设置正确以后,xcode还是不能发现真机
- 算法导论14.3-7
- Multi-threaded Program on SESC
- matlab稀疏矩阵创建及实例
- usaco Cryptarrithm
- 算法导论14.3-3
- Windows7 启动 防火墙
- 自动化测试的反思
- 位操作点滴
- 算法导论14.3-4
- 堆的书中实现