SC740 SEMINAR REPORT 08 for Frederick L. Jones
PRESENTER: Dr. Clay P. Breshears
TOPIC: Threaded and Concurrent Programming for High Performance Computing
OVERVIEW
Dr. Clay Breshears began his seminar with an introduction to threads and concurrent programming. The fact that a UNIX process requires both (1)a unit of dispatching and (2)a unit of resource ownership has made it possible to separate the implementation of the concepts of process (i.e., unit of resource ownership) and thread (i.e., unit of dispatching execution path).
Dr. Breshears then provided an in depth overview of two concurrent programming systems which make use of threads to achieve concurrency. The first concurrent programming system described was OpenMP and the second system described was Pthreads. Both OpenMP and Pthreads use a shared memory model.
AN INTRODUCTION TO THREADS AND CONCURRENT PROGRAMMING
Dr. Clay Breshears began his seminar with an introduction to multitasking in UNIX whereby processes spawn other processes. A UNIX process requires both (1)a unit of resource ownership and (2)a unit of dispatching. A unit of dispatching requires both an execution path and an execution state.
The fact that a UNIX process requires both (1)a unit of dispatching and (2)a unit of resource ownership has made it possible to separate the implementation of the concepts of process (i.e., unit of resource ownership) and thread (i.e., unit of dispatching execution path). Threads are a separate execution stream with its own stack, program counter and storage for local variables.
Since threads are separate execution streams of a process or processes, then they can execute concurrently. Dr. Breshears provided an in depth overview of two concurrent programming systems which make use of threads to achieve concurrency. The first concurrent programming system described was OpenMP and the second system described was Pthreads. Both OpenMP and Pthreads use a shared memory model.
OpenMP
Dr. Breshears described OpenMP as a portable fork-join model for user-directed parallelization on shared memory architectures. The shared memory programming model is based on the recommendations of the Parallel Computing Forum (PCF).
OpenMP is a shared memory model whereby some memory segments of each processor can be accessed by all of the threads. The OpenMP data environment can be either private or else shared. Shared data is global and private data is local.
Parallelism in OpenMP can be either coarse-grained, fine-grained or else nested depending upon the users needs. OpenMP was designed with control structure statements such as Parallel, End Parallel, Do, End Do, etc. to define sections of code for parallel execution or else to parallelize a "do loop", etc.
Synchronization is provided in OpenMP to protect the integrity of the parallel programs. OpenMP synchronization can be either implicit or else explicit. For example, Implicit barriers wait for all Do, End Do statements to complete. Explicit directives such as Barrier, Critical, End Critical and Atomic provide finer control over synchronization.
Pthreads
Dr. Breshears described Pthreads as a POSIX standard with a C language interface where all threads created are peers. Pthreads allows users to create and join threads according to tasks. Pthreads makes nested parallelism possible, since the user has fine control.
Threaded programming with Pthreads involves a shared memory model where explicit synchronization is needed. With parallel communication, messages become synchronization points between processes. Since race conditions occur among processes for concurrent access, Pthreads coding considerations involve the use of such synchronization methods as the use of Critical Sections and Mutual Exclusion.
SUMMARY AND CONCLUSIONS
Dr. Clay Breshears began his seminar with an introduction to threads and concurrent programming. The fact that a UNIX process requires both (1)a unit of dispatching and (2)a unit of resource ownership has made it possible to separate the implementation of the concepts of process (i.e., unit of resource ownership) and thread (i.e., unit of dispatching execution path).
Dr. Breshears then provided an in depth overview of two concurrent programming systems which make use of threads to achieve concurrency. The first concurrent programming system described was OpenMP and the second system described was Pthreads. Both OpenMP and Pthreads use a shared memory model.
In response to a question from me concerning whether either OpenMP or else Pthreads was better than the parallel programming system MPI which is used here at USM, Dr. Breshears simply stated that OpenMP and Pthreads are simply different ways of achieving parallelism.
While OpenMP and Pthreads use a shared memory model exclusively, MPI can either use or not use a shared memory model. The concept of threads is explicitly referenced in MPI The Complete Reference and in the USING MPI Portable Parallel Programming with the Message-Passing Interface reference manual. In chapter 7 of the USING MPI reference manual, William Gropp, et.al. describe how to simulate a shared-memory model using MPI. So, the importance of shared memory models such as OpenMP and Pthreads was anticipated by the designers of MPI.