b43836914b
This patch adds support for (so far C/C++) #pragma omp taskwait nowait depend(...) directive, which is like #pragma omp task depend(...) ; but slightly optimized on the library side, so that it creates the task only for the purpose of dependency tracking and doesn't actually schedule it and wait for it when the dependencies are satisfied, instead makes its dependencies satisfied right away. 2022-05-24 Jakub Jelinek <jakub@redhat.com> PR c/105378 gcc/ * omp-builtins.def (BUILT_IN_GOMP_TASKWAIT_DEPEND_NOWAIT): New builtin. * gimplify.cc (gimplify_omp_task): Diagnose taskwait with nowait clause but no depend clauses. * omp-expand.cc (expand_taskwait_call): Use BUILT_IN_GOMP_TASKWAIT_DEPEND_NOWAIT rather than BUILT_IN_GOMP_TASKWAIT_DEPEND if nowait clause is present. gcc/c/ * c-parser.cc (OMP_TASKWAIT_CLAUSE_MASK): Add nowait clause. gcc/cp/ * parser.cc (OMP_TASKWAIT_CLAUSE_MASK): Add nowait clause. gcc/testsuite/ * c-c++-common/gomp/taskwait-depend-nowait-1.c: New test. libgomp/ * libgomp_g.h (GOMP_taskwait_depend_nowait): Declare. * libgomp.map (GOMP_taskwait_depend_nowait): Export at GOMP_5.1.1. * task.c (empty_task): New function. (gomp_task_run_post_handle_depend_hash): Declare earlier. (gomp_task_run_post_handle_depend): Declare. (GOMP_task): Optimize fn == empty_task if there is nothing to wait for. (gomp_task_run_post_handle_dependers): Optimize task->fn == empty_task. (GOMP_taskwait_depend_nowait): New function. * testsuite/libgomp.c-c++-common/taskwait-depend-nowait-1.c: New test.
40 lines
892 B
C
40 lines
892 B
C
#ifdef __cplusplus
|
|
extern "C"
|
|
#endif
|
|
void abort (void);
|
|
|
|
int
|
|
main ()
|
|
{
|
|
int a[64], b = 1;
|
|
#pragma omp parallel num_threads (4)
|
|
#pragma omp single
|
|
{
|
|
int i;
|
|
#pragma omp taskwait depend(in: a) nowait
|
|
#pragma omp taskwait depend(in: a) nowait
|
|
#pragma omp taskwait
|
|
#pragma omp taskgroup
|
|
{
|
|
#pragma omp taskwait depend(in: a) nowait
|
|
#pragma omp taskwait depend(in: a) nowait
|
|
}
|
|
for (i = 0; i < 64; ++i)
|
|
#pragma omp task depend(in: a) shared(a)
|
|
a[i] = i;
|
|
#pragma omp taskwait depend(inout: a) nowait
|
|
for (i = 0; i < 64; ++i)
|
|
#pragma omp task depend(inoutset: a) shared(a)
|
|
if (a[i] != i)
|
|
abort ();
|
|
else
|
|
a[i] = 2 * i + 1;
|
|
#pragma omp taskwait nowait depend(out: a) depend(in: b)
|
|
#pragma omp taskwait depend(inout: b)
|
|
for (i = 0; i < 64; ++i)
|
|
if (a[i] != 2 * i + 1)
|
|
abort ();
|
|
}
|
|
return 0;
|
|
}
|