Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
12 Views

can't figure out mkl_zcsrcoo

I have been able to use mkl_dscrcoo, but I can't figure out mkl_zcsrcoo.

        PROGRAM zcsrcoo_test
        IMPLICIT NONE
        include 'mkl_pardiso.f77'

   integer nx, ne
       parameter(nx=5, ne=3)
  complex*16 val(ne), a(ne)
      integer :: rows(ne), cols(ne), ia(nx+1), ja(ne)
      integer ierr
      rows = 1
      cols = [3,2,1]
 val = [(1,2),(3,4),(5,6)]
      
      call mkl_zcsrcoo((/2,1,1,0,size(a),0,0,0/), nx, a, ja, ia, 
     &    ne, val, rows, cols, ierr)

      STOP
      END

Here's what I get (from the visual studio Locals window).  The contents of ia and ja look good, but the A array looks all wrong!!

  IERR 0 INTEGER(4) 
-  A {...} COMPLEX(8) 
  A(1) (3.00000000000000,2.00000000000000) COMPLEX(8) 
  A(2) (1.00000000000000,4.00000000000000) COMPLEX(8) 
  A(3) (5.00000000000000,6.00000000000000) COMPLEX(8) 
-  JA {...} INTEGER(4) 
  JA(1) 1 INTEGER(4) 
  JA(2) 2 INTEGER(4) 
  JA(3) 3 INTEGER(4) 
-  COLS {...} INTEGER(4) 
  COLS(1) 3 INTEGER(4) 
  COLS(2) 2 INTEGER(4) 
  COLS(3) 1 INTEGER(4) 
-  ROWS {...} INTEGER(4) 
  ROWS(1) 1 INTEGER(4) 
  ROWS(2) 1 INTEGER(4) 
  ROWS(3) 1 INTEGER(4) 
-  IA {...} INTEGER(4) 
  IA(1) 1 INTEGER(4) 
  IA(2) 4 INTEGER(4) 
  IA(3) 4 INTEGER(4) 
  IA(4) 4 INTEGER(4) 
  IA(5) 4 INTEGER(4) 
  IA(6) 4 INTEGER(4) 
-  VAL {...} COMPLEX(8) 
  VAL(1) (1.00000000000000,2.00000000000000) COMPLEX(8) 
  VAL(2) (3.00000000000000,4.00000000000000) COMPLEX(8) 
  VAL(3) (5.00000000000000,6.00000000000000) COMPLEX(8)

 

0 Kudos
19 Replies
Highlighted
Beginner
12 Views

When I run the program using complex*8 and mkl_ccsrcoo, I get the correct result, but in double precision the MKL library seems to be getting confused about the precision.

My version of IVF is: Intel(R) Visual Fortran Composer XE 2013 Update 4 Integration for Microsoft Visual Studio* 2012, 13.0.3624.11.

I don't know how to check the MKL version.  When I try to use the Intel Software Manager from the Visual Studio Help menu, it tells me it can't connect to the update server.

0 Kudos
Highlighted
Black Belt
12 Views

I added the following WRITE statements after the MKL routine call to print out ia, ja and a, and I obtained correct results with IFort 11.1.070 (this came with a version of MKL that does not have mkl_zcsrcoo, so I altered the variables concerned to double-precision real), 14.0.4.237 and 16.0.0.110, all 32-bit.

You can do CALL mkl_get_version_string(buf) with buf of length >= 198, and then print buf .

Looking at variable values in the debugger can get tricky. You have to complete execution up to the point where the variables are expected to have been assigned meaningful values, and the debugger cannot correlate line numbers and instruction register values precisely if the code has been allowed to be optimized. WRITE statements do not have these issues.

0 Kudos
Highlighted
Beginner
12 Views

I added write statements, and got this:

       write(*,*) buf
       write(*,*) a
Intel(R) Math Kernel Library Version 11.0.4 Product Build 20130517 for 32-bit applications
 (3.00000000000000,2.00000000000000) (1.00000000000000,4.00000000000000)
 (5.00000000000000,6.00000000000000)

If this means there is a bug in the version I have, what do I do about it?  The Intel Software Manager doesn't work for me.

0 Kudos
Highlighted
Black Belt
12 Views

If you have a curent license, you can sign into registrationcenter.intel.com and download those products that are covered by your license, instead of using the Intel Software Manager.

