
120 CHAPTER 5. SHARED-MEMORY: C
5.2.3 Analysis
Now, take a look at burst():
void b urst ( double ∗x , int nx , int k ,
int ∗ startmax , int ∗endmax , double ∗ maxval )
{
int nth ; // number of thre a d s
#pragma omp p a r a l l e l
{ int p e r s t a r t , // START OF PARALLEL BLOCK
perlen , // p er i od len g t h
. . .
. . .
. . .
∗ startmax = mystartmax ;
∗endmax = myendmax ;
}
}
} // END OF PARALLEL BLOCK
This is really the crux of OpenMP. Note the pragma:
#pragma omp parallel
This instruction to the compiler unleashes a team of threads. Each of the
threads will execute the block that follows,
2
with certain rules governing
the local variables:
Consider the variable ...