mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-07 23:22:11 +01:00
26 lines
549 B
C
26 lines
549 B
C
/*
|
|
* @@name: taskloop.c
|
|
* @@type: C
|
|
* @@compilable: yes
|
|
* @@linkable: no
|
|
* @@expect: success
|
|
*/
|
|
void long_running_task(void);
|
|
void loop_body(int i, int j);
|
|
|
|
void parallel_work(void) {
|
|
int i, j;
|
|
#pragma omp taskgroup
|
|
{
|
|
#pragma omp task
|
|
long_running_task(); // can execute concurrently
|
|
|
|
#pragma omp taskloop private(j) grainsize(500) nogroup
|
|
for (i = 0; i < 10000; i++) { // can execute concurrently
|
|
for (j = 0; j < i; j++) {
|
|
loop_body(i, j);
|
|
}
|
|
}
|
|
}
|
|
}
|