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

system crash when running dss on MKL_dss_indefinite

may_ka
Beginner
842 Views

Hey there,

my dss implementation freezes the whole system, probably due running out of memory, when switching from positive_definite to indefinite.

The matrix provided to dss is 4x4, so not a big problem, but it is negative definite.

The module implementing the solver is:

include "mkl_dss.f90"
Module ModMKLSolver
  use Data_Kind
  use ModEquation
  use ModLogfile
  Implicit none
  Type MKLSolver
    Type(Equation) :: TSEq
  contains
    Procedure, Pass, Public :: Solve => SubSetPEVDSS
  End type MKLSolver
  Private :: SubSetPEVDSS
contains
  Subroutine SubSetPEVDSS(this,ISSubStat)
    use MKL_DSS
    Implicit None
    Class(MKLSolver), Target, Intent(InOut) :: this
    Integer(Iks), Intent(InOut) :: ISSubStat
    Integer(Ikxl) :: c1, c2
    TYPE(MKL_DSS_HANDLE) :: handle
    Integer(Ikxl) :: ISError
    Integer(Ikl) :: opt, a, ISSize
    Integer(Ikl), Allocatable, Dimension(:) :: IVPermu
    ISSize=this%TSEq%TSLHS%ISDim
    Allocate(&
      &IVPermu(ISSize),&
      &stat=ISSubStat)
    If(ISSubStat==0) Then
      IVPermu=0
      this%TSEq%RVsol=0._rkdbl
      ISSubStat=dss_create(handle, MKL_DSS_MSG_LVL_WARNING&
        &+MKL_DSS_TERM_LVL_ERROR)
      If(ISSubStat==0) Then
        ISSubStat=dss_define_structure(handle=handle,&
          &opt=MKL_DSS_SYMMETRIC,&
          &rowIndex=this%TSEq%TSLhs%IVRowPos,&
          &nRows=ISSize,&
          &RCols=ISSize,&
          &columns=this%TSEq%TSLhs%IVColPos,&
          &nNonZeros=size(this%TSEq%TSLhs%RVCoeff))
      End If
      If(ISSubStat==0) Then
        ISSubStat=dss_reorder(handle=handle, opt=MKL_DSS_GET_ORDER, perm&
          &=IVPermu)
      end If
      If(ISSubStat==0) Then
        ISSubStat=dss_factor(handle=handle,&
          !&opt=MKL_DSS_POSITIVE_DEFINITE,&
          &opt=MKL_DSS_INDEFINITE,&
          &RValues=this%TSEq%TSLhs%RVCoeff)
      End If
      If(ISSubStat==0) Then
        ISSubStat=dss_solve(handle=handle,&
          &opt=0,&
          &RRhsValues=this%TSEq%RVRHS,&
          &nRhs=1,&
          &RSolValues=this%TSEq%RVSol)
      End If
    End If
  end Subroutine SubSetPEVDSS
end Module ModMKLSolver

The implementation works with setting "positive_definite" and matrices which abide by that rule.

Compiler: ifort 15, System: ubuntu 14.04

Any suggestions??

Thanks

Karl

0 Kudos
4 Replies
Kevin_D_Intel
Employee
842 Views

I relocated this post to the MKL forum.

0 Kudos
Ying_H_Intel
Employee
842 Views

Hi May,ka, 

Could you please attach the fortran file ( with the test matrix)?  

There is button at the end of page. You can use it to attach file. 

 
Browse

Thanks

Ying 

0 Kudos
may_ka
Beginner
842 Views

Find a compilable program below. However, I found that the issue might be a memory leak in DSS solver routines. Compiling with "indefinite" or "positive definite" yields valid solutions when calling dss with appropriate matrices. But calling dss in a loop, e.g. 100000 times (see the code), will lead to stuffing up the ram. With the example below and 8GB of ram, dss ram use had increased to ~50% (recorded with "top") when reaching the 100000th iteration. This happens with both positive definite and negative definite matrices.

include "mkl_dss.f90"
Module Data_Kind
  Implicit None
  Integer, Parameter :: IkXL=Selected_Int_Kind(12)
  Integer, Parameter :: IkL=Selected_Int_Kind(8)
  Integer, Parameter :: IkM=Selected_Int_Kind(4)
  Integer, Parameter :: IkS=Selected_Int_Kind(2)
  Integer(IkS), Parameter :: RkDbl=Selected_Real_Kind(15,100)
  Integer(IkS), Parameter :: RkSgl=Selected_Real_Kind(6,37)
End Module Data_Kind
Module ModSparseSquaredUpperTriangularMatrix
  use Data_Kind
  Implicit None
  Type :: SparseSquaredUpperTriangularMatrix
    Integer(IkXL) :: ISDim=0_ikxl
    Integer(IkL), allocatable, Dimension(:) :: IVColPos, IVRowPos
    Real(Rkdbl), allocatable, Dimension(:) :: RVCoeff
  End type SparseSquaredUpperTriangularMatrix
End Module ModSparseSquaredUpperTriangularMatrix
Module ModEquation
  use Data_Kind
  use ModSparseSquaredUpperTriangularMatrix
  Implicit None
  Type :: Equation
    Real(Rkdbl), Pointer, Dimension(:) :: RVSol, RVRhs
    Type(SparseSquaredUpperTriangularMatrix), Pointer :: TSLhs
  End type Equation
