[PATCH] D105375: [OPENMP]Remove const firstprivate allocation as a variable in a constant space.
Alexey Bataev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 8 11:17:15 PDT 2021
ABataev added a comment.
In D105375#2864733 <https://reviews.llvm.org/D105375#2864733>, @jhuber6 wrote:
> This revision causes a bug with generic regions. Firstprivate constants now aren't mapped properly into an internal parallel region and will just be zero. For example if I run this code I will see different values for the constants inside and outside the parallel region.
>
> #include <complex>
> #include <cstdio>
>
> void foo(const std::complex<double> X, std::complex<double> Y) {
> #pragma omp target firstprivate(X) map(from:Y)
> {
> printf ("Outside parallel: %f + %fi\n", X.real(), X.imag());
> #pragma omp parallel firstprivate(X)
> {
> printf ("Inside parallel: %f + %fi\n", X.real(), X.imag());
> Y = X;
> }
> }
> }
>
> int main() {
> std::complex<double> X = {1.0, 1.0};
> std::complex<double> Y;
> foo(X, Y);
> }
>
> Outside parallel: 1.000000 + 1.000000i
> Inside parallel: 0.000000 + 0.000000i
>
> I'm assuming they aren't being properly copied because they were originally global constants that had visibility everywhere.
Hi, thanks for the report. I think I know the reason, I prepared a patch D105647 <https://reviews.llvm.org/D105647>. Could you check if it fixes the issue?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105375/new/
https://reviews.llvm.org/D105375
More information about the cfe-commits
mailing list