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,
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
xs(:,l,j) = x(:,l,k-1) + matmul(ks(:,l,:j-1),as(:j-1,j))
heap-arrays as below, the code with -qopenmp works, no error.
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.
A similar post is here below,
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
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.