This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Introduce GOMP taskwait depend in the runtime
ClosedPublic

Authored by jlpeyton on Sep 7 2020, 10:12 PM.

Details

Summary

This change introduces the GOMP_taskwait_depend() function. It implements
the OpenMP 5.0 feature of #pragma omp taskwait with depend() clause by
wrapping around the __kmpc_omp_wait_deps() function.

Diff Detail

Event Timeline

jlpeyton created this revision.Sep 7 2020, 10:12 PM
jlpeyton requested review of this revision.Sep 7 2020, 10:12 PM

The GOMP wrapper makes sense to me.
Several inline comments for the test.

openmp/runtime/test/tasking/omp50_taskwait_depend.c
15

since this is an OpenMP program, shouldn't we use OpenMP atomic store and load?

26

How can we be sure, that not all threads get occupied by these tasks, while none of the other tasks are scheduled?

51

The test succeeds with clang, when I replace this line with

#pragma omp task if(0) depend(inout: a)
{}

Can you please add this copy of the test?

60

b should be loaded with omp atomic

openmp/runtime/test/tasking/omp50_taskwait_depend.c
18

I think the test is going to hang if executed by a single thread. So omp_get_max_threads() should be checked before parallel, and if it is 1 then omp_set_num_threads() could be used to increase number of threads explicitly.

jlpeyton updated this revision to Diff 291694.Sep 14 2020, 2:52 PM

Test was poorly constructed. Second attempt.

The test is three steps:

  1. test a single independent task and make sure the #pragma omp taskwait depend() does not wait on that task. Also ensure that a worker thread grabs the task instead of the generating thread.
  1. test a single task with irrelevant dependencies and make sure the #pragma omp taskwait depend() does not wait on that task. Also ensure that a worker thread grabs the task instead of the generating thread.
  1. test a single dependent task which takes a while and make sure the #pragma omp taskwait depend() actually waits on it.

The test also forces at least two threads in the parallel region, and then rechecks to ensure that at least two threads were actually created for the parallel region.

The #pragma omp task if(0) depend() version of the test will be part of the GOMP fix if0 patch: D87271

This revision is now accepted and ready to land.Sep 15 2020, 4:51 AM
protze.joachim added inline comments.Sep 15 2020, 5:09 AM
openmp/runtime/test/tasking/omp50_taskwait_depend.c
4

For the OMPT tests, I prefer to use XFAIL in the situations, where I expect compiler support at some point.
This way, we won't forget to update the support level when codegen is added for clang/icc .

This is what I have in the OMPT test case:

// clang does not yet support taskwait with depend clause
// clang-12 introduced parsing, but no codegen
// update expected result when codegen in clang was added
// XFAIL: clang
jlpeyton updated this revision to Diff 292558.Sep 17 2020, 10:31 AM

Change to XFAIL for clang and icc and add comment in test file.

protze.joachim accepted this revision.Sep 20 2020, 3:35 PM

LGTM as well.

This revision was landed with ongoing or failed builds.Sep 24 2020, 7:50 AM
This revision was automatically updated to reflect the committed changes.