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