From 7f6e9d70788c7eeab310353cabedb7ca5f9f3a3f Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Sat, 3 May 2025 12:14:34 +0200 Subject: [PATCH 1/3] Add precompilation workload --- Project.toml | 4 +++- src/SparseMatrixColorings.jl | 4 ++++ src/precompile.jl | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/precompile.jl diff --git a/Project.toml b/Project.toml index 2e71e968..33e2f6d9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,12 +1,13 @@ name = "SparseMatrixColorings" uuid = "0a514795-09f3-496d-8182-132a7b665d35" authors = ["Guillaume Dalle", "Alexis Montoison"] -version = "0.4.19" +version = "0.4.20" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" @@ -24,6 +25,7 @@ CliqueTrees = "1" Colors = "0.12.11, 0.13" DocStringExtensions = "0.8,0.9" LinearAlgebra = "<0.0.1, 1" +PrecompileTools = "1.2.1" Random = "<0.0.1, 1" SparseArrays = "<0.0.1, 1" julia = "1.10" diff --git a/src/SparseMatrixColorings.jl b/src/SparseMatrixColorings.jl index 45cb7663..7c25bac4 100644 --- a/src/SparseMatrixColorings.jl +++ b/src/SparseMatrixColorings.jl @@ -27,6 +27,7 @@ using LinearAlgebra: ldiv!, parent, transpose +using PrecompileTools: @compile_workload using Random: Random, AbstractRNG, default_rng, randperm using SparseArrays: SparseArrays, @@ -39,6 +40,7 @@ using SparseArrays: nzrange, rowvals, sparse, + sprand, spzeros include("graph.jl") @@ -55,6 +57,8 @@ include("check.jl") include("examples.jl") include("show_colors.jl") +include("precompile.jl") + export NaturalOrder, RandomOrder, LargestFirst export DynamicDegreeBasedOrder, SmallestLast, IncidenceDegree, DynamicLargestFirst export PerfectEliminationOrder diff --git a/src/precompile.jl b/src/precompile.jl new file mode 100644 index 00000000..7f0e611e --- /dev/null +++ b/src/precompile.jl @@ -0,0 +1,20 @@ +for (structure, partition, decompression) in [ + (:nonsymmetric, :column, :direct), + (:nonsymmetric, :row, :direct), + (:symmetric, :column, :direct), + (:symmetric, :column, :substitution), + (:nonsymmetric, :bidirectional, :direct), + (:nonsymmetric, :bidirectional, :substitution), +] + A = sparse(Symmetric(sprand(Bool, 100, 100, 0.1))) + problem = ColoringProblem(; structure, partition) + algo = GreedyColoringAlgorithm(; decompression, postprocessing=true) + result = coloring(A, problem, algo) + if partition == :bidirectional + Br, Bc = compress(A, result) + decompress(Br, Bc, result) + else + B = compress(A, result) + decompress(B, result) + end +end From 52e1d83fe53dc2c936f5f7e53879531861e49a63 Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Sat, 3 May 2025 19:43:23 +0200 Subject: [PATCH 2/3] Simplest matrix --- src/precompile.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/precompile.jl b/src/precompile.jl index 7f0e611e..ea851689 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -6,7 +6,7 @@ for (structure, partition, decompression) in [ (:nonsymmetric, :bidirectional, :direct), (:nonsymmetric, :bidirectional, :substitution), ] - A = sparse(Symmetric(sprand(Bool, 100, 100, 0.1))) + A = sparse([1 0; 0 1]) problem = ColoringProblem(; structure, partition) algo = GreedyColoringAlgorithm(; decompression, postprocessing=true) result = coloring(A, problem, algo) From 1675a699dce0b641c25cf9ff8f475c5d4a9a8798 Mon Sep 17 00:00:00 2001 From: Guillaume Dalle <22795598+gdalle@users.noreply.github.com> Date: Sat, 3 May 2025 19:43:50 +0200 Subject: [PATCH 3/3] Bool --- src/precompile.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/precompile.jl b/src/precompile.jl index ea851689..29eebaca 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -6,7 +6,7 @@ for (structure, partition, decompression) in [ (:nonsymmetric, :bidirectional, :direct), (:nonsymmetric, :bidirectional, :substitution), ] - A = sparse([1 0; 0 1]) + A = sparse(Bool[1 0; 0 1]) problem = ColoringProblem(; structure, partition) algo = GreedyColoringAlgorithm(; decompression, postprocessing=true) result = coloring(A, problem, algo)