CHAPTER 3

Pointers and Arrays

The concept of pointers is a core element of the ISO C programming language and has proven to be a powerful programming tool. UPC defines a number of pointer classes that follow directly from C pointers and the UPC memory model. As in C, pointers are variables that contain the address of another variable. However, under the UPC memory model such pointers can reside in either the private space or the shared space. UPC pointers can also reference the private space or the shared space. These different variants of the UPC pointer semantics serve distinct programming scenarios. Pointers often lead to compact programs and result in efficient implementations. Pointers and array indexes are closely related in C, and they remain that way in UPC. Under UPC, pointers can be declared to have blocking factors similar to those in the case of arrays. Thus, given any array layout in the shared space, a pointer can be declared to traverse the elements of such an array in the same sequence that C pointers traverse array elements. In many cases, casting is also allowed from one pointer type to another.

3.1 UPC POINTERS

The syntax of pointer declarations in UPC is similar to those of C. However, with a memory model that has shared and private spaces, there are four major UPC pointer classes: private pointers pointing to the private space, private pointers pointing to the shared space, shared pointers pointing to the shared space, and shared pointers pointing to the ...

Get UPC: DISTRIBUTED SHARED MEMORY PROGRAMMING now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.