OpenMP-Examples/sources/Example_tasking.1.c

26 lines
431 B
C

/*
* @@name: tasking.1c
* @@type: C
* @@compilable: yes
* @@linkable: no
* @@expect: success
*/
struct node {
struct node *left;
struct node *right;
};
extern void process(struct node *);
void traverse( struct node *p )
{
if (p->left)
#pragma omp task // p is firstprivate by default
traverse(p->left);
if (p->right)
#pragma omp task // p is firstprivate by default
traverse(p->right);
process(p);
}