CSC 2/458: Build Notes


Please use Makefiles. Samples are provided in the apps directory.


You may use any of the following department machines.

Turn In


The turn-in script will recursively copy all files and subdirectories of your current directory to a location in the course's account. Please avoid running it at your home directory or any other directory that contains files irrelevant to the current project. For any problems while using it please contact the TA with an email (sending the script's output will help).You may turn-in your project as many times as you need. However, only the MOST RECENT submission will be graded. DO NOT FORGET to submit a README file (text or pdf format) with your code, and include your name and e-mail address in the README file. Check the appropriate assignment page for information related to the contents of the README file.


* From the grad network:

1) Go to the directory that contains ALL the files that are related
to your current project.

2) Run the script:


Upon successful completion you will get an output of the form:

File Submission completed successfully at: [CURRENT DATE] Where CURRENT DATE represents the current date and time. You will also receive through email a message with subject ``Submission Notification'', which will contain a listing of all the files you submitted along with their last modification date and size.

Assignment #3 Build Notes

In this assignment you'll be working with three different programming models (1) MPI, (2) OpenMP, (3) Cilk. Besides the difference between message passing and shared memory, MPI is a library interface whereas OpenMP and Cilk consist of a set of directives that need special compiler support. Although both of them are language independent, we'll be focusing on C/C++.

Environment Variable Setup

Please add the following to your .cshrc in order to automatically find the executables, libraries, and include files.
# Set the default home directories for MPI and Cilk
setenv MPI_HOME /u/{cs258 or cs458}/installed/mpi/3.0.2/x86_64
setenv CILK_HOME /u/{cs258 or cs458}/installed/cilkplus

# set MPI binary and library paths
setenv PATH ${MPI_HOME}/bin:${PATH}

if ( "$?LD_LIBRARY_PATH" ) then

# set cilk binary and library paths

setenv PATH ${CILK_HOME}/bin:${PATH}


Tool-hardware compatibility is an important issue. We have set up a variety of compiler-hardware setups at /u/cs2(or4)58/installed. Each specific compiler needs you to set up the PATH and LD_LIBRARY_PATH variables.



Current versions of gcc should support OpenMP by default.

How to Compile

In addition to using gcc 4.2 or higher, you need to compile with the -fopenmp command-line option:
 gcc -fopenmp -o hello hello.c 

How to program

For a programming guide you may refer to this tutorial. We have also included a simple hello world program at /u/cs4(or 2)58/apps/test_omp.


MPI is a message-passing library in which the programmer is expected to explicitly specify the communication and transfer of data between execution threads. The data communication can be implemented using a number of underlying protocols, shmem (shared memory) or TCP/IP (messaging across a network).


The MPI versions have been set up at, /u/cs(2 or 4)58/installed/mpi/3.0.2/x86_64

How to compile

Like gcc, mpicc performs both compilation and linking. A sample Makefile and program can be found at /u/cs458/apps/sor/mpi. You may use the directory as a template and plug in your own programs. You also need to specify the include path to help mpicc find the header "-I/u/cs458/$MPI_HOME/include/".

How to program

Take a look at MPI tutorial from Lawrence Livermore National Lab.

How to run

mpirun is the script for launching your mpi tasks. The syntax is
 mpirun -np  -machinefile   
np specifying the number of processors to use and the machine file listing the processors to be selected from.

NOTE: On the graduate network, any jobs submitted to the cluster nodes ranging from node33 to node64 are subject to centralized management. For detail instructions, please refer to ClusterJobs. In short, you need to wrap your jobs in a shell script and then pass it as an argument to qsub. Here's a script that could be used in submitting your MPI jobs.

source ~/.cshrc.mpi

#set your machinefile
cat $PBS_NODEFILE > ./cluster_nodes 
#count how many nodes you reserve

#run mpi on these nodes
mpirun -np `cat ./cluster_nodes | wc -l` -machinefile ./cluster_nodes
./linux/ < your-mpi-program >  >  ./mpi.out
Now you ssh to, enter your mpi working directory and then copy and fix To run your mpi program, just type qsub -l nodes=4


Cilk is a set of language extensions that allow users to specify parallelism points without worrying about threads or scheduling issues.

How to set up

setenv CILK_HOME /u/{cs258 or cs458}/installed/cilkplus

# set cilk binary and library paths

setenv PATH ${CILK_HOME}/bin:${PATH}


How to compile

In addition to using gcc 4. or higher, you need to compile with the -fcilkplus and -lcilkrts command-line options:

 gcc -fcilkplus -lcilkrts -o hello hello.c 
We have also included sample programs and a makefile at /u/cs4(or 2)58/apps/test_cilk.

How to program

Please see the tutorials and information at
Cilk Plus Tutorial
Intel's pages for Cilk Plus: Additional material