baiyunping333 / cusp-library

Automatically exported from code.google.com/p/cusp-library
Apache License 2.0
0 stars 0 forks source link

sparse diagonal matrix-vector multiplication is inconsistent across host and device memory #108

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile and run the attached script
More details:
Raw values for the array2d are {1,2,3,0}, with diagonal_offsets={0,1}.  Sending 
these to a dia_matrix_view leads to consistent matrices (viewed in 
cusp::print(A) - lines 57,99), however during multiplication, host memory 
treats this matrix as {{1,2},{0,3}} (correct) and device memory treats this 
matrix as {{1,3},{0,2}}.   

What is the expected output? What do you see instead?

1. Output to matrix-vector multiplication in the host part leads to {5,6} 
(correct)
2. Output to matrix-vector multiplication in the host part leads to {7,4} 
(incorrect)

What version of the product are you using? On what operating system?
4.0 - latest release.  Operating system OSX 10.9

Please provide any additional information below.

Original issue reported on code.google.com by gjhersch...@gmail.com on 23 Jan 2014 at 6:37

Attachments:

GoogleCodeExporter commented 9 years ago
I have determined the solution to the bug, however do not know how to 
contribute to cusp.

In $[include-dir]/cusp/detail/device/spmv/dia.h, change

Line:92 "IndexType idx = row + pitch * base;" -> "IndexType idx = row * pitch + 
base;"
Line:104 "idx += pitch;" -> "idx++;"

Original comment by gjhersch...@gmail.com on 23 Jan 2014 at 8:40

GoogleCodeExporter commented 9 years ago
There is no bug - diagonal sparse matrices are documented as having their 
values stored in column-major ordering.  Attempting to enforce row major 
ordering was the source of the problem.

Original comment by gjhersch...@gmail.com on 19 Feb 2014 at 5:31