mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-07 23:22:11 +01:00
27 lines
458 B
C
27 lines
458 B
C
/*
|
|
* @@name: critical.1c
|
|
* @@type: C
|
|
* @@compilable: yes
|
|
* @@linkable: no
|
|
* @@expect: success
|
|
*/
|
|
int dequeue(float *a);
|
|
void work(int i, float *a);
|
|
|
|
void critical_example(float *x, float *y)
|
|
{
|
|
int ix_next, iy_next;
|
|
|
|
#pragma omp parallel shared(x, y) private(ix_next, iy_next)
|
|
{
|
|
#pragma omp critical (xaxis)
|
|
ix_next = dequeue(x);
|
|
work(ix_next, x);
|
|
|
|
#pragma omp critical (yaxis)
|
|
iy_next = dequeue(y);
|
|
work(iy_next, y);
|
|
}
|
|
|
|
}
|