Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/decompression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ function decompress!(
R = eltype(A)
fill!(A, zero(R))

if eltype(buffer) == R
if eltype(buffer) == R || isempty(buffer)
buffer_right_type = buffer
else
buffer_right_type = similar(buffer, R)
Expand Down Expand Up @@ -599,7 +599,7 @@ function decompress!(
nzA = nonzeros(A)
uplo == :F && check_same_pattern(A, S)

if eltype(buffer) == R
if eltype(buffer) == R || isempty(buffer)
buffer_right_type = buffer
else
buffer_right_type = similar(buffer, R)
Expand Down
3 changes: 2 additions & 1 deletion src/result.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ function TreeSetColoringResult(

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

return TreeSetColoringResult(
A,
Expand Down
18 changes: 18 additions & 0 deletions test/allocations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,21 @@ end;
test_noallocs_structured_decompression(1000; structure, partition, decompression)
end
end;

@testset "Multi-precision acyclic decompression" begin
@testset "$format" for format in ("dense", "sparse")
A = [0 0 1; 0 1 0; 1 0 0]
if format == "sparse"
A = sparse(A)
end
problem = ColoringProblem(; structure=:symmetric, partition=:column)
result = coloring(A, problem, GreedyColoringAlgorithm{:substitution}())
@test isempty(result.buffer)
for T in (Float32, Float64)
C = rand(T) * T.(A)
B = compress(C, result)
bench_multiprecision = @be decompress!(C, B, result)
@test minimum(bench_multiprecision).allocs == 0
end
end
end