Skip to content

Commit c6401af

Browse files
Add static allocation checks and fix ComponentArrays allocs
Fixes #1152
1 parent 4e618d7 commit c6401af

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

.github/workflows/Tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
- Core
2727
- Downstream
2828
- Downstream2
29+
- Static
2930
uses: "SciML/.github/.github/workflows/tests.yml@v1"
3031
with:
3132
julia-version: "${{ matrix.version }}"

src/common_defaults.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ function abs2_and_sum(x, y)
33
reduce(+, y, init = zero(real(value(eltype(y)))))
44
end
55
UNITLESS_ABS2(x::Number) = abs2(x)
6+
7+
function UNITLESS_ABS2(x::AbstractArray{<:Number})
8+
mapreduce(UNITLESS_ABS2, +, x, init = zero(real(value(eltype(x)))))
9+
end
10+
611
function UNITLESS_ABS2(x::AbstractArray)
712
mapreduce(UNITLESS_ABS2, abs2_and_sum, x, init = zero(real(value(eltype(x)))))
813
end

test/runtests.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ function activate_downstream_env()
1111
Pkg.instantiate()
1212
end
1313

14+
function activate_static_env()
15+
Pkg.activate("static")
16+
Pkg.develop(PackageSpec(path = dirname(@__DIR__)))
17+
Pkg.instantiate()
18+
end
19+
1420
function activate_gpu_env()
1521
Pkg.activate("gpu")
1622
Pkg.develop(PackageSpec(path = dirname(@__DIR__)))
@@ -55,6 +61,11 @@ end
5561
@time @safetestset "GTPSA Tests" include("downstream/gtpsa.jl")
5662
end
5763

64+
if !is_APPVEYOR && GROUP == "Static"
65+
activate_static_env()
66+
@time @safetestset "Static Checks" include("static/static_checks.jl")
67+
end
68+
5869
if !is_APPVEYOR && GROUP == "Downstream2"
5970
activate_downstream_env()
6071
@time @safetestset "Prob Kwargs" include("downstream/prob_kwargs.jl")

test/static/Project.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[deps]
2+
AllocCheck = "9b6a8646-10ed-4001-bbdc-1d2f46dfbb1a"
3+
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
4+
5+
[compat]

test/static/static_checks.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using DiffEqBase, ComponentArrays, AllocCheck
2+
3+
u = ComponentArray(x=1.0, y=0.0, z=0.0)
4+
t = 0.0
5+
@test @allocated(DiffEqBase.ODE_DEFAULT_NORM(u, t)) < 20

0 commit comments

Comments
 (0)