Skip to content
Merged
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
67 changes: 52 additions & 15 deletions benchmarks/LinearSolve/MatrixDepot.jmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ allmatrices_md = listnames("*/*")
@info "Total number of matrices: $(allmatrices_md.content[1].rows)"
times = fill(NaN, length(allmatrices_md.content[1].rows), length(algs))
percentage_sparsity = fill(NaN, length(allmatrices_md.content[1].rows))
spaced_out_sparsity = fill(NaN, length(allmatrices_md.content[1].rows))
matrix_size = fill(NaN, length(allmatrices_md.content[1].rows))
```

Expand All @@ -47,12 +48,37 @@ for z in 1:length(allmatrices_md.content[1].rows)
A = mdopen(currMTX).A
A = convert(SparseMatrixCSC, A)
n = size(A, 1)
matrix_size[z] = n
percentage_sparsity[z] = length(nonzeros(A)) / n^2
@info "$n × $n"


n > 500 && error("Skipping too large matrices")
mtx_copy = copy(A)

@info "$n × $n"
n > 100 && error("Skipping too large matrices")


rows, cols = size(mtx_copy)
new_rows = div(rows, 2)
new_cols = div(cols, 2)
condensed = zeros(Int, new_rows, new_cols)

while size(mtx_copy, 1) > 32 || size(mtx_copy, 2) > 32

rows, cols = size(mtx_copy)
new_rows = div(rows, 2)
new_cols = div(cols, 2)
condensed = sparse(zeros(Int, new_rows, new_cols))

for r in 1:2:rows-1
for c in 1:2:cols-1
block = mtx_copy[r:min(r+1, rows), c:min(c+1, cols)]
condensed[div(r-1, 2) + 1, div(c-1, 2) + 1] = (length(nonzeros(block)) >= 2) ? 1 : 0
end
end

mtx_copy = condensed

end

b = rand(rng, n)
u0 = rand(rng, n)

Expand All @@ -64,17 +90,9 @@ for z in 1:length(allmatrices_md.content[1].rows)
alias_b = true))
times[z,j] = bt
end

#=
p = bar(algnames, times[z, :];
ylabel = "Time/s",
yscale = :log10,
title = "Time on $(currMTX)",
fmt = :png,
legend = :outertopright)
display(p)
=#

matrix_size[z] = n
percentage_sparsity[z] = length(nonzeros(A)) / n^2
spaced_out_sparsity[z] = length(nonzeros(mtx_copy)) * percentage_sparsity[z]
println("successfully factorized $(currMTX)")
catch e
matrix = allmatrices_md.content[1].rows[z]
Expand All @@ -86,6 +104,13 @@ for z in 1:length(allmatrices_md.content[1].rows)
println(e)
end
end

percentage_sparsity = percentage_sparsity[.!isnan.(percentage_sparsity)]
spaced_out_sparsity = spaced_out_sparsity[.!isnan.(spaced_out_sparsity)]
spaced_out_sparsity = replace(spaced_out_sparsity, 0 => 1e-10)
matrix_size = matrix_size[.!isnan.(matrix_size)]
nanrows = any(isnan, times; dims=2)
times = times[.!vec(nanrows), :]
```

```julia
Expand Down Expand Up @@ -122,6 +147,18 @@ p = scatter(matrix_size, times;
legend = :outertopright)
```

```julia
p = scatter(spaced_out_sparsity, times;
ylabel = "Time/s",
yscale = :log10,
xlabel = "Spaced Out Sparsity",
xscale = :log10,
label = algnames_transpose,
title = "Factorization Time vs Spaced Out Sparsity",
fmt = :png,
legend = :outertopright)
```


## Appendix

Expand Down