Issue 150297
Summary Flang OpenMP: OpenMP BLAS build broken with latest Flang.
Labels
Assignees
Reporter scamp-nvidia
    We periodically build OpenBLAS with the latest Flang version and we recently identified that the OpenMP build of OpenBLAS crashes with the latest build of Flang from the upstream version due to OpenMP semantics issues. Particularly this seems to be due to how Flang relates an array passed in as size (*) with that array being called in a DEPEND clause and only feeding part of it. A basic reproducing example is given below:

test.F90:
```
subroutine omp_task_depend_reproducer(work, n, myid, shift)
  use omp_lib
  implicit none
  integer, intent(in) :: n, myid, shift
  real, intent(inout) :: work(*)
  integer :: tid

!$omp parallel shared(work, myid, shift) private(tid)
  !$omp single
    !$omp task depend(in:work(myid+shift-1)) depend(in:work(myid-1)) depend(out:work(myid))
      tid = omp_get_thread_num()
      call dummy_kernel(work(myid))
    !$omp end task
  !$omp end single
!$omp end parallel
contains
  subroutine dummy_kernel(x)
    real :: x
    x = x + 1.0
  end subroutine dummy_kernel
end subroutine omp_task_depend_reproducer
```
Compiling this with the latest Flang build: 
```
scamp@dev-sky5:/local/home/scamp/openblas$ flang test.F90 -c -fopenmp
error: Semantic errors in test.F90
./test.F90:10:26: error: Whole assumed-size array 'work' may not appear here without subscripts
      !$omp task depend(in:work(myid+shift-1)) depend(in:work(myid-1)) depend(out:work(myid))
                           ^^^^
./test.F90:5:26: Declaration of 'work'
    real, intent(inout) :: work(*)
 ^^^^
./test.F90:10:56: error: Whole assumed-size array 'work' may not appear here without subscripts
      !$omp task depend(in:work(myid+shift-1)) depend(in:work(myid-1)) depend(out:work(myid))
 ^^^^
./test.F90:5:26: Declaration of 'work'
    real, intent(inout) :: work(*)
                           ^^^^
./test.F90:10:81: error: Whole assumed-size array 'work' may not appear here without subscripts
      !$omp task depend(in:work(myid+shift-1)) depend(in:work(myid-1)) depend(out:work(myid))
 ^^^^
./test.F90:5:26: Declaration of 'work'
 real, intent(inout) :: work(*)
 ^^^^
scamp@dev-sky5:/local/home/scamp/openblas$ flang test.F90 -c -fopenmp --version
flang version 22.0.0git (https://github.com/llvm/llvm-project 17e32c921acc856498ad13ade495374bed4605b2)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /proj/nv/llvm/Linux_x86_64/llvm-5638/bin
Build config: +assertions
```
Tracking wise, we have pretty big hash gaps inbetween our builds but I know that this issue slipped in between 

```
LLVM Hash Analysis:
  Older Hash: 30725efe671bc82bf9095a575aece60fc40fbef5 
  Newer Hash: 2f1e6eb6c3e731266052536c3f98cce3a71a316e 
```
Of the most obvious significance in that region, we found: 

`4a47634a0075 [flang][OpenMP] Support substrings and complex part refs for DEPEND (#143907)`

This is from @tblah and directly deals with OpenMP DEPENDS clauses, which is the heart of the issue here, so I'm particularly suspicious that's the offending commit - that this reproducing code just lives in an edge case of the work there. 

Note that GCC 14 and NVHPC 25.7 both compile the reproducing example fine, and if I remove the "-fopenmp" from the Flang compile, it works fine. 
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to