Skip to content

Commit ff49d3f

Browse files
committed
Check if a buffer for the decompression of acyclic coloring is needed
1 parent b6dea77 commit ff49d3f

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/decompression.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ function decompress!(
575575
nzA = nonzeros(A)
576576
uplo == :F && check_same_pattern(A, S)
577577

578-
if eltype(buffer) == R
578+
if eltype(buffer) == R || isempty(buffer)
579579
buffer_right_type = buffer
580580
else
581581
buffer_right_type = similar(buffer, R)

src/result.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ function TreeSetColoringResult(
361361

362362
# buffer holds the sum of edge values for subtrees in a tree.
363363
# For each vertex i, buffer[i] is the sum of edge values in the subtree rooted at i.
364-
buffer = Vector{R}(undef, nvertices)
364+
# Note that we don't need a buffer is all trees are stars
365+
buffer = all(is_star) ? R[] : Vector{R}(undef, nvertices)
365366

366367
return TreeSetColoringResult(
367368
A,

test/allocations.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,16 @@ end;
132132
test_noallocs_structured_decompression(1000; structure, partition, decompression)
133133
end
134134
end;
135+
136+
@testset "Multi-precision acyclic decompression" begin
137+
A = sparse([0 0 1; 0 1 0; 1 0 0])
138+
problem = ColoringProblem(; structure=:symmetric, partition=:column)
139+
result = coloring(A, problem, GreedyColoringAlgorithm{:substitution}())
140+
@test isempty(result.buffer)
141+
for T in (Float32, Float64)
142+
C = rand(T) * T.(A)
143+
B = compress(C, result)
144+
bench_multiprecision = @be decompress!(C, B, result)
145+
@test minimum(bench_multiprecision).allocs == 0
146+
end
147+
end

0 commit comments

Comments
 (0)