flang-compiler / f18-llvm-project

Fork of llvm/llvm-project for f18. In sync with f18-mlir and f18.
http://llvm.org
28 stars 16 forks source link

[Flang][OpenMP] Add support for lastprivate clause lowering. #1593

Open arnamoy10 opened 2 years ago

arnamoy10 commented 2 years ago

Thanks for the comment @kiranchandramohan . From this C++ OpenMP example, looking at the diff between with and without the use of lastprivate, it looked like the change necessary was just to add a load and store of the lastprivatevariable at the end of the loop. I did not see any code that checks the last iteration's value. I was under the impression that OpenMP runtime calls will take care of that.

It will be great if you can point to the part of the IR that ensures it.

kiranchandramohan commented 2 years ago

@arnamoy10 Can you read the discussion in https://discourse.llvm.org/t/rfc-privatisation-in-openmp-dialect/3526?

I think the lastprivate handling is not done in the body of the loop in the llvm it generated but it is in the footer or exit portion of the loop. We do not have a representation for the footer/exit portion of the loop in omp.wsloop. So we are forced to add a condition inside the body of the loop that checks whether it is the last iteration and then do an update.

I can explain more if required.

schweitzpgi commented 2 years ago

Q: is there a related phabricator review to this PR? Thanks for working on this.

arnamoy10 commented 2 years ago

@schweitzpgi Thanks for asking, unfortunately, privatization implementation, for now, has to be done in fir-dev, through pull req style. Here is the relevant discussion in slack

kiranchandramohan commented 2 years ago

Q: is there a related phabricator review to this PR? Thanks for working on this.

@schweitzpgi Is a phabricator review what you would prefer for OpenMP work?

schweitzpgi commented 2 years ago

Q: is there a related phabricator review to this PR? Thanks for working on this.

@schweitzpgi Is a phabricator review what you would prefer for OpenMP work?

See Steve's announcement here. https://discourse.llvm.org/t/nvidia-transition-from-fir-dev/61947

I think transitioning to working upstream, in so far as it is possible to do so, would be a good direction.