Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
- Conversion to sparse matrix: wrong behavior of mkl_zdnscsr

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Massimiliano_Culpo

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-23-2011
02:27 PM

58 Views

I am trying to convert a complex(8) dense matrix into csr sparse format using MKL specific routines. Anyhow, I encountered a problem I was able to isolate in the code attached below:

[fortran]program dns2csr complex(8), allocatable :: Aall(:,:) integer, allocatable :: ia (:) integer, allocatable :: ja (:) complex(8), allocatable :: zval(:) real(8), allocatable :: dval(:) ! Variables needed by MKL integer :: job(1:8) integer :: info integer, parameter :: nrow = 3 integer, parameter :: ncol = 3 ! Allocate workspace allocate(Aall(1:3,1:3)) allocate(ia (1:nrow+1)) ! Initialize dns matrix Aall = cmplx(0.0d0,0.0d0) Aall(1,1) = cmplx(1.0d0,0.0d0) Aall(3,1) = cmplx(5.0d0,0.0d0) Aall(2,2) = cmplx(4.0d0,0.0d0) Aall(3,2) = cmplx(0.0d0,4.0d0) Aall(1,3) = cmplx(3.0d0,0.0d0) ! Set job job(1) = 0 ! Convert from dense to CSR format job(2) = 1 ! One-based indexing for dense job(3) = 1 ! One-based indexing for CSR job(4) = 2 ! Pass the whole dense matrix to MKL routines ! Compute ia only job(5) = 0 ! Max number of nnz job(6) = 0 ! Construct ia only allocate(ja(1),zval(1),dval(1)) call mkl_zdnscsr(job,nrow,ncol,Aall,nrow,zval,ja,ia,info) print *,ia print *,info call mkl_ddnscsr(job,nrow,ncol,real(Aall),nrow,dval,ja,ia,info) print *,ia print *,info deallocate(ia,ja,dval,zval) deallocate(Aall) end program dns2csr[/fortran]I compile this program with the command:

[bash]ifort -O0 -warn all dns2csr.f90 -lmkl_intel -lmkl_sequential -lmkl_core[/bash]Then running a.out I get the following output:

[bash]$ ./a.out 1 1 1 1 0 1 3 4 5 3 [/bash]While the correct one should have been:

[bash]$ ./a.out 1 3 4 6 3 1 3 4 5 3 [/bash]It seems that conversion from dense format to csr format works properly only with real(8) type. I wonder if the routine mkl_zdnscsr is somehow buggy or if I am doing some trivial error I am not able to spot. Is anyone able to reproduce the same behavior?

M.

Link Copied

Accepted Solutions

Murat_G_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-24-2011
09:57 AM

58 Views

Thank you for reporting this issue. The subroutine works correctly if you set both imaginary and real parts of a complex number to non-zero. It seems like the component that checks whether an entry is nonzero or not is in error. We will fix this as soon as possible.

-- Efe

8 Replies

barragan_villanueva_

Valued Contributor I

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-24-2011
01:58 AM

58 Views

According to MKL Reference Manual

Convert a sparse matrix in dense representation to the CSR format and vice versa.

but

COMPLEX for mkl_cdnscsr

DOUBLE COMPLEX for mkl_zdnscsr

INTERFACE is as follows:

SUBROUTINE mkl_zdnscsr(job, m, n, adns, lda, acsr, ja, ia, info)

INTEGER job(8)

INTEGER m, n, lda, info

INTEGER ja(*), ia(m+1)

DOUBLE COMPLEX adns(*), acsr(*)

However, in your example complex(8) and real(8)are used for mkl_zdnscsr function.

Massimiliano_Culpo

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-24-2011
03:13 AM

58 Views

and many thanks for your reply!

Nonetheless I think you misunderstood my post a little. I used complex(8) (syntax equivalent to a complex*16 declaration, at least on my machine) in the calling mkl_zdnscsr, while real(8) (syntax equivalent to a real*8 declaration, at least on my machine) was used in the calling to mkl_ddnscsr.

My point was to say that the same piece of code works if I am using double precision matrix, while it is not if I am using double complex matrix. Of course when I work with complex(8)/real(8) I call the z/d version of mkl_Xdnscsr.

Any suggestion on what to do? Are you able to reproduce this problem?

Many thanks again,

Massimiliano

Gennady_F_Intel

Moderator

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-24-2011
09:27 AM

58 Views

yes, it looks like the bug. Please let us the time we will investigate and back to you shortly.

--Gennady

Murat_G_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-24-2011
09:57 AM

59 Views

Thank you for reporting this issue. The subroutine works correctly if you set both imaginary and real parts of a complex number to non-zero. It seems like the component that checks whether an entry is nonzero or not is in error. We will fix this as soon as possible.

-- Efe

Massimiliano_Culpo

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-24-2011
01:55 PM

58 Views

many thanks for the quick response! I'll look forward to the fixed version (and will use other means to convert the complex matrix in the meanwhile :-) )

Massimiliano

Gennady_F_Intel

Moderator

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-24-2011
11:54 PM

58 Views

HiMassimiliano, thanks for the problem you raised.This issue has been submitted to our internal development tracking database for further investigation, we will inform you once a new update becomes available.

Here is a bug tracking number for your reference: 200209064.

Gennady_F_Intel

Moderator

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-13-2011
02:12 AM

58 Views

could you please check how it works with the latest **10.3 update 4** which was released yesterday and let us know if you will see the same behavior?

--Gennady

Massimiliano_Culpo

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-13-2011
02:15 AM

58 Views

The output now is:

[bash]1 3 4 6 0 1 3 4 5 0 [/bash]which I think is fine. Many thanks for updating me on the issue!

Massimiliano

For more complete information about compiler optimizations, see our Optimization Notice.