0% found this document useful (0 votes)
54 views2 pages

OpenMP Work-Sharing and Performance

The document discusses using work-sharing sections and loops together in OpenMP to distribute sections of an application among threads. An example is provided that uses sections and a for loop within a parallel region. OpenMP first creates several threads, distributes the loop iterations among them, and then distributes the sections among threads once the loop is finished, so that each section executes in parallel without additional thread creation overhead. Performance oriented programming with OpenMP requires using synchronization pragmas and runtime functions effectively with minimal overhead and waiting to achieve optimal performance.

Uploaded by

bsgindia82
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views2 pages

OpenMP Work-Sharing and Performance

The document discusses using work-sharing sections and loops together in OpenMP to distribute sections of an application among threads. An example is provided that uses sections and a for loop within a parallel region. OpenMP first creates several threads, distributes the loop iterations among them, and then distributes the sections among threads once the loop is finished, so that each section executes in parallel without additional thread creation overhead. Performance oriented programming with OpenMP requires using synchronization pragmas and runtime functions effectively with minimal overhead and waiting to achieve optimal performance.

Uploaded by

bsgindia82
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Work-sharing Sections:

The work-sharing sections construct directs the OpenMP compiler and runtime to distribute the identified sections of your application among threads in the team created for the parallel region. The following example uses work-sharing for loops and work-sharing sections together within a single parallel region. In this case, the o erhead of forking or resuming threads for parallel sections is eliminated.

Example: Parallel sections


#pragma omp parallel Sections Private(y,z) { #pragma omp section { y=sectionA(x); fn7(y); } #pragma omp section { z = section (x); fn!(z); } }

Work can be shared within a parallel region


#pragma omp parallel { #pragma omp for for ( " = #; " $ m; "%% ) { x = fn&(") % fn'("); } #pragma omp sections private(y, z) { #pragma omp section { y = sectionA(x); fn7(y); } #pragma omp section { z = section (x); fn!(z); } } }

OpenMP first creates se eral threads. Then, the iterations of the loop are di ided among the threads. Once the loop is finished, the sections are di ided among the threads so that each section is executed exactly once, but in parallel with the other sections. If the program contains more sections than threads, the remaining sections get scheduled as threads finish their pre ious sections.

Department CSE, SCAD CET

3.Performance Oriented Programming:


OpenMP pro ides a set of important pragmas and runtime functions that enable thread synchroni!ation and related actions to facilitate correct parallel programming. "sing these pragmas and runtime functions effecti ely with minimum o erhead and thread waiting time is extremely important for achie ing optimal performance from your applications. Performance Iss es in OPE!"P:

Department CSE, SCAD CET

You might also like