f18-llvm-project icon indicating copy to clipboard operation
f18-llvm-project copied to clipboard

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

Open arnamoy10 opened this issue 3 years ago • 6 comments

arnamoy10 avatar Apr 19 '22 00:04 arnamoy10

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 lastprivate variable 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.

arnamoy10 avatar Apr 19 '22 14:04 arnamoy10

@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.

kiranchandramohan avatar Apr 19 '22 15:04 kiranchandramohan

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

schweitzpgi avatar Apr 20 '22 18:04 schweitzpgi

@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

arnamoy10 avatar Apr 20 '22 18:04 arnamoy10

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?

kiranchandramohan avatar Apr 21 '22 08:04 kiranchandramohan

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.

schweitzpgi avatar Apr 21 '22 22:04 schweitzpgi