From 5ac0b94e4fedd3c7adea9c6e1ef7f2f981dfd568 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Wed, 7 Sep 2022 12:04:41 +0400 Subject: [PATCH 1/7] precompile common function calls --- Project.toml | 2 ++ src/ApproxFunOrthogonalPolynomials.jl | 1 + src/precompile.jl | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 src/precompile.jl diff --git a/Project.toml b/Project.toml index 523c7b3..8e15fb2 100644 --- a/Project.toml +++ b/Project.toml @@ -14,6 +14,7 @@ FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" +SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" @@ -33,6 +34,7 @@ FillArrays = "0.11, 0.12, 0.13, 1" IntervalSets = "0.5, 0.6, 0.7" LazyArrays = "0.22, 1" Reexport = "0.2, 1" +SnoopPrecompile = "1" SpecialFunctions = "0.10, 1.0, 2" Static = "0.8" StaticArrays = "1" diff --git a/src/ApproxFunOrthogonalPolynomials.jl b/src/ApproxFunOrthogonalPolynomials.jl index 9cd5ed5..a7907b7 100644 --- a/src/ApproxFunOrthogonalPolynomials.jl +++ b/src/ApproxFunOrthogonalPolynomials.jl @@ -142,5 +142,6 @@ include("specialfunctions.jl") include("fastops.jl") include("symeigen.jl") include("show.jl") +include("precompile.jl") end diff --git a/src/precompile.jl b/src/precompile.jl new file mode 100644 index 0000000..8dd746b --- /dev/null +++ b/src/precompile.jl @@ -0,0 +1,20 @@ +using SnoopPrecompile + +@precompile_setup begin + splist = Any[Jacobi(1, 1), Chebyshev(), Ultraspherical(1)] + append!(splist, Any[Jacobi(1, 1, 0..1), Chebyshev(0..1), Ultraspherical(1, 0..1)]) + push!(splist, Chebyshev(Segment(1.0+im,2.0+2im))) + a = Fun(ChebyshevInterval{BigFloat}(),BigFloat[1,2,3]) + @precompile_all_calls begin + for S in splist + v = [0.0, 1.0] + f = Fun(S,v) + abs(DefiniteIntegral()*f - sum(f)) + norm(Derivative()*f-f') + norm(differentiate(integrate(f)) - f) + norm(differentiate(cumsum(f))-f) + norm(first(cumsum(f))) + end + Fun(sin,Interval(big"0.0", big"1.0") + end +end \ No newline at end of file From 15d8f144b4db9eff072bd77ea6b29a0162861827 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Wed, 7 Sep 2022 12:08:55 +0400 Subject: [PATCH 2/7] bugfix --- src/precompile.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/precompile.jl b/src/precompile.jl index 8dd746b..ff1a347 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -4,7 +4,6 @@ using SnoopPrecompile splist = Any[Jacobi(1, 1), Chebyshev(), Ultraspherical(1)] append!(splist, Any[Jacobi(1, 1, 0..1), Chebyshev(0..1), Ultraspherical(1, 0..1)]) push!(splist, Chebyshev(Segment(1.0+im,2.0+2im))) - a = Fun(ChebyshevInterval{BigFloat}(),BigFloat[1,2,3]) @precompile_all_calls begin for S in splist v = [0.0, 1.0] @@ -15,6 +14,6 @@ using SnoopPrecompile norm(differentiate(cumsum(f))-f) norm(first(cumsum(f))) end - Fun(sin,Interval(big"0.0", big"1.0") + roots(Fun(sin,Interval(big"0.0", big"1.0"))) end -end \ No newline at end of file +end From 07b8c9ac7290c4ae55d11cc54f009bb6ecfe725d Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Wed, 7 Sep 2022 23:18:12 +0400 Subject: [PATCH 3/7] precompile special functions --- src/precompile.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/precompile.jl b/src/precompile.jl index ff1a347..f282fdf 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -4,15 +4,21 @@ using SnoopPrecompile splist = Any[Jacobi(1, 1), Chebyshev(), Ultraspherical(1)] append!(splist, Any[Jacobi(1, 1, 0..1), Chebyshev(0..1), Ultraspherical(1, 0..1)]) push!(splist, Chebyshev(Segment(1.0+im,2.0+2im))) + # special functions + spfns = Any[sin, cos, exp] @precompile_all_calls begin for S in splist v = [0.0, 1.0] f = Fun(S,v) + 1/(f^2+1) abs(DefiniteIntegral()*f - sum(f)) norm(Derivative()*f-f') norm(differentiate(integrate(f)) - f) norm(differentiate(cumsum(f))-f) norm(first(cumsum(f))) + for spfn in spfns + spfn(f) + end end roots(Fun(sin,Interval(big"0.0", big"1.0"))) end From f4bc03e60a3e9ad4eb4b4ace9f6d4e88d6fbc7ac Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Wed, 19 Oct 2022 21:48:32 +0400 Subject: [PATCH 4/7] rearrange precompile statements --- src/precompile.jl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/precompile.jl b/src/precompile.jl index f282fdf..0bd0ed6 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -5,16 +5,14 @@ using SnoopPrecompile append!(splist, Any[Jacobi(1, 1, 0..1), Chebyshev(0..1), Ultraspherical(1, 0..1)]) push!(splist, Chebyshev(Segment(1.0+im,2.0+2im))) # special functions - spfns = Any[sin, cos, exp] + spfns = (sin, cos, exp) + v = ones(2) @precompile_all_calls begin for S in splist - v = [0.0, 1.0] f = Fun(S,v) 1/(f^2+1) abs(DefiniteIntegral()*f - sum(f)) norm(Derivative()*f-f') - norm(differentiate(integrate(f)) - f) - norm(differentiate(cumsum(f))-f) norm(first(cumsum(f))) for spfn in spfns spfn(f) From 0b7afe8f5eecf441afa1f27a8f5c2ca7202b45b7 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Thu, 20 Oct 2022 19:06:47 +0400 Subject: [PATCH 5/7] diff eq solving and transform --- src/precompile.jl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/precompile.jl b/src/precompile.jl index 0bd0ed6..c7a3e77 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -3,13 +3,17 @@ using SnoopPrecompile @precompile_setup begin splist = Any[Jacobi(1, 1), Chebyshev(), Ultraspherical(1)] append!(splist, Any[Jacobi(1, 1, 0..1), Chebyshev(0..1), Ultraspherical(1, 0..1)]) + spreal = copy(splist) push!(splist, Chebyshev(Segment(1.0+im,2.0+2im))) # special functions spfns = (sin, cos, exp) v = ones(2) + m = ones(2,2) + a = ones(2,2,2) @precompile_all_calls begin for S in splist f = Fun(S,v) + f(0.1) 1/(f^2+1) abs(DefiniteIntegral()*f - sum(f)) norm(Derivative()*f-f') @@ -18,6 +22,20 @@ using SnoopPrecompile spfn(f) end end + for S in spreal + transform(S, v) + itransform(S, v) + transform!(S, v) + itransform!(S, v) + transform(S * S, m) + itransform(S * S, m) + + [Derivative(S)^2 + 1; Dirichlet(S)] \ [1,0] + + f2 = Fun((x,y) -> x*y, S^2); f2(0.1, 0.1) + P = ProductFun((x,y) -> x*y, S^2); P(0.1, 0.1) + L = LowRankFun((x,y) -> x*y, S^2); L(0.1, 0.1) + end roots(Fun(sin,Interval(big"0.0", big"1.0"))) end end From 890ceeb9d72c88ca5b32f1d779498ab3eb757bd2 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Fri, 28 Apr 2023 17:13:41 +0530 Subject: [PATCH 6/7] use PrecompileTools instead --- Project.toml | 3 +-- src/precompile.jl | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 8e15fb2..084c859 100644 --- a/Project.toml +++ b/Project.toml @@ -13,8 +13,8 @@ FastTransforms = "057dd010-8810-581a-b7be-e3fc3b93f78c" FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" -SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" @@ -34,7 +34,6 @@ FillArrays = "0.11, 0.12, 0.13, 1" IntervalSets = "0.5, 0.6, 0.7" LazyArrays = "0.22, 1" Reexport = "0.2, 1" -SnoopPrecompile = "1" SpecialFunctions = "0.10, 1.0, 2" Static = "0.8" StaticArrays = "1" diff --git a/src/precompile.jl b/src/precompile.jl index c7a3e77..0821764 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -1,6 +1,6 @@ -using SnoopPrecompile +using PrecompileTools -@precompile_setup begin +@setup_workload begin splist = Any[Jacobi(1, 1), Chebyshev(), Ultraspherical(1)] append!(splist, Any[Jacobi(1, 1, 0..1), Chebyshev(0..1), Ultraspherical(1, 0..1)]) spreal = copy(splist) @@ -10,7 +10,7 @@ using SnoopPrecompile v = ones(2) m = ones(2,2) a = ones(2,2,2) - @precompile_all_calls begin + @compile_workload begin for S in splist f = Fun(S,v) f(0.1) From 064594d0f2c321201cb7409ce11d5a87887f59d4 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Fri, 28 Apr 2023 19:06:58 +0530 Subject: [PATCH 7/7] fix compat for PrecompileTools --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index 084c859..2ff7d09 100644 --- a/Project.toml +++ b/Project.toml @@ -33,6 +33,7 @@ FastTransforms = "0.12, 0.13, 0.14, 0.15.1" FillArrays = "0.11, 0.12, 0.13, 1" IntervalSets = "0.5, 0.6, 0.7" LazyArrays = "0.22, 1" +PrecompileTools = "1" Reexport = "0.2, 1" SpecialFunctions = "0.10, 1.0, 2" Static = "0.8"