Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix array display #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#using CSC format for interop with Julia's native sparse functionality

import Base: length, size, ndims, eltype, similar, pointer, stride,
copy, convert, reinterpret, show, summary, copy!, get!, fill!, issym,
copy, convert, reinterpret, show, showarray, summary, copy!, get!, fill!, issym,
ishermitian, isupper, islower
import Base.LinAlg: BlasFloat, Hermitian, HermOrSym
import CUDArt: device, to_host, free
Expand Down Expand Up @@ -234,3 +234,11 @@ copy(Vec::CudaSparseVector; stream=null_stream) = copy!(similar(Vec),Vec;stream=
copy(Mat::CudaSparseMatrixCSC; stream=null_stream) = copy!(similar(Mat),Mat;stream=null_stream)
copy(Mat::CudaSparseMatrixCSR; stream=null_stream) = copy!(similar(Mat),Mat;stream=null_stream)
copy(Mat::CudaSparseMatrixBSR; stream=null_stream) = copy!(similar(Mat),Mat;stream=null_stream)

function showarray(io::IO, S::CudaSparseMatrix;
header::Bool=true, limit::Bool=Base._limit_output,rows = Base.tty_size()[1], repr=false)
to_host(S)

s = to_host(S)
showarray(io,s;header=header,limit=limit,rows=rows,repr=repr)
end
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ d_y = CUSPARSE.switch2bsr(d_y,convert(Cint,blockdim))
d_x = CUSPARSE.switch2bsr(d_x,convert(Cint,blockdim))
@test_throws ArgumentError copy!(d_y,d_x)

# issue #21
A = speye(20)
d_A = CudaSparseMatrixCSR(A)
@test sprint(show,d_A) == "\n\t[1 , 1] = 1.0\n\t[2 , 2] = 1.0\n\t[3 , 3] = 1.0\n\t[4 , 4] = 1.0\n\t[5 , 5] = 1.0\n\t[6 , 6] = 1.0\n\t[7 , 7] = 1.0\n\t[8 , 8] = 1.0\n\t[9 , 9] = 1.0\n\t[10, 10] = 1.0\n\t[11, 11] = 1.0\n\t[12, 12] = 1.0\n\t[13, 13] = 1.0\n\t[14, 14] = 1.0\n\t[15, 15] = 1.0\n\t[16, 16] = 1.0\n\t[17, 17] = 1.0\n\t[18, 18] = 1.0\n\t[19, 19] = 1.0\n\t[20, 20] = 1.0"


# misc char tests

@test_throws ArgumentError CUSPARSE.cusparseop('Z')
Expand Down