intel 直接解法器的问题

wenhuaguan30 2009-08-20 10:49:34
我在测试Intel直接解法器dss_sym_f.f的过程中,出现了如下问题:
dawning:~/mkl-dss$ ./run.sh

Matrix Information: 353 .rsa
Title: Boeing/crystm01; 1995; R. Grimes; ed: T. Davis |
Size: 4875 4875 NonZeros: 55107

*** glibc detected *** double free or corruption (out): 0x0000000000a570a0 ***

使用的矩阵为对称正定.rsa文件,先利用ireadhb读入矩阵,格式为csc,后调用dcsccsr函数转成csr格式。根据打印查错,发现在dss_reorder的地方停止输出,
请问各位高人,有何解决办法?
多谢
代码如下:Example program for solving symmetric positive definite system of
C equations.
C---------------------------------------------------------------------------
subroutine fmain(fname)
IMPLICIT NONE
INCLUDE 'mkl_dss.f77'
C---------------------------------------------------------------------------
C Define the array and rhs vectors
C---------------------------------------------------------------------------
DOUBLE PRECISION,dimension(:),allocatable :: solution,rhs
DOUBLE PRECISION,dimension(:),allocatable :: values,values_new
INTEGER nRows,nCols,nzeros_l, nNonZeros, i,j,nRhs
INTEGER nd,bufLen,nmax,error,err0
integer,dimension(:),allocatable :: rowIndex, rowIndex_new,iwk
integer,dimension(:),allocatable :: columns, columns_new,indu
! integer,dimension(:),allocatable ::ia_nn,ja_nn
! DOUBLE PRECISION,dimension(:),allocatable ::a_nn
integer count1,count2,count_rate,count_max,N
DOUBLE PRECISION t
INTEGER*8 handle
CHARACTER*15 statIn
DOUBLE PRECISION statOut(5)
PARAMETER(bufLen = 20,nRhs=1)
INTEGER buff(bufLen)
character fname*256,type*3
!---------------------------------------------------------------------------
! Read the dimension of the matrix
!---------------------------------------------------------------------------
call ireadhb(fname,type,nRows,nCols,nzeros_l)
if(nRows.ne.nCols) then
write(*,*) 'error!The nRows must be equal to nCols'
stop
else
nmax=nRows
endif
C---------------------------------------------------------------------------
C Allocate storage for the solver handle and the solution vector
C---------------------------------------------------------------------------
! DOUBLE PRECISION,dimension(:),allocatable :: solution
! INTEGER*8 handle
! INTEGER error
! CHARACTER*15 statIn
! DOUBLE PRECISION statOut(5)
! INTEGER bufLen
! PARAMETER(bufLen = 20)
! INTEGER buff(bufLen)
!---------------------------------------------------------------------------
! Allocate the storage of the matrix and the vector
!---------------------------------------------------------------------------
allocate(rhs(nmax))
allocate(rowIndex(nmax+1))
allocate(values(nzeros_l))
allocate(values_new(nzeros_l))
allocate(columns(nzeros_l))
allocate(columns_new(nzeros_l))
allocate(rowIndex_new(nmax+1))
allocate(solution(nmax))
! allocate(iwk(nmax+1))
! allocate(indu(nmax))
! allocate(ia_nn(nRows+1))
! allocate(a_nn(nzeros_l))
! allocate(ja_nn(nzeros_l))
!----------------------------------------------------------------------------------
! Read the matrix of hb format
!
!---------------------------------------------------------------------------
if (type(1:1) .eq. 'r' .or. type(1:1).eq. 'R') then
call dreadhb( fname, nRows, nCols,nzeros_l,
$ rowIndex_new, columns_new, values_new)
else
write(*,*) 'wrong format, only support real matrix in HB format!'
stop
endif
write(*,*)'the value_new is'
do i=1,20
write(*,*) values_new(i)
enddo

write(*,*)'the columns_new is'
do i=1,20
write(*,*) columns_new(i)
enddo
write(*,*)'the rowIndex_new is'
do i=1,10
write(*,*) rowIndex_new(i)
enddo
!----------------------------------------------------------------------------------
! Transpose the matrix from csc to csr
!--------------------------------------------------------------------------
! call dcsccsr(nRows, a_nn, ja_nn, ia_nn,
! $ values_new,columns_new, rowIndex_new)
call dcsccsr(nRows, values_new, columns_new, rowIndex_new,
$ values,columns, rowIndex)
! write(*,*) 'nice guy'
! if(type(2:2) .eq. 's' .or. type(2:2) .eq. 'S') then
! nd=0
! do i=1,nRows
! do j=rowIndex(i),rowIndex(i+1)-1
! if(columns(j).eq.i) nd=nd+1
! enddo
! enddo
! nNonZeros=2*nzeros_l-nd
! allocate(values(nNonZeros))
! allocate(columns(nNonZeros))
! write(*,*) nRows,nCols,nNonZeros
! write(*,*) 'Read hb file ok! hello'
! call ssrcsr(1,1,nRows,values_new,columns_new,rowIndex_new,
! & nNonZeros,values,columns,rowIndex,indu,iwk,err0)
! else
nNonZeros=nzeros_l
! allocate(values(nNonZeros))
! allocate(columns(nNonZeros))
write(*,*) nRows,nCols,nNonZeros
write(*,*) 'Read hb file ok!'
! rowIndex=rowIndex_new
! columns=columns_new
! values=values_new
! endif
! deallocate(rowIndex_new)
! deallocate(columns_new)
! deallocate(values_new)
! deallocate(iwk)
! deallocate(indu)
N=nRows
write(*,*)'the values_ are'
do i=1,20
write(*,*) values(i)
enddo
write(*,*) 'rowIndex is:'
do j=1,10
write(*,*) rowIndex(j)
enddo
write(*,*) 'columns is :'
do i=1,20
write(*,*) columns(i)
enddo
!---------------------------------------------------------------------------
! Initialize the right hand side through matrix-vector product
!---------------------------------------------------------------------------
do i=1,N
solution(i)=i
enddo
! PARAMETER(nRhs=1)
CALL MKL_DCSRSYMV('U', N, values, rowIndex,
& columns, solution, rhs)

C---------------------------------------------------------------------------
C Initialize the solver
C--------------------------------------------------------------------------
call system_clock(count1,count_rate,count_max)
error = dss_create( handle, MKL_DSS_DEFAULTS)
IF (error .NE. MKL_DSS_SUCCESS ) GOTO 999
C---------------------------------------------------------------------------
C Define the non-zero structure of the matrix
C---------------------------------------------------------------------------
! write(*,*) nRows,nCols
! write(*,*) 'rowIndex is:'
! write(*,*) rowIndex
! write(*,*) 'columns is:'
! write(*,*) columns
error = dss_define_structure( handle, MKL_DSS_SYMMETRIC,
& rowIndex, nRows, nCols, columns, nNonZeros )
IF (error .NE. MKL_DSS_SUCCESS ) GOTO 999
write(*,*)'good'
C---------------------------------------------------------------------------
C Reorder the matrix
C---------------------------------------------------------------------------
error = dss_reorder(handle, MKL_DSS_DEFAULTS,0)
write(*,*)'reorder god'
IF (error .NE. MKL_DSS_SUCCESS ) GOTO 999
write(*,*)'error god'
C---------------------------------------------------------------------------
C Factor the matrix
C---------------------------------------------------------------------------
write(*,*)'right'
error = dss_factor_real( handle, MKL_DSS_DEFAULTS, values)
IF (error .NE. MKL_DSS_SUCCESS ) GOTO 999
C---------------------------------------------------------------------------
C Get the solution vector
C---------------------------------------------------------------------------
write(*,*)'haha'
error = dss_solve_real( handle, MKL_DSS_DEFAULTS,
& rhs, nRhs, solution)
IF (error .NE. MKL_DSS_SUCCESS ) GOTO 999
C---------------------------------------------------------------------------
C Print Determinant of the matrix (no statistics for a diagonal matrix)
C---------------------------------------------------------------------------
write(*,*) 'ho!'
IF( nRows .LT. nNonZeros ) THEN
statIn = 'determinant'
call mkl_cvt_to_null_terminated_str(buff,bufLen,statIn)
error = dss_statistics(handle, MKL_DSS_DEFAULTS,
& buff,statOut)
WRITE(*,"(' pow of determinant is ', 5(F10.3))") statOut(1)
WRITE(*,"(' base of determinant is ', 5(F10.3))") statOut(2)
WRITE(*,"(' Determinant is ', 5(F10.3))")(10**statOut(1))*
& statOut(2)
END IF
!---------------------------------------------------------------------------
! Reverse Communication ends here
! Get the current iteration number
!---------------------------------------------------------------------------
call system_clock(count2,count_rate,count_max)
if(count2>count1) then
t=(count2-count1)/float(count_rate)
else
t=(count_max-count1+count2)/float(count_rate)
endif
write(*,105) t
105 format('the time :',E21.14)
C---------------------------------------------------------------------------
C Deallocate solver storage
C---------------------------------------------------------------------------
error = dss_delete( handle, MKL_DSS_DEFAULTS )
IF (error .NE. MKL_DSS_SUCCESS ) GOTO 999
C---------------------------------------------------------------------------
C Print solution vector
C---------------------------------------------------------------------------
OPEN (10,file='bcsstk17.txt')
WRITE(10,900) (solution(i), i = 1, nRows)
900 FORMAT(' Solution Array: ',5(F10.3))
GOTO 1000
999 WRITE(*,*) "Solver returned error code ", error
1000 END
...全文
172 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wenhuaguan30 2009-09-29
  • 打赏
  • 举报
回复
恩,问题已经解决,是对称矩阵的上三角和下三角的问题,Mkl只接受上三角的csr格式
我输入的是下三角的。
intel_cyu 2009-09-11
  • 打赏
  • 举报
回复
一个可能的原因是输入数据的问题:
dcsccsr是否是自己实现的函数,确认一下,是否有问题? DSS 求解中的CSR格式是与一般的CSR略有变化。参考MKL手册的“Sparse Matrix Storage Formats”中的说明。

567

社区成员

发帖
与我相关
我的任务
社区描述
英特尔® 边缘计算,聚焦于边缘计算、AI、IoT等领域,为开发者提供丰富的开发资源、创新技术、解决方案与行业活动。
社区管理员
  • 英特尔技术社区
  • shere_lin
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