Skip to content
Open
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
8 changes: 5 additions & 3 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,12 @@ function coloring(
A::AbstractMatrix,
problem::ColoringProblem,
algo::GreedyColoringAlgorithm;
decompression_eltype::Type{R}=Float64,
decompression_eltype::Type=Float64,
symmetric_pattern::Bool=false,
) where {R}
return _coloring(WithResult(), A, problem, algo, R, symmetric_pattern)
)
return _coloring(
WithResult(), A, problem, algo, decompression_eltype, symmetric_pattern
)
end

"""
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ include("utils.jl")
include("type_stability.jl")
end
end
@testset "Static compilation" begin
include("static_compilation.jl")
end
@testset "Allocations" begin
include("allocations.jl")
end
Expand Down
47 changes: 47 additions & 0 deletions test/static_compilation.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Guard for static compilation (`juliac --trim=safe`).
#
# The C and Fortran interfaces compile SMC.jl into a standalone shared library.
# The trimming verifier rejects any call whose result type is not fully inferred,
# so `coloring` must return a concrete type.

using SparseArrays
using SparseMatrixColorings
using Test

const STATIC_COMBOS = [
(ColoringProblem{:nonsymmetric,:column}(), GreedyColoringAlgorithm{:direct}()),
(ColoringProblem{:nonsymmetric,:row}(), GreedyColoringAlgorithm{:direct}()),
(ColoringProblem{:symmetric,:column}(), GreedyColoringAlgorithm{:direct}()),
(ColoringProblem{:symmetric,:column}(), GreedyColoringAlgorithm{:substitution}()),
(ColoringProblem{:nonsymmetric,:bidirectional}(), GreedyColoringAlgorithm{:direct}()),
(
ColoringProblem{:nonsymmetric,:bidirectional}(),
GreedyColoringAlgorithm{:substitution}(),
),
]

# Symmetric, so that it is a valid input for every combination above.
const STATIC_MATRIX = sparse(
[1, 2, 1, 2, 3, 2, 3, 4, 3, 4], [1, 1, 2, 2, 2, 3, 3, 3, 4, 4], ones(10), 4, 4
)

@testset "coloring infers a concrete result type" begin
@testset "$(typeof(problem)) / $(typeof(algo))" for (problem, algo) in STATIC_COMBOS
for decompression_eltype in (Float32, Float64)
for symmetric_pattern in (false, true)
@test (@inferred(
(
(A, p, a, sp, R) ->
coloring(A, p, a; decompression_eltype=R, symmetric_pattern=sp)
)(
STATIC_MATRIX,
problem,
algo,
symmetric_pattern,
decompression_eltype,
)
)) isa AbstractColoringResult
end
end
end
end
Loading