Directory services/software/parallel/pgas/upc

UPC is a PGAS parallel extension to the C standard.

Basic Usage on LRZ HPC systems

  • The GCC-based version of UPC is available and supports parallelism within a shared memory system. Please load the environment module

    module load upc/gcc

    (Beware: this module will also overload the default gcc with a version of its own; in particular, this module cannot be loaded in conjunction with any gcc module).

  • The Intel C based version of the Berkeley UPCcompiler can be used on SGI Altix systems by loading the module

    module load upc/bupc_icc

A simple example program

#include <upc_relaxed.h>
#include <stdio.h>
int main(){
printf("Hello World from THREAD %d (of %d THREADS)\n",
MYTHREAD, THREADS);
}

stored in hello.upc can then be compiled under the dynamic translation environment by GCC UPC with the command

upc -o hello.exe hello.upc

The resulting executable can then run using e.g., 4 threads via the command

./hello.exe -n 4 -sched-policy auto

producing its output lines in random order (since no explicit synchronization measures are provided to ensure a particular ordering).

For Berkeley UPC, the compilation is done with

upcc -o hello.exe hello.upc

and the executable is then run under the control of upcrun:

upcrun -n 4 ./hello.exe

Under thestatic translation environment, a fixed number of threads is specified at compile time. This allows more optimization, and the THREADS and MYTHREADS macro can then also be used to define other static quantities via the preprocessor. However, the resulting executable will then run only with a fixed number of threads. For GCC UPC, compilation is done via

upc -fupc-threads-4 -o hello.exe hello.upc

The resulting executable will then run using 4 threads always:

./hello.exe -sched-policy auto

For Berkeley UPC, compilation is done with

upcc -T=4 -o hello.exe hello.upc

Execution still requires the use of upcrun:

upcrun ./hello.exe

UPC Documentation

  • The upc manual page (man upc) for GCC UPC
  • The upcc manual page (man upcc) for Berkeley UPC
  • HTML documentation for upcc (Berkeley UPC) is available in a subdirectory of $UPC_DOC, or on the Berkeley UPC web site
  • UPC 1.2 specification
  • UPC manual
  • UPC extensions, in particular collectives