[Openmp-commits] [PATCH] D51875: [OPENMP][NVPTX] Add support for lastprivates/reductions handling in SPMD constructs with lightweight runtime.
Jonas Hahnfeld via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Fri Sep 28 06:44:18 PDT 2018
Hahnfeld added a comment.
In https://reviews.llvm.org/D51875#1249019, @ABataev wrote:
> No, you're not correct here.
>
> void outlined_target_fn(int *last) {
> int *last_ds = /* get data sharing frame from runtime */
> for (/* distribute loop from 0 to 9999 */) {
> outlined_parallel_fn(lb, ub, last_ds);
> }
> if (/* received last chunk */) {
> *last = *last_ds;
> }
> }
>
>
> This code is for the distribute loop. And here you have conflict without the datasharing scheme. The problem here is that this check `/* received last chunk */` is `true` for all inner loop iterations for inner `for` directive and `*last_ds` may come not from the last iteration of `for` loop, but from some other iterations. To solve this problem, we need to share the same `last_ds` between all the threads in the team.
Yes, that's the current solution in Clang and actually what I described above:
In https://reviews.llvm.org/D51875#1248997, @Hahnfeld wrote:
> In SPMD constructs all CUDA threads are executing the `distribute` loop, but only the thread executing the last iteration of the `for` loop has seen the `lastprivate` value. However the information of which thread this is has been lost at the end of the `parallel` region. So data sharing is used to communicate the `lastprivate` value to all threads in the team that is executing the last `distribute` chunk.
I'm assuming that the pointer returned by `/* get data sharing frame from runtime */` is shared between all threads in a team.
Repository:
rL LLVM
https://reviews.llvm.org/D51875
More information about the Openmp-commits
mailing list