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.

Example programs

Dot product

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.

Dynamic arrays

This is the same dot product example as above except the arrays are dynamically allocated with upc_all_alloc.

Sieve of Erathosthenes

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.

Tree based Reduction

Each thread has a value and we want to compute the the sum of those values.

Serial Functions

Example programs that calls user written functions and standard C functions from a library.

Functions on shared arrays

Rewrite of the dot product program above that uses a function on the shared arrays.

Localization

Rewrite of the dot product program that exploits affinity to compute the partial sums of the dot with local pointers.

Localization trick for 2D arrays

This is a localization trick for a 2D array.

99 Bottles of Beer

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 }