I do have the still older Intel Fortran 11.1.070, but the MKL that accompanied it does not have mkl_zcsrcoo().

The matrix that you used is degenerate -- it is a 5 X 5 matrix with non-zero elements only in row-1, cols 1, 2 and 3. If you don't mind, please try this example with your compiler/MKL combination.

program xzcsr
use mkl_mod
implicit none
integer, parameter :: N=3, NZ=7
integer :: i,j,k, info
complex*16 acoo(NZ), acsr(NZ)
integer rind(NZ),cind(NZ),ir(N+1),jr(NZ),job(8)
intrinsic cmplx,iabs
character(len=200) :: buf
!
call mkl_get_version_string(buf)
write(*,*)buf

rind=[1,1,2,2,2,3,3]
cind=[1,2,1,2,3,2,3]
job=[2,1,1,0,7,0,0,0]
k=0
do i=1,3; do j=1,3
   if(iabs(i-j).le.1)then
      k=k+1
      acoo(k)=cmplx(i*1d1+j*1d0,-i*1d0-j*1d1)
   endif
end do; end do
call mkl_zcsrcoo(job,N, acsr,jr,ir, NZ, acoo,rind,cind,info)
write(*,*)'info = ',info
write(*,'(10I3)')ir
write(*,'(10I3)')jr
do k=1,NZ
   write(*,*)k,acsr(k)
end do
end

Note that the module mkl_mod is what I use to avoid placing INCLUDE 'mkl.fi' or INCLUDE 'mkl.f77' in my source codes and subjecting myself to long waits while the include file gets compiled. You can generate that module file by creating, say, file mkl_mod.f containing the following lines of fixed format code and compiling it once.

c
      module mkl_mod
      include 'mkl.fi'
      end module
c

 

0 Kudos
Highlighted
Beginner
12 Views

I ran your code, and got what I think is the right result.  I inserted a few extra write statements, and got the following:

 Intel(R) Math Kernel Library Version 11.0.4 Product Build 20130517 for 32-bit a
 pplications                                                                    
                                           
rind  1  1  2  2  2  3  3
cind  1  2  1  2  3  2  3
           1 (11.0000000000000,-11.0000000000000)
           2 (12.0000000000000,-21.0000000000000)
           3 (21.0000000000000,-12.0000000000000)
           4 (22.0000000000000,-22.0000000000000)
           5 (23.0000000000000,-32.0000000000000)
           6 (32.0000000000000,-23.0000000000000)
           7 (33.0000000000000,-33.0000000000000)
 info =            0
ir  1  3  6  8
jr  1  2  1  2  3  2  3
           1 (11.0000000000000,-11.0000000000000)
           2 (12.0000000000000,-21.0000000000000)
           3 (21.0000000000000,-12.0000000000000)
           4 (22.0000000000000,-22.0000000000000)
           5 (23.0000000000000,-32.0000000000000)
           6 (32.0000000000000,-23.0000000000000)
           7 (33.0000000000000,-33.0000000000000)

Here's what I get with the last two elements of cind reversed.  I think it's wrong.

 Intel(R) Math Kernel Library Version 11.0.4 Product Build 20130517 for 32-bit a
 pplications                                                                    
                                           
rind  1  1  2  2  2  3  3
cind  1  2  1  2  3  3  2
           1 (11.0000000000000,-11.0000000000000)
           2 (12.0000000000000,-21.0000000000000)
           3 (21.0000000000000,-12.0000000000000)
           4 (22.0000000000000,-22.0000000000000)
           5 (23.0000000000000,-32.0000000000000)
           6 (32.0000000000000,-23.0000000000000)
           7 (33.0000000000000,-33.0000000000000)
 info =            0
ir  1  3  6  8
jr  1  2  1  2  3  2  3
           1 (11.0000000000000,-11.0000000000000)
           2 (12.0000000000000,-21.0000000000000)
           3 (21.0000000000000,22.0000000000000)
           4 (-12.0000000000000,-22.0000000000000)
           5 (23.0000000000000,-32.0000000000000)
           6 (32.0000000000000,-23.0000000000000)
           7 (33.0000000000000,-33.0000000000000)

 

program xzcsr 
use mkl_mod 
implicit none 
integer, parameter :: N=3, NZ=7 
integer :: i,j,k, info 
complex*16 acoo(NZ), acsr(NZ) 
integer rind(NZ),cind(NZ),ir(N+1),jr(NZ),job(8) 
intrinsic cmplx,iabs 
character(len=200) :: buf 
! 
call mkl_get_version_string(buf) 
write(66,*)buf 
  
