class barrier Barrier class.
| | barrier (int count) Create a barrier for count tasks |
| | ~barrier () Destroy a barrier |
| | wait () wait at a barrier for all tasks |
| | maxcnt Maximum number of runners |
| | sb [2] Subbarriers |
| | sbp Current sub-barrier |
This class can be used to implement a barrier. In many applications, and especially numerical applications, while part of the algorithm can be parallelized, other parts are inherently sequential, as shown in the following:Thread1 Thread2 through Threadn while(many_iterations) { while(many_iterations) { sequential_computation --- Barrier --- --- Barrier --- parallel_computation parallel_computation } }The nature of the parallel algorithms for such a computation is that little synchronization is required during the computation, but synchronization of all the threads employed is required to ensure that the sequential computation is finished before the parallel computation begins.
The barrier forces all the threads that are doing the parallel computation to wait until all threads involved have reached the barrier. When they've reached the barrier, they are released and begin computing together.
Example:
~barrier()
bool wait()
struct subbarrier
pthread_cond_t wait_cv
int maxcnt
alphabetic index hierarchy of classes
Please send questions and comments to zweizig_j@ligo.caltech.edu
generated by doc++