Skip to content

Commit

Permalink
Use PrecompileTools (#47)
Browse files Browse the repository at this point in the history
* Use PrecompileTools

* Update default Manifest

* More precompilation

* add file to .gitignore

* cleanup

* cleanup

* Add limit for PrecompileTools
  • Loading branch information
ufechner7 committed Mar 12, 2024
1 parent 832bcd9 commit 78d7d6a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ bin/kps-image-1.9-main.so
.vscode/settings.json
bin/kps-image-1.1-main.so
bin/kps-image-1.10-main.so
bin/kps-image-1.10-dev2.so
37 changes: 17 additions & 20 deletions Manifest-1.10.toml.default
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@

julia_version = "1.10.2"
manifest_format = "2.0"
project_hash = "82de7d00b41552f09375765ca5eaaa021eed178a"
project_hash = "642c8a96274ac43f57914dcc15e474cd5fd3a2d2"

[[deps.ADTypes]]
git-tree-sha1 = "41c37aa88889c171f1300ceac1313c06e891d245"
git-tree-sha1 = "016833eb52ba2d6bea9fcb50ca295980e728ee24"
uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
version = "0.2.6"
version = "0.2.7"

[[deps.Adapt]]
deps = ["LinearAlgebra", "Requires"]
git-tree-sha1 = "cea4ac3f5b4bc4b3000aa55afb6e5626518948fa"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "4.0.3"

weakdeps = ["StaticArrays"]

[deps.Adapt.extensions]
Expand All @@ -26,14 +25,15 @@ version = "1.1.1"

[[deps.ArrayInterface]]
deps = ["Adapt", "LinearAlgebra", "SparseArrays", "SuiteSparse"]
git-tree-sha1 = "c85c172841acde8dcdf5d77967b14c89c33d65cc"
git-tree-sha1 = "44691067188f6bd1b2289552a23e4b7572f4528d"
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
version = "7.8.1"
version = "7.9.0"

[deps.ArrayInterface.extensions]
ArrayInterfaceBandedMatricesExt = "BandedMatrices"
ArrayInterfaceBlockBandedMatricesExt = "BlockBandedMatrices"
ArrayInterfaceCUDAExt = "CUDA"
ArrayInterfaceChainRulesExt = "ChainRules"
ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore"
ArrayInterfaceReverseDiffExt = "ReverseDiff"
ArrayInterfaceStaticArraysCoreExt = "StaticArraysCore"
Expand All @@ -43,6 +43,7 @@ version = "7.8.1"
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2"
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
Expand Down Expand Up @@ -159,9 +160,9 @@ version = "1.1.0+0"

[[deps.ConcurrentUtilities]]
deps = ["Serialization", "Sockets"]
git-tree-sha1 = "9c4708e3ed2b799e6124b5673a712dda0b596a9b"
git-tree-sha1 = "87944e19ea747808b73178ce5ebb74081fdf2d35"
uuid = "f0e56b4a-5159-44fe-b623-3e5288b988bb"
version = "2.3.1"
version = "2.4.0"

[[deps.ConstructionBase]]
deps = ["LinearAlgebra"]
Expand Down Expand Up @@ -328,9 +329,10 @@ uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"

[[deps.FiniteDiff]]
deps = ["ArrayInterface", "LinearAlgebra", "Requires", "Setfield", "SparseArrays"]
git-tree-sha1 = "73d1214fec245096717847c62d389a5d2ac86504"
git-tree-sha1 = "bc0c5092d6caaea112d3c8e3b238d61563c58d5f"
uuid = "6a86dc24-6348-571c-b903-95158fe2bd41"
version = "2.22.0"
version = "2.23.0"

[deps.FiniteDiff.extensions]
FiniteDiffBandedMatricesExt = "BandedMatrices"
FiniteDiffBlockBandedMatricesExt = "BlockBandedMatrices"
Expand Down Expand Up @@ -677,9 +679,9 @@ version = "1.3.4"

[[deps.RecursiveArrayTools]]
deps = ["Adapt", "ArrayInterface", "DocStringExtensions", "GPUArraysCore", "IteratorInterfaceExtensions", "LinearAlgebra", "RecipesBase", "SparseArrays", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface", "Tables"]
git-tree-sha1 = "b81c1728477663d4104910f448770f448f946d11"
git-tree-sha1 = "a94d22ca9ad49a7a169ecbc5419c59b9793937cc"
uuid = "731186ca-8d62-57ce-b412-fbd966d074cd"
version = "3.11.0"
version = "3.12.0"

[deps.RecursiveArrayTools.extensions]
RecursiveArrayToolsFastBroadcastExt = "FastBroadcast"
Expand Down Expand Up @@ -910,9 +912,10 @@ uuid = "fb77eaff-e24c-56d4-86b1-d163f2edb164"
version = "5.2.2+0"

[[deps.SymbolicIndexingInterface]]
git-tree-sha1 = "306960ba551858403f60267fabd76da7e79093d7"
deps = ["MacroTools", "RuntimeGeneratedFunctions"]
git-tree-sha1 = "f7b1fc9fc2bc938436b7684c243be7d317919056"
uuid = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
version = "0.3.10"
version = "0.3.11"

[[deps.TOML]]
deps = ["Dates"]
Expand Down Expand Up @@ -946,12 +949,6 @@ version = "1.10.0"
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[deps.TestEnv]]
deps = ["Pkg"]
git-tree-sha1 = "c35f69c951ac4f74b8b074f62dfb1e169b351497"
uuid = "1e6cf692-eddd-4d53-88a5-2d735e33781b"
version = "1.101.1"

[[deps.ThreadingUtilities]]
deps = ["ManualMemory"]
git-tree-sha1 = "eda08f7e9818eb53661b3deb74e3159460dfbc27"
Expand Down
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "KiteModels"
uuid = "b94af626-7959-4878-9336-2adc27959007"
authors = ["Uwe Fechner <fechner@aenarete.eu> and contributors"]
version = "0.5.1"
version = "0.5.2"

[deps]
AtmosphericModels = "c59cac55-771d-4f45-b14d-1c681463a295"
Expand All @@ -13,6 +13,7 @@ KiteUtils = "90980105-b163-44e5-ba9f-8b1c83bb0533"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Expand All @@ -31,6 +32,7 @@ KiteUtils = "0.5"
NLsolve = "4.5"
PackageCompiler = "2.0"
Parameters = "0.12"
PrecompileTools = "1.2"
Reexport = "1.2"
Rotations = "1.3"
StaticArrays = "1.9"
Expand Down
8 changes: 1 addition & 7 deletions bin/create_sys_image
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,7 @@ if [[ $update == true ]]; then
fi
julia --pkgimages=no --project -e "include(\"./test/update_packages.jl\");"
else
if [[ $julia_major == "1.7" ]]; then
cp Manifest-1.7.toml.default Manifest.toml
echo "Using Manifest-1.7.toml.default ..."
elif [[ $julia_major == "1.8" ]]; then
cp Manifest-1.8.toml.default Manifest.toml
echo "Using Manifest-1.8.toml.default ..."
elif [[ $julia_major == "1.9" ]]; then
if [[ $julia_major == "1.9" ]]; then
cp Manifest-1.9.toml.default Manifest.toml
echo "Using Manifest-1.9.toml.default ..."
else
Expand Down
24 changes: 16 additions & 8 deletions src/KiteModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Scientific background: http://arxiv.org/abs/1406.6218 =#

module KiteModels

using PrecompileTools: @setup_workload, @compile_workload
using Dierckx, StaticArrays, Rotations, LinearAlgebra, Parameters, NLsolve, DocStringExtensions, Sundials
using Reexport
@reexport using KitePodModels
Expand Down Expand Up @@ -460,12 +461,19 @@ function copy_bin()
chmod(joinpath(PATH, "update_packages.jl"), 0o664)
end

precompile(find_steady_state!, (KPS3{SimFloat, KVec3, se().segments+1},))
const particles = se().segments+KITE_PARTICLES+1
const springs = se().segments+KITE_SPRINGS
precompile(find_steady_state!, (KPS4{Float64, MVector{3, Float64}, particles, springs, KiteModels.Spring{Int16,
Float64}},))
precompile(init_sim!, (KPS4{Float64, MVector{3, Float64}, particles, springs, KiteModels.Spring{Int16, Float64}},
Float64,))

@setup_workload begin
# Putting some things in `@setup_workload` instead of `@compile_workload` can reduce the size of the
# precompile file and potentially make loading faster.
# list = [OtherType("hello"), OtherType("world!")]
set_data_path()
kps4_::KPS4 = KPS4(KCU(se()))
kps3_::KPS3 = KPS3(KCU(se()))
@compile_workload begin
# all calls in this block will be precompiled, regardless of whether
# they belong to your package or not (on Julia 1.8 and higher)
integrator = KiteModels.init_sim!(kps3_; stiffness_factor=0.035, prn=false)
integrator = KiteModels.init_sim!(kps4_; stiffness_factor=0.035, prn=false)
nothing
end
end
end

0 comments on commit 78d7d6a

Please sign in to comment.