End Module ModEquation
Module ModMKLSolver
  use Data_Kind
  use ModEquation
  Implicit none
  Type MKLSolver
    Type(Equation) :: TSEq
  contains
    Procedure, Pass, Public :: Solve => SubSetPEVDSS
  End type MKLSolver
  Private :: SubSetPEVDSS
contains
  Subroutine SubSetPEVDSS(this,ISSubStat)
    use MKL_DSS
    Implicit None
    Class(MKLSolver), Target, Intent(InOut) :: this
    Integer(Iks), Intent(InOut) :: ISSubStat
    TYPE(MKL_DSS_HANDLE) :: handle
    Integer(Ikxl) :: ISError
    Integer(Ikl) :: opt, a, ISSize
    Integer(Ikl), Allocatable, Dimension(:) :: IVPermu
    ISSize=this%TSEq%TSLHS%ISDim
    Allocate(&
      &IVPermu(ISSize),&
      &stat=ISSubStat)
    If(ISSubStat==0) Then
      IVPermu=0
      this%TSEq%RVsol=0._rkdbl
      ISSubStat=dss_create(handle, MKL_DSS_MSG_LVL_WARNING&
        &+MKL_DSS_TERM_LVL_ERROR)
      If(ISSubStat==0) Then
        ISSubStat=dss_define_structure(handle=handle,&
          &opt=MKL_DSS_SYMMETRIC,&
          &rowIndex=this%TSEq%TSLhs%IVRowPos,&
          &nRows=ISSize,&
          &RCols=ISSize,&
          &columns=this%TSEq%TSLhs%IVColPos,&
          &nNonZeros=size(this%TSEq%TSLhs%RVCoeff))
      End If
      If(ISSubStat==0) Then
        ISSubStat=dss_reorder(handle=handle, opt=MKL_DSS_GET_ORDER, perm&
          &=IVPermu)
      end If
      If(ISSubStat==0) Then
        ISSubStat=dss_factor(handle=handle,&
          &opt=MKL_DSS_POSITIVE_DEFINITE,&
          !&opt=MKL_DSS_INDEFINITE,&
          &RValues=this%TSEq%TSLhs%RVCoeff)
      End If
      If(ISSubStat==0) Then
        ISSubStat=dss_solve(handle=handle,&
          &opt=0,&
          &RRhsValues=this%TSEq%RVRHS,&
          &nRhs=1,&
          &RSolValues=this%TSEq%RVSol)
      End If
    End If
  end Subroutine SubSetPEVDSS
end Module ModMKLSolver
Program DSS_Test
  use Data_Kind
  use ModMKLSolver
  use ModSparseSquaredUpperTriangularMatrix
  Implicit None
  Integer(Iks) :: ISSubstat
  Real(Rkdbl) :: RMLhsPD(4,4)
  Real(Rkdbl), Target :: RVRhs(4), RVSol(4)
  Type(SparseSquaredUpperTriangularMatrix), Target :: TSLhsPD
  Type(MKLSolver) :: TSSolver
  Integer(IkXL) :: c1
  !!set the full matrices (for fun)
  RMLhsPD=reshape((/5.2800,13.8366,16.6227,0.0000,&
    &13.8366,74.0000,84.8594,0.0000,&
    &16.6227,84.8594,173.0000,0.0000,&
    &0.0000,0.0000,0.0000,60.0000/),shape(RMLhsPD))
  RVRhs=(/1,0,0,0/) !!set the right hand side
  !!set the sparse upper triangular matrices
  Allocate(TSLhsPD%IVColPos(7),TSLhsPD%RVCoeff(7),TSLhsPD%IVRowPos(5))
  TSLhsPD%ISDim=4
  TSLhsPd%IVColPos=(/1,2,3,2,3,3,4/)
  TSLhsPd%RVCoeff=(/5.2800,13.8366,16.6227,74.0000,84.8594,173.0000&
    &,60.0000/)
  TSLhsPD%IVRowPos=(/1,4,6,7,8/)
  !!solve
  TSSolver%TSEq%TSLhs => TSLhsPd
  TSSolver%TSEq%RVRhs => RVRhs
  TSSolver%TSEq%RVSol => RVSol
  Do c1=1,100000
    call TSSolver%Solve(ISSubStat)
  End Do
End Program DSS_Test

 

Below the makefile used to compile the program

FC =ifort -mkl -warn nounused -warn declarations -static -O3 -parallel
SRC :=
MKLPATH=$(MKLROOT)/lib/intel64/
MKLINCLUDE=$(MKLPATH)/include/

MKL= -L$(MKLPATH) -I$(MKLINCLUDE) -lmkl_blas95_lp64 -lmkl_lapack95_lp64 -Wl,--start-group $(MKLPATH)/libmkl_intel_lp64.a $(MKLPATH)/libmkl_intel_thread.a $(MKLPATH)/libmkl_core.a -Wl,--end-group -liomp5 -lpthread

.SUFFIXES:
.SUFFIXES: .f90

include Main.mk

OBJS = $(subst .f90,.o,$(SRC))

%.o: %.f90
	$(FC) -c -o $@ $<

DSS: $(OBJS)
	$(FC) -o $@ $^ $(MKL)


clean:
	rm *.mod
	rm *.o

 

Thanks for the support.

Cheers

 

Karl

0 Kudos
may_ka
Beginner
842 Views

Solved!!

I forgot the dss_delete.

Cheers

Karl

0 Kudos
Reply