rind=[1,1,2,2,2,3,3] 
cind=[1,2,1,2,3,3,2] 
job=[2,1,1,0,7,0,0,0] 
k=0 
do i=1,3; do j=1,3 
   if(iabs(i-j).le.1)then 
      k=k+1 
      acoo(k)=cmplx(i*1d1+j*1d0,-i*1d0-j*1d1) 
   endif 
end do; end do 
write(66,'("rind",10I3)')rind 
write(66,'("cind",10I3)')cind
do k=1,NZ 
   write(66,*)k,acoo(k) 
end do 
call mkl_zcsrcoo(job,N, acsr,jr,ir, NZ, acoo,rind,cind,info) 
write(66,*)'info = ',info 
write(66,'("ir",10I3)')ir 
write(66,'("jr",10I3)')jr 
do k=1,NZ 
   write(66,*)k,acsr(k) 
end do 
end 

When I ran this program in a CMD window, the write(*,*) statements would write nothing.  So I put in a unit number of 6, still got nothing.  I put in a unit number of 66, and got a fort.66 file.  Why no output in the CMD window???

 

0 Kudos
Highlighted
Black Belt
12 Views

I think that your MKL installation is corrupted in one way or the other. Changing the order of the entries in the COO format should not affect the transformed CSR format data at all, since JOB(1)=2 has been set to request that the CSR entries be sorted by ascending column index within each row. Did you, by chance, install a different, more recent, version of MKL instead of the one that came with the Fortran/C compilers?

I changed '66' to '*' in your modified program from #6 and it printed the correct results on standard output,  and the numbers are the same as in the first set that you reported in #6.

0 Kudos
Highlighted
Beginner
12 Views

I wouldn't be surprised if it is corrupt.  But not that long ago Steve Lionel had me uninstall IVF and reinstall it from a fresh download from Intel.

I have IVF installed with visual studio 2012 on my host system, and with visual studio 2010 in a virtual machine.  With this little test program, output to the screen in a console window doesn't work with either one.  When I run it from the debugger, however, output does get written to the console window that is opened by the debugger.  Strange, but true.

I have asked my sponsor about getting my support contract with Intel renewed.  Hopefully I will hear back from him soon.

0 Kudos
Highlighted
Beginner
12 Views

Why does 11.0.4 have mkl_zcsrcoo and 11.1.070 does not?  Is it possible it was removed because it didn't work.

0 Kudos
Highlighted
Beginner
12 Views

Can I get the source code for mkl_ccsrcoo?  I'm hoping it will be simple to make a version for double precision that works.

0 Kudos
Highlighted
Black Belt
12 Views

I doubt that you can obtain MKL source code but, if your objective is only to convert from COO to CSR, that can be done without much trouble. Basically, this is what has to be done.

  1. Sort the (rind, cind) data with rind as the primary key and cind as the secondary key
  2. Merge adjacent entries in the sorted arrays that have the same row and column indices, adding up the acoo values concerned
  3. Form the row pointer array by locating changes in the row index values.

I have a generic subroutine that does this, and works with the four value types of interest (real and complex, single and double precision). It is not fully portable, since it uses the Fortran accessible qsort() function in the Intel Fortran runtime, but the code works with 32 and 64 bit Intel Fortran. I wrote this code a couple of years ago when the MKL version of that date did not provide the conversion subroutines that MKL does in current versions.

0 Kudos
Highlighted
Beginner
12 Views

Thanks for the offer, mecej4.  It only has to work with Intel Fortran.  So if you send it to me, I will certainly give it a try.

My first choice would be to simply get a version of MKL that works, but I am not the administrator of my license, so for the time being I'm stuck with what I've got.

0 Kudos
Highlighted
Black Belt
12 Views

Here are the files. Extract the zip, and compile coo2csr.f90. Then, in the place in your code where you wish to do a conversion, add USE COO2CSR.MOD and call coo2csr() to do the conversion. Include coo2csr.obj in the link step.  

Note that the converter does not use MKL and, to avoid any confusion with the MKL converters, which use a slightly different argument list and allow bidirectional conversions, I have used the name coo2csr. The compiler/linker will choose the appropriate one of the four routines based on the type of the arrays passed as the fifth and last arguments.

