mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-07 23:22:11 +01:00
36 lines
592 B
C
36 lines
592 B
C
/*
|
|
* @@name: task_depend.8.c
|
|
* @@type: C
|
|
* @@compilable: yes
|
|
* @@linkable: yes
|
|
* @@expect: success
|
|
*/
|
|
|
|
#include<stdio.h>
|
|
|
|
void foo()
|
|
{
|
|
int x = 0, y = 2;
|
|
|
|
#pragma omp task depend(inout: x) shared(x)
|
|
x++; // 1st child task
|
|
|
|
#pragma omp task depend(in: x) depend(inout: y) shared(x, y)
|
|
y -= x; // 2st child task
|
|
|
|
#pragma omp taskwait depend(in: x,y)
|
|
|
|
printf("x=%d\n",x);
|
|
printf("y=%d\n",y);
|
|
|
|
}
|
|
|
|
int main()
|
|
{
|
|
#pragma omp parallel
|
|
#pragma omp single
|
|
foo();
|
|
|
|
return 0;
|
|
}
|