Using UPC at MTU
Here is a short page on using UPC
on the CSE machines at MTU.
UPC Syntax
UPC is an extension of C.
This is a collection of very simple programs that
illustrate the basic functionality and syntax of UPC.
- Every tutorial starts with
Hello World.
This introduces the idea of an SPMD program and the keywords
THREADS and MYTHREADS.
- A barrier is necessary evil in parallel programming.
The following versions
of
helloworld, called
upc-barriers,
use barriers to serialize the program so that the threads
print one at a time.
- Affinity is one of the key notions in UPC.
This
affinity page
has a sample code that reports the affinity of
arrays declared in various ways.
- The
upc_forall statement gives an easy way to
restrict the execution of the body of a for loop
based on affinity. Some comments and two examples are given
on the
upc-forall page.
- Locks are mechanism that can be used to
control synchronization while avoiding the use of a barrier.
This collection of code
locks,
gives examples of the syntax for locks in upc.
Typically uses of locks are given in the examples section.
Example programs
This is a simple programs to compute the dot product of two
vectors stored as shared arrays. It uses upc_forall
and locks. The code also shows the use of a
blocking factor to change the affinity of elements in
the arrays.
This is the same dot product example as above except the arrays
are dynamically allocated with upc_all_alloc.
The sieve of Erathosthenes is one of the oldest know algorithms.
It is not a good way to find primes, but it provides
examples of how to share work in UPC.
Each thread has a value and we want to compute the
the sum of those values.
Example programs that calls user written functions and standard C functions
from a library.
Rewrite of the dot product program above that uses a function on the shared arrays.
Rewrite of the dot product program that exploits affinity to compute the
partial sums of the dot with local pointers.
This is a localization trick for a 2D array.
Program to generate the song "99 Bottles of Beers" in C and UPC.
The UPC version uses fetch_and_add.
Last modified 12/8/4
{ Insert a counter here }