diff --git a/src/interface.jl b/src/interface.jl index 0d183c9c..80c8d34f 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -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 """ diff --git a/test/runtests.jl b/test/runtests.jl index ec679d4e..9801000d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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 diff --git a/test/static_compilation.jl b/test/static_compilation.jl new file mode 100644 index 00000000..dbc6005b --- /dev/null +++ b/test/static_compilation.jl @@ -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