Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang][OpenMP] support arrays of atomic numbers #112908

Open
tblah opened this issue Oct 18, 2024 · 2 comments
Open

[flang][OpenMP] support arrays of atomic numbers #112908

tblah opened this issue Oct 18, 2024 · 2 comments

Comments

@tblah
Copy link
Contributor

tblah commented Oct 18, 2024

Support for atomic operations on scalar complex variables is being added in #92364.

flang also supports atomic operations which read a single element from an array. The openmp standard says that the lhs and rhs of the assignment must be "scalar variables of intrinsic type" (OpenMP 5.2 section 4.3.1.3). The result of the expression on the rhs must be scalar but the expression might involve arrays.

Currently (and after #92364) Flang will crash on an assertion on this code:

program atomic_array
  complex :: x(2)
  complex :: y
  !$omp parallel
    !$omp atomic read
      y = x(1)
  !$omp end parallel
end program

Reproduce with flang -fopenmp file.f90.

CC @NimishMishra

@NimishMishra
Copy link
Contributor

Thanks for reporting. I'm assigning it to myself; will investigate and get back.

@NimishMishra
Copy link
Contributor

I tested out this issue. Seems like with #111377, the test case works correctly.

program atomic_array
  complex :: x(2)
  complex :: y

  x(1) = (1.0, 1.0)
  x(2) = (2.0, 2.0)
  !$omp parallel
    !$omp atomic read
      y = x(1)
  !$omp end parallel
  print *, y
end program

Gives me (1. , 1.) if I test with #111377, which is ok.

However, there will still be issues with the following test case:

program atomic_array
  complex :: x(2)
  integer :: y

  x(1) = (1.0, 1.0)
  x(2) = (2.0, 2.0)
  !$omp parallel
    !$omp atomic read
      y = x(1)
  !$omp end parallel
  print *, y
end program

which segfaults. So I have included type conversion (see https://github.com/NimishMishra/f18-llvm-project/commits/atomic_complex_type_conversion/ upon #111377). With these two commits, atomic read works ok for non-conforming types (I get 1 for the above test-case).

Should I raise this fix as another PR? Or should I merge with #111377. Let me know what is preferable to you. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants