Unified Parallel C on LRZ's HPC systems
UPC is a PGAS parallel extension to the C standard.
Basic Usage on LRZ HPC systems
The Intel C based version of the Berkeley UPC compiler can be used by loading the module
> module load bupc # requires probably also to load the correct gcc module!
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); }
Compile it under the dynamic translation environment by GCC UPC with the command
> upc -p 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 the static 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