Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

ifort with mkl and function mkl_sparse_d_mv

watanabe__renato
Beginner
1,266 Views

 

I compile my program and it gives the following error:

forrtl: severe (174): SIGSEGV, segmentation fault occurred

I isolated the problem and it is occurring at the call of the mkl_sparse_d_mv function of the following function:

function dVdt(self, t, V)
        class(MotorUnitPool), intent(inout) :: self
        real(wp), intent(in) :: t
        real(wp), intent(in) :: V(:)
        real(wp), dimension(self%totalNumberOfCompartments) :: dVdt
        integer :: i, j, stat
        real(wp), dimension(:), allocatable :: matInt

        allocate(matInt(self%totalNumberOfCompartments))
              
        do i = 1, self%MUnumber
            do j = 1, self%unit(i)%compNumber
                self%iIonic((i-1)*self%unit(i)%compNumber+j) = self%unit(i)%Compartments(j)%computeCurrent(t, V((i-1)*self%unit(i)%compNumber+j))
            end do
        end do       
        
        stat = mkl_sparse_d_mv(self%spOperation, &
                                                self%spAlpha, &
                                                self%GSp, &
                                                self%spDescr, &
                                                V, &
                                                self%spBeta, &
                                                matInt)
        
        dVdt = (self%iIonic + matInt + self%iInjected + self%EqCurrent_nA) * self%capacitanceInv       
end function

I compile with gfortran without any problems. As compiler options to the ifort compiler i tried to use the option -heap_arrays, whith no success.

This function is part of a bigger program, with some files. If you want to see the whole software, you can find it in https://github.com/rnwatanabe/projectFR . 

 

Thanks in advance,

 

Renato Watanabe

 

 

 

0 Kudos
1 Solution
MariaZh
Employee
1,266 Views

Hi,

I don't see a call to the mkl_sparse_destroy() routine.
(please, refer to https://software.intel.com/en-us/mkl-developer-reference-fortran-mkl-sparse-destroy)
I guess this can be a root cause for the memory leak in your implementation.

Please, let me know what you find out!
Best regards,
Maria

View solution in original post

0 Kudos
7 Replies
Gennady_F_Intel
Moderator
1,266 Views

could you isolate the case in the form of standalone example whicj we may compile and execute on our side w/o extracted the code from your project!  

0 Kudos
watanabe__renato
Beginner
1,266 Views

Thank you for  your answer Gennady.

I isolated the problem in one file.  It has a run-time segmentation fault  with ifort and not with gfortran:

forrtl: severe (174): SIGSEGV, segmentation fault occurred

Image              PC                Routine            Line        Source
spTest             0000000000860BAD  Unknown               Unknown  Unknown
libpthread-2.23.s  00007FBA1A709390  Unknown               Unknown  Unknown
spTest             0000000000545E88  Unknown               Unknown  Unknown
spTest             00000000004090B0  Unknown               Unknown  Unknown
spTest             0000000000406DAA  Unknown               Unknown  Unknown
spTest             000000000040484C  Unknown               Unknown  Unknown
spTest             000000000040332E  Unknown               Unknown  Unknown
libc-2.23.so       00007FBA19E41830  __libc_start_main     Unknown  Unknown
spTest             0000000000403229  Unknown               Unknown  Unknown

The file is attached.

 

0 Kudos
Gennady_F_Intel
Moderator
1,266 Views

could you please show the linking line

0 Kudos
watanabe__renato
Beginner
1,266 Views

The whole command line I used is :

 

ifort -c $MKLROOT/include/mkl_spblas.f90 &  ifort spTest.f90 -o spTest -O3  -Wl,--start-group $MKLROOT/lib/intel64/libmkl_intel_lp64.a $MKLROOT/lib/intel64/libmkl_sequential.a $MKLROOT/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread -lm -ldl -I$MKLROOT/include

The Linux version is:

 

Linux  4.15.0-33-generic #36-Ubuntu  x86_64 x86_64 x86_64 GNU/Linux

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic

The ifort version is:

ifort (IFORT) 18.0.3 20180410
 

The MKL version is the version released in May 2018.

 

Thank you,

 

Renato

 

 

 

0 Kudos
watanabe__renato
Beginner
1,266 Views

I found a way to solve the issue. If I create the sparse matrix every step of the simulation, it works fine, both with gfortran and ifort. The code is attached. The problem now is that there is a memory leak. on the creation of the sparse matrix. Any idea of why?

0 Kudos
MariaZh
Employee
1,267 Views

Hi,

I don't see a call to the mkl_sparse_destroy() routine.
(please, refer to https://software.intel.com/en-us/mkl-developer-reference-fortran-mkl-sparse-destroy)
I guess this can be a root cause for the memory leak in your implementation.

Please, let me know what you find out!
Best regards,
Maria

0 Kudos
watanabe__renato
Beginner
1,266 Views

Thank you Maria! Now it worked.

Renato

0 Kudos
Reply