This patch adds support for the OpenMP 4.0 depend clause for the task
construct, excluding array sections, to Flang lowering from parse-tree
to MLIR.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Looks OK.
Could you check why the following is crashing at runtime?
subroutine foo() implicit none integer::x,y x=0 y=2 !$omp task depend(out:x) shared(x) x=x+1 !$omp end task !$omp task depend(out:y) shared(y) y=y+1 !$omp end task !$omp task depend(in:x,y) shared(x,y) y=y-x !$omp end task !$omp taskwait print*,"y=",y end subroutine foo program p implicit none !$omp parallel !$omp single call foo() !$omp end single !$omp end parallel end program p
flang/test/Lower/OpenMP/task.f90 | ||
---|---|---|
107 | Please add a few more tests to, |
I reduced the test case to the following, and it crashes for me too. Note that this does not have any depend clauses. I will debug this issue.
subroutine foo() implicit none integer::x,y x=0 y=2 !$omp task shared(x,y) y=x !$omp end task !$omp taskwait print*,"y=",y end subroutine foo program p implicit none call foo() end program p
@psoni2628 Will you have time this week or next to look into the blocking issue. I think it also shows up in https://github.com/llvm/llvm-project/issues/62013. I guess this has something to do with kmp_task_t structure that is being passed to the tasks and how the shared variables are copied into it.
Sure, I can spend more time on it this week. However, I don't think the issue you linked is related to this one. The issue looks like a compile time crash, whereas I am dealing with a runtime crash.
This test case failure is caused by the shared clause not being implemented for the task construct. In llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp, there is the following comment from D71989: TODO: Argument - sizeof_shareds.
I don't think we can properly test the depend clause without at least 2 shared variables. Thus, we must first implement the shared clause functionality. Do you have a different opinion @kiranchandramohan ?
On second thought, I think we can write a test case that has only 1 shared variable to test the depend clause functionality. I tested the following test case below and it runs.
subroutine foo() implicit none integer::x,y x=0 !$omp task shared(x) depend(out:x) x=2 !$omp end task !$omp task shared(x) depend(in:x) x=x-1 !$omp end task !$omp taskwait print*,"x=",x end subroutine foo program p implicit none !$omp parallel !$omp single call foo() !$omp end single !$omp end parallel end program p
@kiranchandramohan Do you think this test case is fine? We can land this patch and move on to fixing the shared clause.
This patch caused an unused variable ‘a’ [-Werror=unused-variable] warning in https://lab.llvm.org/buildbot/#/builders/160/builds/20500 for flang/lib/Lower/OpenMP.cpp:1197. This has been corrected in rGe0fed043662cb2410858ad82002f22e64ee552dd.
Side note: I am not sure why the build bot run for this original Differential did not complain about this warning.
Please add a few more tests to,
-> cover all the dependency types.
-> cover a few FIR types : allocatable, character etc
-> have more than one depend clause for the same task
-> have more than one variable in a single depend clause