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

MKL SPBLAS Question : sparse matrix-vector multiplication

pavanm
Beginner
578 Views
Hi all

I have this simple test program (which I wrote after getting frustrated with a bigger program!!).

Description of the program:
-- The program computes the product of a sparse matrix with a vector. The sparse matrix i gave is filled with Ones, and the vector is also filled with Ones.

-- The difference between the last two mkl_dcoomv calls in the code is the order in which row indices and col indices are sent.

-- I created the matrix such that it is symmetric, so that rowindices and column indices can be interchanged without any problem.


Question: Why do I get different results for both the calls when the matrix is symmetric and interchanging rows and cols should not matter?

For the second call to the coomv, if I give the transpose 'T", it gives the right result (which is understandable of course!).

Does it have to do with the index sorting in coordinate reprsentation? If so, i did not find it anywhere explicitly mentioned in the documentation!

[cpp]real(8), dimension(100) :: vA;
integer, dimension(100) :: iA;
integer, dimension(100) :: jA;
real(8),dimension(10) :: ones;
real(8),dimension(10) :: sumA;

integer :: i,j;

k = 1;
do i=1,10
do j=1,10
iA(k) = i;
jA(k) = j;
vA(k) = 1;
k = k + 1;
enddo
enddo

sumA = 0;
ones = 1;
call mkl_dcoogemv('T',10,vA,iA,jA,100,ones,sumA);
print*, sumA;

sumA = 0;
call mkl_dcoogemv('T',10,vA,jA,iA,100,ones,sumA);
print*, sumA;

end
[/cpp]



Both of the outputs are incorrect (I was wrong before, Sorry about it!)

5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000


10.0000000000000 10.0000000000000 10.0000000000000 10.0000000000000 10.0000000000000 0.000000000000000E+000 0.000000000000000E+000 0.000000000000000E+000 0.000000000000000E+000 0.000000000000000E+000


Here is the compilation command I used:

ifort -i8 -debug all -I /opt/intel/mkl/10.1.1.019/include/ test.f90 -L /opt/intel/mkl/10.1.1.019/lib/em64t/ -lmkl -lm -openmp


I would greatly appreciate any help.
Thank you.

Regards
Pavan
0 Kudos
1 Solution
Gennady_F_Intel
Moderator
578 Views

Pavan,
The cause of this problem dealt with interface library you are using:
for this case please use ilp64 library (libmkl_intel_ilp64.a ) instead of lp64 one.

ifort-w-i8-I/opt/intel/mkl/10.1.1.019/includetest.f90-L/opt/intel/mkl/10.1.1.019/lib/em64t/opt/intel/mkl/10.1.1.019/lib/em64t/libmkl_intel_ilp64.a.........

or use building line without -i8 option
in this case you can use libmkl_intel_lp64.a

--Gennady

View solution in original post

0 Kudos
5 Replies
Gennady_F_Intel
Moderator
578 Views

Hi Pavan,
You wrote: "The output of the above program is as follows: (first one is correct, while the second one is absolute junk!!)" 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000

but, at the first glance, for your example ( when all matrix's and input vector's elements filled by Ones ) it seems that, the output vector must be == 10.0 but no 5.0.

can you please check the problem with the follow linking:

ifort -w -i8 -I${MKL_INCL} test.f ${MKL_LIB}/libmkl_intel_lp64.a
-Wl,--start-group
${MKL_LIB}/libmkl_intel_threa.a ${MKL_LIB}/libmkl_core.a
-Wl,--end-group
-liomp5 -lpthread -lm -o test.out
where
MKL_INCL=/opt/intel/mkl/10.XXX/include
MKL_LIB=/opt/intel/mkl/10.XXX/lib/em64t
--Gennady

0 Kudos
pavanm
Beginner
578 Views
Hi Gennady,

Thanks for the response. Your comment on the solution being all 10s and not 5s is right. I was carried away by the fact that all the values are equal in solution 1. I corrected the original question also in my first post.

I was working on a program since last 15 days and could not figure this out (the program should have been done in a day !!)

So, basically - both the solutions are incorrect. I did compile the code with the command you gave:
[shell]ifort -w -i8 -I/opt/intel/mkl/10.1.1.019/include test.f90  -L/opt/intel/mkl/10.1.1.019/lib/em64t  /opt/intel/mkl/10.1.1.019/lib/em64t/libmkl_intel_lp64.a  -Wl,--start-group  /opt/intel/mkl/10.1.1.019/lib/em64t/libmkl_intel_thread.a /opt/intel/mkl/10.1.1.019/lib/em64t/libmkl_core.a  -Wl,--end-group -liomp5 -lpthread -lm -o test.out [/shell]

There is no difference in the solution. I still get the same solution.

[plain]   5.00000000000000        5.00000000000000        5.00000000000000     
   5.00000000000000        5.00000000000000        5.00000000000000     
   5.00000000000000        5.00000000000000        5.00000000000000     
   5.00000000000000     
   10.0000000000000        10.0000000000000        10.0000000000000     
   10.0000000000000        10.0000000000000       0.000000000000000E+000
  0.000000000000000E+000  0.000000000000000E+000  0.000000000000000E+000
  0.000000000000000E+000
[/plain]

Please let me know what can be done. The example I have provided is too small to have any major bugs in it, but who knows! :)

Thank you once again,

Pavan.

P.S. I am not able to reply to your post (forums are giving Page not found error), so I am replying to my own email. I am not sure if you will recieve this.
0 Kudos
Gennady_F_Intel
Moderator
579 Views

Pavan,
The cause of this problem dealt with interface library you are using:
for this case please use ilp64 library (libmkl_intel_ilp64.a ) instead of lp64 one.

ifort-w-i8-I/opt/intel/mkl/10.1.1.019/includetest.f90-L/opt/intel/mkl/10.1.1.019/lib/em64t/opt/intel/mkl/10.1.1.019/lib/em64t/libmkl_intel_ilp64.a.........

or use building line without -i8 option
in this case you can use libmkl_intel_lp64.a

--Gennady

0 Kudos
pavanm
Beginner
578 Views
Hi Gennady,

Thank you very much for the response. It worked. Its not really essential, only if you have time, can you please let me know what the reason for this behaviour is?

Thank you once again.

Bye
Pavan


0 Kudos
Anand_M_Intel
Employee
578 Views

Hi Pavan,
You wrote: "The output of the above program is as follows: (first one is correct, while the second one is absolute junk!!)" 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000 5.00000000000000

but, at the first glance, for your example ( when all matrix's and input vector's elements filled by Ones ) it seems that, the output vector must be == 10.0 but no 5.0.

can you please check the problem with the follow linking:

ifort -w -i8 -I${MKL_INCL} test.f ${MKL_LIB}/libmkl_intel_lp64.a
-Wl,--start-group
${MKL_LIB}/libmkl_intel_threa.a ${MKL_LIB}/libmkl_core.a
-Wl,--end-group
-liomp5 -lpthread -lm -o test.out
where
MKL_INCL=/opt/intel/mkl/10.XXX/include
MKL_LIB=/opt/intel/mkl/10.XXX/lib/em64t
--Gennady


0 Kudos
Reply