Skip to content

Bugged Sparse Matrix-Dense matrix multiplication, where dense matrix is transposed #77

@irhum

Description

@irhum

Describe the bug
Given A and B are two matrices, where A is of type CuSparseMatrixCSC and B is a regular CuArray (for simplicity assume both are square)

A * B works
transpose(A) * B works
A * transpose(B) does not work
transpose(A) * transpose(B) does not work

The implementations of mul! are there on line 20 and line 22 of CuArrays/src/sparse/interfaces.jl, but instead of them being called properly, both of the failing multiplications throw a scalar getindex is disallowed, suggesting it may be defaulting to a generic method?

To Reproduce
The Minimal Working Example (MWE) for this bug:

using CuArrays
using SparseArrays
using LinearAlgebra

CuArrays.allowscalar(false)

randsparse_cpu = SparseMatrixCSC{Float32, Int32}(sprand(3000, 3000, 0.0008))
sparsecscmatrix = CUSPARSE.CuSparseMatrixCSC(randsparse)

densematrix = cu(rand(Float32, 3000, 3000))

sparsecscmatrix * densematrix
transpose(sparsecscmatrix) * densematrix
sparsecscmatrix * transpose(densematrix) # throws scalar getindex is disallowed, should throw different error
transpose(sparsecscmatrix) * transpose(densematrix) # throws scalar getindex is disallowed, should throw no error

Expected behavior
three of the multiplications should complete correctly, while sparsecscmatrix * transpose(densematrix) should throw a CUSPARSE error (CUSPARSE does not support 'N', 'T' multiplications for CSC matrices)

Build log

# post the output of Pkg.build()
# make sure the error still reproduces after that.
   Building TimeZones → `~/.julia/packages/TimeZones/OjMoF/deps/build.log`
   Building HDF5 ─────→ `~/.julia/packages/HDF5/pAi1D/deps/build.log`
   Building CodecZlib → `~/.julia/packages/CodecZlib/5t9zO/deps/build.log`
   Building NNlib ────→ `~/.julia/packages/NNlib/FAI3o/deps/build.log`
   Building Conda ────→ `~/.julia/packages/Conda/3rPhK/deps/build.log`
   Building PyCall ───→ `~/.julia/packages/PyCall/zqDXB/deps/build.log`
   Building WebIO ────→ `~/.julia/packages/WebIO/nTMDV/deps/build.log`

error still reproduces

Environment details (please complete this section)
Details on Julia:

# please post the output of:
versioninfo()
Julia Version 1.4.1
Commit 381693d3df* (2020-04-14 17:20 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, haswell)
Environment:
  JULIA_NUM_THREADS = 4

Julia packages:

  • CuArrays.jl:
  • CUDAnative.jl:
  • SparseArrays
  • LinearAlgebra

CUDA: toolkit and driver version
10.2, 440.64

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcuda arrayStuff about CuArray.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions