Skip to content

Commit 61ed9cd

Browse files
Move to PrecompileTools (JuliaArrays#1187)
* move to PrecompileTools . * update disabled precompiles Co-Authored-By: Tim Holy <tim.holy@gmail.com> * fix Co-Authored-By: Tim Holy <tim.holy@gmail.com> --------- Co-authored-by: Tim Holy <tim.holy@gmail.com>
1 parent 7c5febd commit 61ed9cd

File tree

3 files changed

+30
-33
lines changed

3 files changed

+30
-33
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version = "1.6.5"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
7+
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
78
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
89
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
910
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
@@ -15,8 +16,9 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1516
StaticArraysStatisticsExt = "Statistics"
1617

1718
[compat]
18-
julia = "1.6"
19+
PrecompileTools = "1"
1920
StaticArraysCore = "~1.4.0"
21+
julia = "1.6"
2022

2123
[extras]
2224
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"

src/StaticArrays.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import LinearAlgebra: transpose, adjoint, dot, eigvals, eigen, lyap, tr,
1919
normalize!, Eigen, det, logdet, logabsdet, cross, diff, qr, \
2020
using LinearAlgebra: checksquare
2121

22+
using PrecompileTools
23+
2224
# StaticArraysCore imports
2325
# there is intentionally no "using StaticArraysCore" to not take all symbols exported
2426
# from StaticArraysCore to make transitioning definitions to StaticArraysCore easier.
@@ -136,6 +138,5 @@ include("pinv.jl")
136138
end
137139

138140
include("precompile.jl")
139-
_precompile_()
140141

141142
end # module

src/precompile.jl

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,29 @@
1-
function _precompile_()
2-
ccall(:jl_generating_output, Cint, ()) == 1 || return nothing
3-
# These make a difference for Makie's TTFP and should help others too
4-
# Total time for this to run is ~2s. To time it, disable:
5-
# - the `_precompile_()` call in StaticArrays.jl
6-
# - the jl_generating_output line above
7-
# and then do
8-
# @time StaticArrays._precompile_()
9-
10-
for T in (Float32, Float64, Int) # some common eltypes
11-
for S = 2:4 # some common sizes
12-
L = S*S
13-
@assert precompile(Tuple{typeof(*),SMatrix{S, S, T, L},SMatrix{S, S, T, L}})
14-
@assert precompile(Tuple{typeof(*),SMatrix{S, S, T, L},SVector{S, T}})
15-
@assert precompile(Tuple{typeof(inv),SMatrix{S, S, T, L}})
16-
@assert precompile(Tuple{typeof(transpose),SMatrix{S, S, T, L}})
17-
@assert precompile(Tuple{typeof(_adjoint),Size{(S, S)},SMatrix{S, S, T, L}})
18-
@assert precompile(Tuple{Core.kwftype(typeof(minimum)),NamedTuple{(:dims,), Tuple{Int}},typeof(minimum),SMatrix{S, S, T, L}})
19-
@assert precompile(Tuple{Core.kwftype(typeof(maximum)),NamedTuple{(:dims,), Tuple{Int}},typeof(maximum),SMatrix{S, S, T, L}})
20-
@assert precompile(Tuple{typeof(getindex),SMatrix{S, S, T, L},SOneTo{S-1},SOneTo{S-1}})
1+
@setup_workload begin
2+
@compile_workload begin
3+
for T in (Float32, Float64, Int) # some common eltypes
4+
for S = 2:4 # some common sizes
5+
L = S*S
6+
x = fill(0., SMatrix{S, S, T, L})
7+
x * x
8+
y = fill(0., SVector{S, T})
9+
x * y
10+
inv(x)
11+
transpose(x)
12+
_adjoint(Size(S, S), x)
13+
minimum(x; dims=1)
14+
minimum(x; dims=2)
15+
maximum(x; dims=1)
16+
maximum(x; dims=2)
17+
getindex(x, SOneTo(S-1), SOneTo(S-1))
18+
y .* x .* y'
19+
zero(y)
20+
zero(x)
21+
end
2122
end
22-
end
2323

24-
# TODO: These fail to precompile on v1.11 pre-release
25-
if VERSION < v"1.11.0-0"
26-
# Some expensive generators
27-
@assert precompile(Tuple{typeof(which(__broadcast,(Any,Size,Tuple{Vararg{Size}},Vararg{Any},)).generator.gen),Any,Any,Any,Any,Any,Any})
28-
@assert precompile(Tuple{typeof(which(_zeros,(Size,Type{<:StaticArray},)).generator.gen),Any,Any,Any,Type,Any})
29-
@assert precompile(Tuple{typeof(which(_mapfoldl,(Any,Any,Colon,Any,Size,Vararg{StaticArray},)).generator.gen),Any,Any,Any,Any,Any,Any,Any,Any})
30-
end
31-
# broadcast_getindex
32-
for m = 0:5, n = m:5
33-
@assert precompile(Tuple{typeof(broadcast_getindex),NTuple{m,Int},Int,CartesianIndex{n}})
24+
# broadcast_getindex
25+
for m = 0:5, n = m:5
26+
broadcast_getindex(Tuple(1:m), 1, CartesianIndex(n))
27+
end
3428
end
3529
end

0 commit comments

Comments
 (0)