explain example fig.5.28 - dynamic schedule

Use this forum to discuss the book: Using OpenMP - Portable Shared Memory Parallel Programming, by Barbara Chapman, Gabriele Jost and Ruud van der Pas Read the http://openmp.org/forum/viewtopic.php?f=8&t=465 for book info and to download the examples. Post your feedback about the book and examples to this forum
Forum rules
The OpenMP Forums are now closed to new posts. Please visit Stack Overflow if you are in need of help: https://stackoverflow.com/questions/tagged/openmp
Locked
fjhr
Posts: 14
Joined: Thu Jul 03, 2014 12:37 am

explain example fig.5.28 - dynamic schedule

Post by fjhr »

Hello , I am checking the example of fig 5.28 from the book.

Code: Select all

#pragma omp parallel
{
    /* preload data to be used in first iteration of the i-loop */
    #pragma omp single
    {ReadFromFile(0,...);}

    for (i=0; i<N; i++) {

    /* preload data for next iteration of the i-loop */

    #pragma omp single nowait
    {ReadFromFile(i+1...);}

    #pragma omp for schedule(dynamic)
    for (j=0; j<ProcessingNum; j++)
        ProcessChunkOfData(); /* here is the work */
    
    /* there is a barrier at the end of this loop */
    
    #pragma omp single nowait
    {WriteResultsToFile(i);}

    } /* threads immediately move on to next iteration of i-loop */
} /* one parallel region encloses all the work */
I couldn't understand how the processing of data works ( ProcessChunkOfData() ) in parallel.

First , 1 thread reads from file .
Then,we have 1 thread to read from next file and 1 thread write to next file while all the others process data.
But the writting tales place after processing the data ( ok with this).

But then, how the ProcessChunkOfData works right in parallel?It processes which data?On which file?


Can someone elaborate on this?

Thanks!

fjhr
Posts: 14
Joined: Thu Jul 03, 2014 12:37 am

Re: explain example fig.5.28 - dynamic schedule

Post by fjhr »

Hello ,

Someone about this please?

Thanks!

Locked