mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-07 23:22:11 +01:00
34 lines
603 B
C
34 lines
603 B
C
/*
|
|
* @@name: tasking.3c
|
|
* @@type: C
|
|
* @@compilable: yes
|
|
* @@linkable: no
|
|
* @@expect: success
|
|
*/
|
|
typedef struct node node;
|
|
struct node {
|
|
int data;
|
|
node * next;
|
|
};
|
|
|
|
void process(node * p)
|
|
{
|
|
/* do work here */
|
|
}
|
|
void increment_list_items(node * head)
|
|
{
|
|
#pragma omp parallel
|
|
{
|
|
#pragma omp single
|
|
{
|
|
node * p = head;
|
|
while (p) {
|
|
#pragma omp task
|
|
// p is firstprivate by default
|
|
process(p);
|
|
p = p->next;
|
|
}
|
|
}
|
|
}
|
|
}
|