Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
27223 Discussions

Why /heap-arrays0 cause /qopenmp show access violation for do concurrent?

CRquantum
New Contributor I
154 Views

A very simple question about do concurrent. Code is below,

program mainomp
  implicit none
  integer, parameter :: r8=selected_real_kind(15,9)
  real, allocatable :: x(:,:,:),ks(:,:,:),xs(:,:,:)
  integer :: i,j,nstep,np,nd,l,k
  real(kind=r8), parameter :: as(4,4) = reshape([ &
    &  0.0_r8,              0.0_r8,              0.0_r8,              0.0_r8, &
    &  2.71644396264860_r8, 0.0_r8,              0.0_r8,              0.0_r8, &
    & -6.95653259006152_r8, 0.78313689457981_r8, 0.0_r8,              0.0_r8, &
    &  0.0_r8,              0.48257353309214_r8, 0.26171080165848_r8, 0.0_r8 ], [4,4]) 
  np=10**5
  nd=2
  nstep=10**3
  allocate(x(np,nd,0:nstep))
  allocate(xs(np,nd,4))
  allocate(ks(np,nd,4))
  do k = 1, nstep
    do j = 1,4
      do concurrent (l=1:nd)
        xs(:,l,j) = x(:,l,k-1) + matmul(ks(:,l,:j-1),as(:j-1,j))           
      enddo  
    enddo   
  enddo
end program mainomp

 

The problem is, if I compile with /qopenmp and with /heap-arrays0 as below,

CRquantum_0-1649096903063.pngCRquantum_1-1649096927648.png

 

When I run code I got error message 'access violation', 

forrtl: severe (157 Program Exception - access violation
Image              PC                Routine            Line        Source
openMPtest.exe     00007FF6CC756A0A  Unknown               Unknown  Unknown
openMPtest.exe     00007FF6CC7317B2  MAIN__                     20  main_omp.f90
libiomp5md.dll     00007FF80756D853  Unknown               Unknown  Unknown
libiomp5md.dll     00007FF8074CEC67  Unknown               Unknown  Unknown
libiomp5md.dll     00007FF8074D0A26  Unknown               Unknown  Unknown
libiomp5md.dll     00007FF807487751  Unknown               Unknown  Unknown
openMPtest.exe     00007FF6CC73155C  MAIN__                     19  main_omp.f90
openMPtest.exe     00007FF6CC761E5E  Unknown               Unknown  Unknown
openMPtest.exe     00007FF6CC76223C  Unknown               Unknown  Unknown
KERNEL32.DLL       00007FF8A9EC7034  Unknown               Unknown  Unknown
ntdll.dll          00007FF8AABA2651  Unknown               Unknown  Unknown

 

at line

 

xs(:,l,j) = x(:,l,k-1) + matmul(ks(:,l,:j-1),as(:j-1,j))         

 

However, without heap-arrays as below, the code with -qopenmp works, no error.

CRquantum_2-1649097109098.png

 

Can someone please explain why heap-arrays will cause /qopenmp and do concurrent not compatible? Thanks much in advance!

 

I use Intel OneAPI 2022.0.3 on Windows 10 21H2.

 

PS.

A similar post is here below,

https://fortran-lang.discourse.group/t/why-heap-arrays0-cause-qopenmp-show-access-violation-for-do-c...

0 Kudos
2 Replies
Ron_Green
Moderator
126 Views

Hi @CRquantum 

 

I saw this issue on fortran-discourse this morning.  I ran a few tests.  This bug appears on all 3 supported OSes.  What's more, the OMP equivalent:

 

  do k = 1, nstep
    do j = 1,4
      !$omp parallel do 
      do l=1,nd
        xs(:,l,j) = x(:,l,k-1) + matmul(ks(:,l,:j-1),as(:j-1,j))           
      enddo  
    enddo   
  enddo

 

has no problem.  I even tried the LOCAL_INIT clause but that was no help. 

It's interesting, it crashes on the first entry to DO CONCURRENT.  Here's my hack to test when the fault occurs:

 

  do k = 1, nstep
    do j = 1,4
      print*, "calling do concurrent k and j are: ", k,j
      print*, "nd is ", nd
      do concurrent (l=1:nd)
        xs(:,l,j) = x(:,l,k-1) + matmul(ks(:,l,:j-1),as(:j-1,j))           
      enddo  
    enddo   
  enddo
  print*, "done"


./a.out
 calling do concurrent k and j are:            1           1
 nd is            2
forrtl: severe (174): SIGSEGV, segmentation fault occurred

 

So definitely an interaction of HEAP-ARRAYS.  Bug ID is CMPLRIL0-34679.  Barbara will track this bug for us.  Thanks for bringing this issue to our attention

 

ron

CRquantum
New Contributor I
120 Views

Thank you Ron! Well our first names are kind of similar, mine is Rong yours is Ron, LOL.

Yes, right now, it seems if I have to use heap-arrays + -qopenmp, then I have to change all the ```do concurrent``` just to regular ```do``` and add ```!$OMP PARALLEL DO``` as you did. 

Hopefully this bug could be fixed soon. After all, it is really cool if -qopenmp can be compatible with heap-arrays and do concurrent. 

Best regards,

Rong

Reply