Skip to content

Weird transpose timing #40

@PetrKryslUCSD

Description

@PetrKryslUCSD

Please visit https://discourse.julialang.org/t/what-is-the-fastest-way-of-realizing-transpose-of-a-csr-or-csc-matrix/136241/27?u=petrkryslucsd

The timing of the transpose is suspect. Is that real? Notice the huge allocation. And, of course, the time is way off.


pkrysl@samadira sparse_transpose_tests.jl % julia --project t.jl
[ Info: Matrix M = 20133 by N = 20133, sparsity = 0.0004966969651815428, nnz = 201916
(typeof(Ac), typeof(Ar)) = (SparseMatrixCSC{Float64, Int64}, SparseMatrixCSR{1, Float64, Int64})
(typeof(Gc), typeof(Gr)) = (GBMatrix{Float64, Float64}, GBMatrix{Float64, Float64})
norm(gbtranspose(Gc) - copy(transpose(Ac))) = 0.0
norm(gbtranspose(Gr) - copy(transpose(Ar))) = 0.0
[ Info: Benchmarking copy+transpose CSC
  624.167 μs (12 allocations: 3.24 MiB)
[ Info: Benchmarking copy+transpose CSR
  1.900 s (3 allocations: 3.02 GiB)      # <---------------- !?
[ Info: Benchmarking gbtranspose CSC
  758.167 μs (23 allocations: 3.70 MiB)
[ Info: Benchmarking gbtranspose CSR
  1.072 s (14 allocations: 3.02 GiB)
[ Info: Benchmarking csr_transpose
  684.417 μs (15 allocations: 3.54 MiB)
norm(csr_transpose(C) - copy(transpose(Ac))) = 0.0
[ Info: Benchmarking csr_transpose_2
  637.125 μs (9 allocations: 3.23 MiB)
norm(csr_transpose_2(C) - copy(transpose(Ac))) = 0.0

I believe that copy(Ar') results in a dense matrix here:

Ar = copy(sparsecsr(Ac))
copy(Ar')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions