Quantcast
Channel: Intel® Software - Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 3005

MKL help with mkl_sparse_s_create_coo and MKL_SPARSE_CONVERT_CSR

$
0
0

Hello,

I am trying to use mkl_spblas and I am having some strange issues. Firstly, here is the code I am trying to compile using mkl-16.2.181 and impi-intel-5.1.3-16.0.2.

 

MODULE test

contains

subroutine tester_sub(l,N,Pf)

use MKL_SPBLAS

include 'mkl_spblas.fi'

include 'mkl_sparse_handle.fi'

!declaring variables                                                              

integer, intent(in) :: l,N

integer, DIMENSION(1) :: seed = (/300/) 

real :: num                                                                                                                                                                                                                                  

real, dimension(4) :: sum1                                                                                                                                              

real, dimension(2) :: sum2

real :: hf,hc,U,Z

real, intent(out) :: pf 

integer :: i,nf,nc,N1

real, allocatable, dimension(:) :: cf_m,cfd,cf_p,cf,cc_m,ccd,cc_p,cc,RHS,ones_f,ones_c,uf,uc

integer, allocatable, dimension(:,:) :: coords_d, coords_m,coords_p

type (SPARSE_MATRIX_T) :: A0f,A1f,A0c,A1c,LHS,Identity_c,Identity_f,A1f_csr

integer :: stat 

real, allocatable,dimension(:) :: cf_full,cc_full 

type(MATRIX_DESCR) :: descr!SPARSE_MATRIX_TYPE_GENERAL  

nf = 2**(l+1)

!creating a ones array for f                                                                                                            

ALLOCATE(ones_f(nf-1))

ones_f = real(-1)

ALLOCATE(cf(nf),cf_m(nf-1),cfd(nf-1),cf_p(nf-1))

hf = real(1)/real(nf)

cf = real(1)

cf_m = hf**(-2)*cf(2:size(cf))

cfd = hf**(-2)*-cf(2:size(cf)) - hf**(-2)*cf(1:size(cf)-1)

cf_p = hf**(-2)*cf(1:size(cf)-1)

ALLOCATE(coords_d(nf-1,2))

ALLOCATE(coords_m(nf-1,2))

ALLOCATE(coords_p(nf-1,2))

!creating the coordinates of the vectors                                                                                                                                 

do i = 1,nf-1

   coords_d(i,:) = i

end do

!don't want last row of matrix                                        

do i = 1,nf-1

   coords_m(i,1) = i + 1     !row position    

   coords_m(i,2) = i         !column position                                                                                                                                                                                   end do

!don't want last row of matrix                                                                                                                                                                                                     do i = 1,nf-1

   coords_p(i,1) = i         !row position                                                                                                                                                                                            coords_p(i,2) = i + 1     !column position                                                                                                                                                                                 end do

allocate(cf_full(3*nf-3))

!holding all of the values for the sparse matrix           

cf_full = (/ cf_m,cfd,cf_p  /)

stat = mkl_sparse_s_create_coo(A0f,1,nf-1,nf-1,size(cf_full),(/ coords_m(1:nf-2,1),coords_d(:,1), &

     coords_p(1:nf-2,1) /),(/ coords_m(1:nf-2,2),coords_d(:,2),coords_p(1:nf-2,2) /),cf_full)

print *, stat                                                                                                                                                                                                                                     

print *, 'here 0'

stat = MKL_SPARSE_CONVERT_CSR(A0f,SPARSE_OPERATION_NON_TRANSPOSE,A0f)

print *, 'here 1'

end subroutine tester_sub

end MODULE test

 

I can compile the code so I believe that all of the libraries are linked correctly.

When I do print *, stat  after mkl_sparse_s_create_coo I get the value 3. I am unsure of what this value actually means. From https://software.intel.com/en-us/node/590112 it seems like mkl_sparse_s_create_coo is supposed to return a Character, but I can only use integer type for stat. 

Once I try to use  MKL_SPARSE_CONVERT_CSR the program either has a segmentation fault or it hangs. I believe this is because A0f is not created correctly. 

So, I guess my question is

1) What does stat = 3 mean?

2) If I am creating the sparse matrix A0f incorrectly, how do I create it correctly? 

 

 

Thread Topic: 

Question

Viewing all articles
Browse latest Browse all 3005

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>