OpenACC_Fortran_Command terminated by signal 11

I am planning to benefit from the OpenACC data regions, in order to use the cuSPARSE library. However, it can be used in the Host Code. Then I put the subroutines, which are in a module, to the Host Code. Yet, when i compile and run the code it gives the ‘signal 11’. The code works when the subroutines are in a module; when it is not in a module, it crashes. What should I do to work the code?

The Makefile:

FC=nvfortran
TIMER=/usr/bin/time
OPT=
NOPT=-fast -Minfo=opt $(OPT)

abc: abc.o
(TIMER) ./abc.o (STEPS) -acc -fopenmp
abc.o: abc.f90
(FC) -o @ $< -fopenmp -acc -ta=tesla:cc75 -Minfo=accel

clean:
rm -f *.o *.exe *.s *.mod a.out

The Code:

program main

use omp_lib

implicit none

integer :: nsize, i
real*8, allocatable :: A(:,:), C(:,:), b(:)
real*8 :: k(550), r
real*8 :: start_time, elapsed_time

nsize = 10000

allocate(A(nsize,nsize),C(nsize,nsize))
allocate(b(nsize))

call init_diag_dom_mat(A)

do i = 1, nsize
    call random_number(r)
    b(i) = mod(r, 51.0d0)
end do 

start_time = omp_get_wtime()

!$OMP PARALLEL DO DEFAULT(NONE) &
!$OMP PRIVATE(C,i) NUM_THREADS(10) &
!$OMP SHARED(A,b,nsize,k)
do i = 1,550
    k(i) = 0.0d0
    C = A*float(i)
    call tartar(C, b, nsize, k(i))
enddo 
!$OMP END PARALLEL DO

write (*,*) k(1)

elapsed_time = omp_get_wtime() - start_time

write (*,*)  elapsed_time, " seconds"

return

end program main

subroutine init_diag_dom_mat(A)

implicit none

real*8, intent(out), dimension(:,:) :: A
integer :: i,j,nsize
real*8 :: sum, x

nsize = ubound(A,1)

do i = 1, nsize
    sum = 0
    do j = 1, nsize
        call random_number(x)
    x = mod(x, 23.0d0) / 1000.0d0
    A(j,i) = x
    sum = sum + x
end do
    
    A(i,i) = A(i,i) + sum
    
do j = 1, nsize
        A(j,i) = A(j,i) / sum
end do
end do

end subroutine

subroutine tartar(A, b, nsize, k)

implicit none

real*8, intent(inout), dimension(:,:) :: A
real*8, intent(in), dimension(:) :: b
real*8, allocatable, dimension(:) :: c,d 
real*8, intent(inout):: k
real*8 :: e, f
integer :: i, j, z
integer, value :: nsize

nsize = ubound(A,1)

allocate(c(nsize),d(nsize))

a = 0.0d0

do i = 1, nsize
    A(i,i) = A(i,i) + 2.0d0
end do

do i = 1, nsize
        A(i,i) = A(i,i)/2.0d0
end do


!$acc data copyin(A(nsize,nsize),b(nsize)) copyout(c(nsize),d(nsize)) 
!$acc parallel loop gang async
do i = 1, nsize
    e = 0.0d0
    !$acc loop seq reduction(+:e)
    do j = 1,nsize
        !$acc loop vector
        do z = 1,nsize
    
            e = e + A(i,j)*A(i,z)
        
        end do
    end do
    c(i) = e
end do

!$acc parallel loop gang async
do i = 1, nsize
    f = 0.0d0
    !$acc loop vector reduction(+:f)
    do j = 1,nsize
    
        f = f + A(i,j)*b(j)
    
    end do
    d(i) = f
end do
!$acc wait 

!$acc end data

end subroutine

The Compilation Error:

nvfortran -o abc.o abc.f90 -fopenmp -acc -ta=tesla:cc75 -Minfo=accel
tartar:
108, Generating copyin(a(:nsize,:nsize),b(:nsize)) [if not already present]
Generating copyout(d(:nsize),c(:nsize)) [if not already present]
109, Generating Tesla code
110, !$acc loop gang ! blockidx%x
113, !$acc loop seq
115, !$acc loop vector(128) ! threadidx%x
Generating reduction(+:e)
115, Loop is parallelizable
124, Generating Tesla code
125, !$acc loop gang ! blockidx%x
128, !$acc loop vector(128) ! threadidx%x
Generating reduction(+:f)
128, Loop is parallelizable
/usr/bin/time ./abc.o -acc -fopenmp
Command terminated by signal 11
0.01user 0.00system 0:00.10elapsed 10%CPU (0avgtext+0avgdata 5600maxresident)k
0inputs+0outputs (0major+296minor)pagefaults 0swaps
make: *** [Makefile:8: abc] Error 139

Thank you for your attention!

Without an interface, Fortran will use F77 style calling conventions which essentially will pass arrays as a raw pointer. Here you’re using assumed shape arrays in the subroutines which require F90 calling conventions so the array descriptors are passed in as well. Hence in order to work, you either need to add interfaces for the subroutines, include these routines in a module where an implicit interface will be generated, or use F77 assumed size arrays.

-Mat