CSCI 3366 (Introduction to Parallel and Distributed Processing):
Sample Programs
Makefiles, scripts, etc.
- For the MPICH implementation of MPI:
- Sample makefile Makefile
for compiling C and C++ programs.
- Sample script run-mpi
for running MPI programs.
- For the LAM implementation of MPI:
- Sample makefile Makefile
for compiling C and C++ programs.
- Sample script run-mpi
for running MPI programs.
- For either implementation:
- Script make-MPIhosts
for generating a list of machines that are currently
"up".
- For programs using the POSIX threads library:
- Sample makefile Makefile
for compiling C++ programs.
Notes:
- To obtain a makefile, use your browser's download function;
cutting and pasting will likely turn the tabs in the makefile
into spaces and cause it to not work.
All makefiles linked from this page begin with
brief documentation on their use.
- To obtain and use a script, download the script and use
chmod to mark it executable, e.g.,
chmod u+x run-mpi.
All scripts linked from this page begin with
brief documentation on their use.
- Also see
Tips for Using MPI on the CS Linux Machines.
Message-passing programs (using MPI)
- "Hello, world" program:
- Trivial example of send/receive:
- Trivial example of send/receive with timing:
- "Hello, world" program also displaying command-line arguments:
- Program to add lots of numbers (based on example in
section 2.2.3 of textbook):
- Program to solve 1D heat-distribution problem (1D version
of problem in section 6.3.2 of textbook):
Multi-threaded programs (using POSIX threads in C++)
- "Hello, world" program:
- Program to add numbers:
- Program to solve 1D heat-distribution problem (1D version
of problem in section 6.3.2 of textbook):
- Class for "bounded buffer" (with appropriate synchronization)
and program showing its use:
Multi-threaded programs (using Java)
- "Hello, world" program:
- Program to add numbers:
- Class for "bounded buffer" (with appropriate synchronization)
and program showing its use: