Cilk Plus Installation Guide
From SuperTech Wiki
(Difference between revisions)
(2 intermediate revisions not shown) | |||
Line 17: | Line 17: | ||
## Set up your environment variables to use ICC. | ## Set up your environment variables to use ICC. | ||
##: <code>$ source /path/to/intel/bin/compilervars.sh intel64</code>. | ##: <code>$ source /path/to/intel/bin/compilervars.sh intel64</code>. | ||
- | # '''Installing GCC:''' These instructions walk you through checking out and building the | + | # '''Installing GCC:''' These instructions walk you through checking out and building the latest version of GCC, which supports the Cilk keywords. Complete instructions for building GCC from source can be found at http://gcc.gnu.org/install/index.html. These instructions will install GCC into a custom directory, <code>gcc</code>, so as not to overwrite the existing version of GCC on your system. |
- | #: ''Warning'': This process takes a while and | + | #: ''Warning'': This process takes a while and use a couple gigabytes of space. |
#: ''Prerequisites'': You will need the following installed on your system. (For more information non prerequisites, please check http://gcc.gnu.org/install/prerequisites.html.) | #: ''Prerequisites'': You will need the following installed on your system. (For more information non prerequisites, please check http://gcc.gnu.org/install/prerequisites.html.) | ||
#:: <code>flex</code> or <code>lex</code> | #:: <code>flex</code> or <code>lex</code> | ||
Line 31: | Line 31: | ||
#:: <code>mpfr</code> | #:: <code>mpfr</code> | ||
#:: <code>mpc</code> | #:: <code>mpc</code> | ||
- | ## | + | ## Create some directories for the GCC source, compiled objects, and binaries: |
- | ##: <code>$ | + | ##: <code>$ mkdir /path/to/gcc</code> |
- | ##: | + | ##: <code>$ mkdir /path/to/gcc/src</code> |
- | ##: <code>$ | + | ##: <code>$ mkdir /path/to/gcc/obj</code> |
- | ## | + | ## Check out the latest version of GCC. |
- | ##: <code>$ git clone git://gcc.gnu.org/git/gcc.git gcc | + | ##: You can check out the repository using Git: |
- | + | ##: <code>$ git clone git://gcc.gnu.org/git/gcc.git gcc/src</code> | |
- | ##: | + | ## Configure GCC:. |
- | ##: <code>$ cd | + | ##: <code>$ cd /path/to/gcc/obj</code> |
- | + | ##: <code>$ ../src/configure --prefix=${PWD}/.. --enable-languages=c,c++</code> | |
- | + | ##: ''Note:'': You might want to add <code>--disable-multilib</code> to the configuration options if multilib is not installed on your system. Otherwise, you might encounter errors such as: | |
- | + | ||
- | + | ||
- | ##: <code>$ ../ | + | |
- | ##: ''Note:'': You | + | |
##: <code>gnu/stubs-32.h: No such file or directory compilation terminated.</code> | ##: <code>gnu/stubs-32.h: No such file or directory compilation terminated.</code> | ||
## Compile GCC: | ## Compile GCC: | ||
##: <code>$ make</code> | ##: <code>$ make</code> | ||
- | ## Install GCC into gcc | + | ##: ''Note:'': If you have multiple cores on your system, you can speed up this compilation using make's <code>-j<number_of_threads></code> flag. |
+ | ## Install GCC into <code>/path/to/gcc/</code>: | ||
##: <code>$ make install</code> | ##: <code>$ make install</code> | ||
- | ## The new GCC binary is <code>/path/to/gcc | + | ## The new GCC binary is <code>/path/to/gcc/bin/gcc</code>. |
## Set up the necessary environment variables. For example, if you are using bash, execute the following, or add these lines to <code>~/.bashrc</code> to set up these variables automatically when you log in. | ## Set up the necessary environment variables. For example, if you are using bash, execute the following, or add these lines to <code>~/.bashrc</code> to set up these variables automatically when you log in. | ||
- | ##: <code>$ export PATH=path/to/gcc | + | ##: <code>$ export PATH=/path/to/gcc/bin:$PATH </code> |
- | ##: <code>$ export LD_LIBRARY_PATH=path/to/gcc | + | ##: <code>$ export LD_LIBRARY_PATH=/path/to/gcc/lib:$LD_LIBRARY_PATH</code> |
- | ##: <code>$ export LIBRARY_PATH=path/to/gcc | + | ##: <code>$ export LIBRARY_PATH=/path/to/gcc/lib:$LIBRARY_PATH</code> |
- | + | ||
# '''Install the Cilk Plus tools (cilkview and cilkscreen):''' Download the archive from here: https://www.cilkplus.org/download#block-views-cilk-tools-block-1. Unpack the archive and include the <code>bin</code> directory inside the newly-created directory in your <code>$PATH</code>. For example, if you are using bash, execute the following lines, or add these lines to your <code>~/.bashrc</code>. | # '''Install the Cilk Plus tools (cilkview and cilkscreen):''' Download the archive from here: https://www.cilkplus.org/download#block-views-cilk-tools-block-1. Unpack the archive and include the <code>bin</code> directory inside the newly-created directory in your <code>$PATH</code>. For example, if you are using bash, execute the following lines, or add these lines to your <code>~/.bashrc</code>. | ||
##: <code>$ export PATH=path/to/cilktools/bin:$PATH </code> | ##: <code>$ export PATH=path/to/cilktools/bin:$PATH </code> | ||
Line 88: | Line 84: | ||
** '''Cilkprof:''' <code>$ cilkprof ./cilkprogram</code> | ** '''Cilkprof:''' <code>$ cilkprof ./cilkprogram</code> | ||
*** This command generates two csv output files, <code>cilkprogram.bb.csv</code> and <code>cilkprogram.cc.csv</code>, containing work and span profiling data for your Cilk program. At this time, the data in these files are most easily perused using your favorite spreadsheet program. For more information on configuring the output of Cilkprof, run <code>$ cilkprof -h</code>. | *** This command generates two csv output files, <code>cilkprogram.bb.csv</code> and <code>cilkprogram.cc.csv</code>, containing work and span profiling data for your Cilk program. At this time, the data in these files are most easily perused using your favorite spreadsheet program. For more information on configuring the output of Cilkprof, run <code>$ cilkprof -h</code>. | ||
+ | |||
+ | * '''Alternative implementations of Cilk''' | ||
+ | ** '''LLVM/Clang with Cilk Plus:''' Please see http://cilkplus.github.io/ for installation details. |
Latest revision as of 19:16, 5 March 2015
Intel provides a suite of tools for programming Cilk-based programs. The tool set contains the Intel compiler ICC, the parallelism checker Cilkview, the race condition reporter Cilkscreen, the binary-level instrumentation gadget Pintool, the fine-level instrumentation tool Cilkprof. Here is a guide to install them on a 64-bit Linux.
- Online Resources
- Open Source Cilk Plus Website: http://www.cilkplus.org/
- Intel Cilk Plus Forum: http://software.intel.com/en-us/forums/intel-cilk-plus
- Installation
- Install ICC or GCC: A free, open-source version is available in the cilkplus branch of GCC.
- Installing ICC These instructions assume your shell is bash.
- Prerequisites: You need a license from Intel® in order to install ICC.
- Go to http://software.intel.com/en-us/articles/intel-software-evaluation-center/.
- Select the Linux version of "Intel® C++ Composer XE" (or any Linux product suite listed as containing "Intel® C++ Composer XE") and download the 64-bit version.
- Unpack the downloaded file and run the installation script.
-
$ /path/to/unpacked/file/install.sh
. - Note: To allow all users to access ICC on the system, run this install script as root.
-
- Follow the on-screen instructions to install ICC.
- Set up your environment variables to use ICC.
-
$ source /path/to/intel/bin/compilervars.sh intel64
.
-
- Installing GCC: These instructions walk you through checking out and building the latest version of GCC, which supports the Cilk keywords. Complete instructions for building GCC from source can be found at http://gcc.gnu.org/install/index.html. These instructions will install GCC into a custom directory,
gcc
, so as not to overwrite the existing version of GCC on your system.- Warning: This process takes a while and use a couple gigabytes of space.
- Prerequisites: You will need the following installed on your system. (For more information non prerequisites, please check http://gcc.gnu.org/install/prerequisites.html.)
-
flex
orlex
-
bison
orYacc
-
isl
-
make
orgmake
-
gcc
org++
, version 4.4 or above -
autogen
-
autoconf
, version 2.64 -
svn
orgit
-
gmp
-
mpfr
-
mpc
-
- Create some directories for the GCC source, compiled objects, and binaries:
-
$ mkdir /path/to/gcc
-
$ mkdir /path/to/gcc/src
-
$ mkdir /path/to/gcc/obj
-
- Check out the latest version of GCC.
- You can check out the repository using Git:
-
$ git clone git://gcc.gnu.org/git/gcc.git gcc/src
- Configure GCC:.
-
$ cd /path/to/gcc/obj
-
$ ../src/configure --prefix=${PWD}/.. --enable-languages=c,c++
- Note:: You might want to add
--disable-multilib
to the configuration options if multilib is not installed on your system. Otherwise, you might encounter errors such as: -
gnu/stubs-32.h: No such file or directory compilation terminated.
-
- Compile GCC:
-
$ make
- Note:: If you have multiple cores on your system, you can speed up this compilation using make's
-j<number_of_threads>
flag.
-
- Install GCC into
/path/to/gcc/
:-
$ make install
-
- The new GCC binary is
/path/to/gcc/bin/gcc
. - Set up the necessary environment variables. For example, if you are using bash, execute the following, or add these lines to
~/.bashrc
to set up these variables automatically when you log in.-
$ export PATH=/path/to/gcc/bin:$PATH
-
$ export LD_LIBRARY_PATH=/path/to/gcc/lib:$LD_LIBRARY_PATH
-
$ export LIBRARY_PATH=/path/to/gcc/lib:$LIBRARY_PATH
-
- Install the Cilk Plus tools (cilkview and cilkscreen): Download the archive from here: https://www.cilkplus.org/download#block-views-cilk-tools-block-1. Unpack the archive and include the
bin
directory inside the newly-created directory in your$PATH
. For example, if you are using bash, execute the following lines, or add these lines to your~/.bashrc
.-
$ export PATH=path/to/cilktools/bin:$PATH
-
- Install Pintool: Download Pin from here: http://www.pintool.org/downloads.html. Unpack the archive.
- Install Cilkprof: These instructions include instructions on downloading and installing Pin for Cilkprof. These instructions should work with the latest version of Pin, which is version 62141 at the time these instructions were last updated. These instructions have not necessarily been tested on newer version of Pin, however.
- Change to the directory
cilkprof/install/dir
in which you would like to install Cilkprof.-
$ cd cilkprof/install/dir
-
- Create a directory
3rdparty
inside ofcilkprof/install/dir
.-
$ mkdir cilkutil 3rdparty
-
- Download Pin for Linux from http://www.pintool.org/downloads.html, and place the downloaded archive into
3rdparty
. - Download libzca from http://cilkplus.org/download, and place the downloaded archive into the current directory,
cilkprof/install/dir
. - Unpack the Pin archive inside of
3rdparty
. - Create a symbolic link called
pintool
to the directory created by unpacking the archive. - If you do not have the necessary permissions to access the
intel64
subdirectory inside ofpintool
, run$ chmod -R 755 intel64
. - Unpack the
libzca
archive inside ofcilkprof/install/dir
. Create a symbolic link calledcilkutil
to the directory created by unpacking this archive. - Build libzca and cilkprof.
-
$ cd cilkutil
-
$ make
(You will need a version ofgcc
and a version oficc
to complete this compilation.)
-
- Download the
cilkprof
script from http://web.mit.edu/neboat/www/code/cilkprof, and place it in a directory in yourPATH
environment variable. For example, place it within the same directory ascilkview
andcilkscreen
. - Set the CILKUTIL environment variable to point to the
cilkutil
directory. For example, if your shell is bash, add the lineexport CILKUTIL=/path/to/cilkutil
to your.bashrc
.
- Change to the directory
- Usage
- Compile with ICC:
$ icc cilkprogram.cpp -o cilkprogram
- Compile with GCC:
$ g++ cilkprogram.cpp -o cilkprogram -lcilkrts -ldl
- Check parallelism:
$ cilkview ./cilkprogram
- Check race condition:
$ cilkscreen ./cilkprogram
- Pintool: Please see the Pin manual, e.g. http://software.intel.com/sites/landingpage/pintool/docs/62141/Pin/html/.
- Linux perf tool:
- Show list of counters:
$ perf list
- check L1 data load miss:
$ perf stat -c L1-dcache-load-misses ./cilkprogram
- Show list of counters:
- Cilkprof:
$ cilkprof ./cilkprogram
- This command generates two csv output files,
cilkprogram.bb.csv
andcilkprogram.cc.csv
, containing work and span profiling data for your Cilk program. At this time, the data in these files are most easily perused using your favorite spreadsheet program. For more information on configuring the output of Cilkprof, run$ cilkprof -h
.
- This command generates two csv output files,
- Compile with ICC:
- Alternative implementations of Cilk
- LLVM/Clang with Cilk Plus: Please see http://cilkplus.github.io/ for installation details.