Skip to content

Commit

Permalink
fix: better precompile directives + remove redundant packages
Browse files Browse the repository at this point in the history
  • Loading branch information
fjebaker committed Jul 26, 2023
1 parent 33d7456 commit e19db98
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 13 deletions.
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ authors = ["fjebaker <[email protected]>"]
version = "0.4.12"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Buckets = "3235f445-51d8-4100-901d-5b23398ac3ab"
DataInterpolations = "82cc6244-b520-54b8-b5a6-8a565e85f1d0"
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
EnumX = "4e289a0a-7415-4d19-859d-a7e5c4648b56"
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
14 changes: 3 additions & 11 deletions src/Gradus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ using StaticArrays
using Optim
using DataInterpolations
using VoronoiCells
using FiniteDifferences
using Roots
using ProgressMeter
using Buckets
using QuadGK
using MuladdMacro

using Accessors: @set
using Tullio: @tullio

import ForwardDiff
Expand Down Expand Up @@ -255,14 +253,8 @@ export AbstractPointFunction,
AbstractDiscProfile,
AbstractDirectionSampler

# precompilation help
precompile(
tracegeodesics,
(KerrMetric{Float64}, SVector{4,Float64}, SVector{4,Float64}, Tuple{Float64,Float64}),
)
precompile(
rendergeodesics,
(KerrMetric{Float64}, SVector{4,Float64}, GeometricThinDisc{Float64}, Float64),
)
if Base.VERSION >= v"1.4.2"
include("precompile.jl")
end

end # module
141 changes: 141 additions & 0 deletions src/precompile.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
Base.precompile(
Tuple{
typeof(lineprofile),
KerrMetric{Float64},
SVector{4,Float64},
GeometricThinDisc{Float64},
},
) # time: 4.8591228
Base.precompile(
Tuple{
typeof(tracegeodesics),
KerrMetric{Float64},
SVector{4,Float64},
SVector{4,Float64},
Vararg{Any},
},
) # time: 1.1855857
let fbody = try
__lookup_kwbody__(
which(
tracegeodesics,
(
TraceGeodesic{Float64},
KerrMetric{Float64},
SVector{4,Float64},
Vararg{Any},
),
),
)
catch missing
end
if !ismissing(fbody)
precompile(
fbody,
(
Base.Pairs{
Symbol,
Any,
Tuple{Symbol,Symbol},
NamedTuple{(:save_on, :chart),Tuple{Bool,PolarChart{Float64}}},
},
typeof(tracegeodesics),
TraceGeodesic{Float64},
KerrMetric{Float64},
SVector{4,Float64},
Vararg{Any},
),
)
end
end # time: 0.9053782
Base.precompile(
Tuple{
typeof(Core.kwcall),
NamedTuple{
(:trace, :image_width, :image_height),
Tuple{TraceRadiativeTransfer{Float64},Int64,Int64},
},
typeof(rendergeodesics),
KerrMetric{Float64},
SVector{4,Float64},
GeometricThinDisc{Float64},
Vararg{Any},
},
) # time: 0.11555993
Base.precompile(
Tuple{
typeof(Core.kwcall),
NamedTuple{(:trace,),Tuple{TraceRadiativeTransfer{Float64}}},
typeof(tracegeodesics),
KerrMetric{Float64},
SVector{4,Float64},
SVector{4,Float64},
Vararg{Any},
},
) # time: 0.04722405
Base.precompile(
Tuple{
typeof(tracegeodesics),
KerrMetric{Float64},
Vector{SVector{4,Float64}},
Vector{SVector{4,Float64}},
Vararg{Any},
},
) # time: 0.034065828
Base.precompile(
Tuple{
typeof(Core.kwcall),
NamedTuple{(:n_samples,),Tuple{Int64}},
typeof(tracegeodesics),
KerrMetric{Float64},
LampPostModel{Float64},
GeometricThinDisc{Float64},
Vararg{Any},
},
) # time: 0.025394669
Base.precompile(
Tuple{
typeof(update_integration_parameters!),
RadiativeTransferIntegrationParameters{Vector{Bool}},
RadiativeTransferIntegrationParameters{Vector{Bool}},
},
) # time: 0.007881916
Base.precompile(
Tuple{
typeof(Core.kwcall),
NamedTuple{
(:trajectories, :save_on, :ensemble),
Tuple{Int64,Bool,EnsembleEndpointThreads},
},
typeof(tracing_configuration),
TraceRadiativeTransfer{Float64},
KerrMetric{Float64},
SVector{4,Float64},
Function,
GeometricThinDisc{Float64},
Float64,
},
) # time: 0.007585501
Base.precompile(
Tuple{
var"#200#threadsfor_fun#119"{
var"#200#threadsfor_fun#118#120"{
KerrMetric{Float64},
Matrix{Float64},
Vector{GeodesicPoint{Float64,SVector{1,Float64}}},
PointFunction{
var"#154#156"{
var"#154#155#157"{
FilterPointFunction{var"#110#116"{var"#110#111#117"},Float64},
var"#109#115",
var"#110#116"{var"#110#111#117"},
},
},
},
Float64,
Base.OneTo{Int64},
},
},
Int64,
},
) # time: 0.001631875

0 comments on commit e19db98

Please sign in to comment.