Skip to content

Commit 655c211

Browse files
merging spaced-out-sparsity
2 parents bfd62df + 1d4cf3c commit 655c211

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

benchmarks/LinearSolve/MatrixDepot.jmd

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ allmatrices_md = listnames("*/*")
3232
@info "Total number of matrices: $(allmatrices_md.content[1].rows)"
3333
times = fill(NaN, length(allmatrices_md.content[1].rows), length(algs))
3434
percentage_sparsity = fill(NaN, length(allmatrices_md.content[1].rows))
35+
spaced_out_sparsity = fill(NaN, length(allmatrices_md.content[1].rows))
3536
matrix_size = fill(NaN, length(allmatrices_md.content[1].rows))
3637
bandedness = fill(NaN, length(allmatrices_md.content[1].rows))
3738
```
@@ -48,12 +49,37 @@ for z in 1:length(allmatrices_md.content[1].rows)
4849
A = mdopen(currMTX).A
4950
A = convert(SparseMatrixCSC, A)
5051
n = size(A, 1)
51-
matrix_size[z] = n
52-
percentage_sparsity[z] = length(nonzeros(A)) / n^2
53-
@info "$n × $n"
52+
5453

55-
n > 500 && error("Skipping too large matrices")
54+
mtx_copy = copy(A)
5655

56+
@info "$n × $n"
57+
n > 100 && error("Skipping too large matrices")
58+
59+
60+
rows, cols = size(mtx_copy)
61+
new_rows = div(rows, 2)
62+
new_cols = div(cols, 2)
63+
condensed = zeros(Int, new_rows, new_cols)
64+
65+
while size(mtx_copy, 1) > 32 || size(mtx_copy, 2) > 32
66+
67+
rows, cols = size(mtx_copy)
68+
new_rows = div(rows, 2)
69+
new_cols = div(cols, 2)
70+
condensed = sparse(zeros(Int, new_rows, new_cols))
71+
72+
for r in 1:2:rows-1
73+
for c in 1:2:cols-1
74+
block = mtx_copy[r:min(r+1, rows), c:min(c+1, cols)]
75+
condensed[div(r-1, 2) + 1, div(c-1, 2) + 1] = (length(nonzeros(block)) >= 2) ? 1 : 0
76+
end
77+
end
78+
79+
mtx_copy = condensed
80+
81+
end
82+
5783
b = rand(rng, n)
5884
u0 = rand(rng, n)
5985

@@ -103,6 +129,13 @@ for z in 1:length(allmatrices_md.content[1].rows)
103129
println(e)
104130
end
105131
end
132+
133+
percentage_sparsity = percentage_sparsity[.!isnan.(percentage_sparsity)]
134+
spaced_out_sparsity = spaced_out_sparsity[.!isnan.(spaced_out_sparsity)]
135+
spaced_out_sparsity = replace(spaced_out_sparsity, 0 => 1e-10)
136+
matrix_size = matrix_size[.!isnan.(matrix_size)]
137+
nanrows = any(isnan, times; dims=2)
138+
times = times[.!vec(nanrows), :]
106139
```
107140

108141
```julia
@@ -151,6 +184,18 @@ p = scatter(matrix_size, times;
151184
legend = :outertopright)
152185
```
153186

187+
```julia
188+
p = scatter(spaced_out_sparsity, times;
189+
ylabel = "Time/s",
190+
yscale = :log10,
191+
xlabel = "Spaced Out Sparsity",
192+
xscale = :log10,
193+
label = algnames_transpose,
194+
title = "Factorization Time vs Spaced Out Sparsity",
195+
fmt = :png,
196+
legend = :outertopright)
197+
```
198+
154199

155200
## Appendix
156201

0 commit comments

Comments
 (0)