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

Single-precision PARDISO gives wrong results!

Hassan-Ebrahimi
New Contributor I
735 Views

Hi everyone.

As a very simple example, I have a 2x2 matrix equation with a diagonal coefficient matrix. 

 

Fortran wrapper of PARDISO is used for both single and double precision versions.

 

The difference between the double-precision and single-precision subroutine is minimal. Except for the number formats and the value of iparam(28), everything else is the same.

The double-precision subroutine gives correct result but the result of the single-version subroutine is basically meaningless.

 

I have never used the single-precision version of PARDISO, so I am not sure of my settings.

 

Would you please point at what I may be missing?

 

The subroutines and the relevant outputs are attached.

 

Thank you.

 

Hassan Ebrahimi

0 Kudos
1 Solution
Hassan-Ebrahimi
New Contributor I
643 Views

I installed the 2022 version and it still gave the same wrong result.

 

However the issue was solved by setting iparam(1) =1

 

I post my  single example here for those who may face the same issue.

 

subroutine pardiso_single()

INTEGER*8 pt(64)
INTEGER maxfct, mnum, mtype, phase, neq, nrhs, error, msglvl
INTEGER iparm(64)
INTEGER ia(2)
INTEGER ja(3)
real *4 a(2)
real *4 b(2)
real *4 x(2)
INTEGER i, j, idum,asym
INTEGER perm(30)
real*4 ddum
character*198 buf

WRITE(*,*) '********** Single precision PARDISO **************'

call mkl_get_version_string(buf)
write(*,'(a)') buf

maxfct=1
nrhs=1
mnum=1

do i=1,64
pt(i)=0
enddo

neq=2
a(1)=4.0
a(2)=4.0

b(1)=1.0
b(2)=1.0

x(1)=0.0
x(2)=0.0

ja(1)=1
ja(2)=2
ja(3)=3

ia(1)=1
ia(2)=2
iparm(1)=1 ! without this setting PARDISO gives wrong result!
iparm(28)=1
error = 0 ! initialize error flag
msglvl = 1 ! print statistical information
mtype = -2 ! real symmetric
phase = 11 ! only reordering and symbolic factorization

C.. Reordering

CALL pardiso (pt, maxfct, mnum, mtype, phase, neq, a, ja, ia,
1 perm, nrhs, iparm, msglvl, b, x, error)


C.. Factorization.

phase = 22 ! only factorization
CALL pardiso (pt, maxfct, mnum, mtype, phase, neq, a, ja, ia,
1 perm, nrhs, iparm, msglvl, ddum, ddum, error)
!WRITE(*,*) 'Factorization completed ... '
IF (error .NE. 0) THEN
WRITE(*,*) 'The following ERROR was detected: ', error
STOP 1
ENDIF

C.. Back substitution and iterative refinement

phase = 33 ! solving
CALL pardiso (pt, maxfct, mnum, mtype, phase, neq, a, ja, ia,
1 perm, nrhs, iparm, msglvl, b, x, error)

do i=1,neq
WRITE(*,*) 'i, x(i) ',i, x(i)
enddo

C.. Releasing memory
phase = -1 ! release internal memory
CALL pardiso (pt, maxfct, mnum, mtype, phase, neq,
1 ddum, idum, idum,
2 idum, nrhs, iparm, msglvl, ddum, ddum, error)

END

View solution in original post

5 Replies
Gennady_F_Intel
Moderator
726 Views

Hassan,

Which version of MKL did you use with this case?

0 Kudos
Hassan-Ebrahimi
New Contributor I
719 Views

 

The mkl version is:


Intel(R) Math Kernel Library Version 2017.0.4 Product Build 20170811 for Intel(R) 64 architecture applications

 

 

0 Kudos
Gennady_F_Intel
Moderator
673 Views

I suggest you try the current version of MKL ( 2022) as a similar problem has been fixed in one of the versions in the past.


0 Kudos
Hassan-Ebrahimi
New Contributor I
644 Views

I installed the 2022 version and it still gave the same wrong result.

 

However the issue was solved by setting iparam(1) =1

 

I post my  single example here for those who may face the same issue.

 

subroutine pardiso_single()

INTEGER*8 pt(64)
INTEGER maxfct, mnum, mtype, phase, neq, nrhs, error, msglvl
INTEGER iparm(64)
INTEGER ia(2)
INTEGER ja(3)
real *4 a(2)
real *4 b(2)
real *4 x(2)
INTEGER i, j, idum,asym
INTEGER perm(30)
real*4 ddum
character*198 buf

WRITE(*,*) '********** Single precision PARDISO **************'

call mkl_get_version_string(buf)
write(*,'(a)') buf

maxfct=1
nrhs=1
mnum=1

do i=1,64
pt(i)=0
enddo

neq=2
a(1)=4.0
a(2)=4.0

b(1)=1.0
b(2)=1.0

x(1)=0.0
x(2)=0.0

ja(1)=1
ja(2)=2
ja(3)=3

ia(1)=1
ia(2)=2
iparm(1)=1 ! without this setting PARDISO gives wrong result!
iparm(28)=1
error = 0 ! initialize error flag
msglvl = 1 ! print statistical information
mtype = -2 ! real symmetric
phase = 11 ! only reordering and symbolic factorization

C.. Reordering

CALL pardiso (pt, maxfct, mnum, mtype, phase, neq, a, ja, ia,
1 perm, nrhs, iparm, msglvl, b, x, error)


C.. Factorization.

phase = 22 ! only factorization
CALL pardiso (pt, maxfct, mnum, mtype, phase, neq, a, ja, ia,
1 perm, nrhs, iparm, msglvl, ddum, ddum, error)
!WRITE(*,*) 'Factorization completed ... '
IF (error .NE. 0) THEN
WRITE(*,*) 'The following ERROR was detected: ', error
STOP 1
ENDIF

C.. Back substitution and iterative refinement

phase = 33 ! solving
CALL pardiso (pt, maxfct, mnum, mtype, phase, neq, a, ja, ia,
1 perm, nrhs, iparm, msglvl, b, x, error)

do i=1,neq
WRITE(*,*) 'i, x(i) ',i, x(i)
enddo

C.. Releasing memory
phase = -1 ! release internal memory
CALL pardiso (pt, maxfct, mnum, mtype, phase, neq,
1 ddum, idum, idum,
2 idum, nrhs, iparm, msglvl, ddum, ddum, error)

END

Gennady_F_Intel
Moderator
639 Views

Thanks for the update.

The issue(thread) is closing and we will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.



0 Kudos
Reply