1. Introductory Tutorial
Published Online: 27 JAN 2005
Copyright © 2005 John Wiley & Sons, Inc.
UPC: Distributed Shared Memory Programming
How to Cite
El-Ghazawi, T., Carlson, W., Sterling, T. and Yelick, K. (2005) Introductory Tutorial, in UPC: Distributed Shared Memory Programming, John Wiley & Sons, Inc., Hoboken, NJ, USA. doi: 10.1002/0471478369.ch1
- Published Online: 27 JAN 2005
- Published Print: 13 MAY 2005
Book Series Editors:
- Albert Y. Zomaya
Print ISBN: 9780471220480
Online ISBN: 9780471478362
- Unified Parallel C (UPC);
- single program, multiple data (SPMD);
- UPC pointers
In this chapter we introduced the basic concepts of UPC in a tutorial style to enable programmers to write their first UPC code quickly. We have in particular demonstrated that UPC is a superset of C and all C programs will run under UPC. However this will naturally create several copies of the same program running in the SPMD mode.
Under UPC, multiple threads will be operating independently and each thread may have access to both private and shared data objects, variables and arrays. A private variable has one independent instance per thread. The total number of threads is THREADS and each thread identifies itself using MYTHREAD. THREAD and MYTHREAD can be thought of as special constants. Shared scalars have affinity with thread 0. Shared array elements, however, are distributed by default in a round robin fashion across the threads.
UPC has many synchronization constructs for barrier, split phase barrier, locks, and fence. UPC also provides the programmer with the ability to specify the memory consistency model, as relaxed or strict.
Work can be distributed based on THREADS and MYTHREAD. Work can be conveniently distributed, however, using upc_forall. All iterations must be independent in order to use upc_forall.
UPC provides rich pointer concepts. Threads can point to shared data using either shared or private pointers. In addition, C pointer declarations result in private pointers to private data. It is possible under UPC to cast one type of pointer to another.