mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-10 08:22:11 +01:00
29 lines
542 B
C
29 lines
542 B
C
/*
|
|
* @@name: critical.2
|
|
* @@type: C
|
|
* @@operation: compile
|
|
* @@expect: success
|
|
* @@version: omp_5.0
|
|
*/
|
|
#include <omp.h>
|
|
|
|
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) hint(omp_sync_hint_contended)
|
|
ix_next = dequeue(x);
|
|
work(ix_next, x);
|
|
|
|
#pragma omp critical (yaxis) hint(omp_sync_hint_contended)
|
|
iy_next = dequeue(y);
|
|
work(iy_next, y);
|
|
}
|
|
|
|
}
|