[flang-commits] [flang] [WIP][flang][OpenMP] Experimental pass to map `do concurrent` to OMP (PR #77285)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Thu Jan 11 08:45:35 PST 2024


klausler wrote:

> > Do not run `DO CONCURRENT` in parallel by default without ensuring first that the loop is free of non-parallelizable data usage.
> 
> Thanks for your reply. Yup, I am looking into understanding the inherent issues in `do concurrent` at the moment. I spent sometime going over your discussions on Github and J3 forums (not directly you but relevant to the issues you raised) ([[1]](https://github.com/j3-fortran/fortran_proposals/issues/62), [[2]](https://mailman.j3-fortran.org/pipermail/j3/2020-July/012229.html), and the linked papers and documents) and trying to understand the issues in deeper detail. Once I form some more background, I will reach out to you if you don't mind since you thought about this problem a lot longer than I did.

It is not complicated.

There are two common assumptions about DO CONCURRENT that are not true.  First, due to the name, many people assume that DO CONCURRENT is an assertion by the programmer that the loop is safe to parallelize and/or a request to parallelize the loop.  Second, that the restrictions imposed by the standard on DO CONCURRENT loops make any conformant program safe to parallelize.

The actual definition of DO CONCURRENT is such that it is safe to execute the iterations of the loop in any serial order.  They are not sufficient to execute the iterations of the loop in parallel.  You can write a DO CONCURRENT loop that is perfectly conformant with the standard but still unsafe to parallelize.

The standard could be fixed with a small change, but the committee won't do it.

If you have permission from the user via the command line to parallelize, fine.  But by default, you still need to analyze the data flow in the loop to guarantee safe parallelization.

https://github.com/llvm/llvm-project/pull/77285


More information about the flang-commits mailing list