[PATCH] D105375: [OPENMP]Remove const firstprivate allocation as a variable in a constant space.

Joseph Huber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 8 09:21:10 PDT 2021


jhuber6 added a comment.

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.


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