[DBPP] previous next up contents index [Search]
Next: 5.3 Concurrency Up: 5 Compositional C++ Previous: 5.1 C++ Review

5.2 CC++ Introduction

CC++ is a general-purpose parallel programming language comprising all of C++ plus six new keywords. It is a strict superset of the C++ language in that any valid C or C++ program that does not use a CC++ keyword is also a valid CC++ program. The   CC++ extensions implement six basic abstractions:

  1.   The processor object is a mechanism for controlling locality. A computation may comprise one or more processor objects. Within a processor object, sequential C++ code can execute without modification. In particular, it can access local data structures. The keyword global identifies a processor object class, and the predefined class proc_t controls processor object placement.

  2. The global pointer, identified by the type modifier   global, is a mechanism for linking together processor objects. A global pointer must be used to access a data structure or to perform computation (using a remote procedure call, or RPC) in another processor object.

  3.   The thread is a mechanism for specifying concurrent   execution. Threads are created independently from processor objects, and more than one thread can execute in a processor object. The par, parfor, and spawn statements create threads.

  4.   The sync variable, specified by the type modifier sync, is used to synchronize thread execution.

  5.   The atomic function, specified by the keyword atomic, is a mechanism used to control the interleaving of threads executing in the same processor object.

  6.   Transfer functions, with predefined type CCVoid, allow arbitrary data structures to be transferred between processor objects as arguments to remote procedure calls.

These abstractions provide the basic mechanisms required to specify concurrency, locality, communication, and mapping.



Example . Bridge Construction: 

  Program 5.3 illustrates many CC++ features. It is   an implementation of the bridge construction algorithm developed in Example 1.1. The program creates two tasks, foundry and bridge, and connects them with a channel. The channel is used to communicate a stream of integer values 1..100 from foundry to bridge, followed by the value --1 to signal termination.

While the concepts of task and channel are not supported directly in CC++ , they can be implemented easily by using CC++ mechanisms. Hence, the main program creates two tasks by first using the new operator to create two processor objects and then using the par construct to create two threads, one per processor object. The two tasks engage in channel communication by invoking functions defined in a Channel class, which will be described in Section 5.11. A channel is declared in the main program and passed as an argument to foundry and bridge. These processes use access functions get_out_port and get_in_port to obtain pointers to out-port and in-port objects to which can be applied functions send and receive, respectively.



 



[DBPP] previous next up contents index [Search]
Next: 5.3 Concurrency Up: 5 Compositional C++ Previous: 5.1 C++ Review

© Copyright 1995 by Ian Foster