There is a short example main program to read a data file, convert and print the results.

0 Kudos
Highlighted
Employee
12 Views

Hi Brian 

It may be a unknow bug in MKL 11.0.4 (fortran composer 2013 update 4) .  

To simplify the issue,  is it possible for you to  install some latest version like 11.1 update 4 (from Intel fortran 2013 SP1 update 4) as mecj's version? 

As i have 2013 composer SP1 update 3 installed with MSVC 2010. The code work fine in this version. (attach the screen). 

Regarding the  console windows quit right away when click start the program in MSVS 2012 environment. It should be the design of MSVS 2012 and later. You may find workaround by internet search  or  just add pause at the end of the program ( i usually did like this).  (as the screenshot). 

Best Regards,
Ying mkl_zcsrcoo.png

 

 

0 Kudos
Highlighted
Employee
12 Views

Hi Brian, 

I just install the MKL 11.0.4 (fortran composer 2013 update 4). I can reproduce the issue as you reported.  this unknow issue seems be fixed in latest version.  So please upgrade  the composer version.

or you can get free-community MKL (2016 version)  from http://software.intel.com/sites/campaigns/nest/

Best Regards,

Ying 

0 Kudos
Highlighted
Beginner
12 Views

Ying,

Thank you very much for the replies.  I am downloading the community MKL library now.  However, the download is over 500 megabytes.  That is so big I wonder if I'm downloading the correct package???

I am confused about what version of Intel Fortran I have installed. 

The Help About box in Visual Studio says: Intel(R) Visual Fortran Composer XE 2013 Update 4 Integration for Microsoft Visual Studio* 2012, 13.0.3624.11

When compiling code, the output window says: Compiling with Intel(R) Visual Fortran Compiler XE 13.1.2.190

The MKL library that I am downloading seems to be 11.3.0.110.  Can you please confirm that this is the correct download for the version of Intel Fortran that I have.

It turns out the issue with no printed text in a CMD prompt window was a compiler setting.  I was using "Multithreaded DLL".  So the program would run fine and print to the screen when running in the VS debugger, but when running from the command line in a CMD window, nothing would happen.  This was because the mkl DLL file was missing.  I found this out by double clicking the .exe file in Windows Explorer, which displays a message that the mkl sequential library was missing.  No such message was displayed when running in the CMD window.  Anyhow, after changing the compiler Runtime Library option to "Multithreaded", I now get the printed output in the CMD window.

 

0 Kudos
Highlighted
Beginner
12 Views

mecej4 - I have downloaded your file coo2csr.zip.  Thank you very much.  I am studying it to see how to package 4 routines for the 4 different data types.  I will use your code if the MKL community library update thing doesn't work out.

Elsewhere, I'm switching to MKL pardiso in several places in my project.  In one place it runs in less than half the time of umfpack for a rather large model. :)

0 Kudos
Highlighted
Black Belt
12 Views

Brian Murphy wrote:

I am studying it to see how to package 4 routines for the 4 different data types.

One of the regular posters in this forum, "Repeat Offender", has posted source codes several times illustrating how algorithms can be applied to a variety of data types without having to rewrite the entire code for each combination of data types.

The idea is to put the algorithm code into an include file, and express the algorithm in terms of a type (or types, if needed) that is not declared in the include file. Then, you write the main source code, which is simply several versions of a few lines of code, each of which declares types and variables, followed by an INCLUDE statement for the include file written earlier.

0 Kudos
Highlighted
Beginner
12 Views

mecej4 - The more examples, the better.  I am (very) slowly learning the capabilities of "new" fortran.  It's come a long way since the days of paper tape and punch cards.

I have a good friend that recently retired from IBM after a long career.  He worked in high performance computing (among other things).  He says fortran is where the real action is.

0 Kudos
Highlighted
Black Belt
12 Views

Brian Murphy wrote:

Why does 11.0.4 have mkl_zcsrcoo and 11.1.070 does not?  Is it possible it was removed because it didn't work.

I happened to look again at these numbers after several days, and I now see why they could cause confusion. The 11.0.4 is the version number of MKL that you have, but 11.1.070 is the older IFort compiler version that I tested. The latter has a release date of 2011, and the version of MKL included with it was 10.2. Sorry for adding to the confusion!

0 Kudos