Skip to content

Commit ef00042

Browse files
Merge pull request #371 from ChrisRackauckas/fix-formatting
Apply JuliaFormatter to fix code formatting
2 parents 331cee5 + 7367a8e commit ef00042

20 files changed

+88
-51
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
This library is a component package of the DifferentialEquations.jl ecosystem. It includes
1313
functionality for making use of GPUs in the differential equation solvers.
1414

15-
1615
## The two ways to accelerate ODE solvers with GPUs
1716

1817
There are two very different ways that one can

docs/src/tutorials/lower_level_api.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,22 @@ probs = cu(probs)
3939
## Finally use the lower API for faster solves! (Fixed time-stepping)
4040
4141
# Run once for compilation
42-
@time CUDA.@sync ts, us = DiffEqGPU.vectorized_solve(probs, prob, GPUTsit5();
42+
@time CUDA.@sync ts,
43+
us = DiffEqGPU.vectorized_solve(probs, prob, GPUTsit5();
4344
save_everystep = false, dt = 0.1f0)
4445
45-
@time CUDA.@sync ts, us = DiffEqGPU.vectorized_solve(probs, prob, GPUTsit5();
46+
@time CUDA.@sync ts,
47+
us = DiffEqGPU.vectorized_solve(probs, prob, GPUTsit5();
4648
save_everystep = false, dt = 0.1f0)
4749
4850
## Adaptive time-stepping
4951
# Run once for compilation
50-
@time CUDA.@sync ts, us = DiffEqGPU.vectorized_asolve(probs, prob, GPUTsit5();
52+
@time CUDA.@sync ts,
53+
us = DiffEqGPU.vectorized_asolve(probs, prob, GPUTsit5();
5154
save_everystep = false, dt = 0.1f0)
5255
53-
@time CUDA.@sync ts, us = DiffEqGPU.vectorized_asolve(probs, prob, GPUTsit5();
56+
@time CUDA.@sync ts,
57+
us = DiffEqGPU.vectorized_asolve(probs, prob, GPUTsit5();
5458
save_everystep = false, dt = 0.1f0)
5559
```
5660

docs/src/tutorials/modelingtoolkit.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ by hand. Those exact features are also potentially useful for GPU computing, and
88
tutorial showcases how to effectively use MTK with DiffEqGPU.jl.
99

1010
!!! warn
11+
1112
This tutorial currently only works for ODEs defined by ModelingToolkit. More work
1213
will be required to support DAEs in full. This is work that is ongoing and expected
1314
to be completed by the summer of 2025.
@@ -29,16 +30,16 @@ eqs = [D(D(x)) ~ σ * (y - x),
2930
D(z) ~ x * y - β * z]
3031
3132
@mtkbuild sys = ODESystem(eqs, t)
32-
u0 = SA[D(x) => 2f0,
33-
x => 1f0,
34-
y => 0f0,
35-
z => 0f0]
33+
u0 = SA[D(x) => 2.0f0,
34+
x => 1.0f0,
35+
y => 0.0f0,
36+
z => 0.0f0]
3637
37-
p = SA[σ => 28f0,
38-
ρ => 10f0,
39-
β => 8f0 / 3f0]
38+
p = SA[σ => 28.0f0,
39+
ρ => 10.0f0,
40+
β => 8.0f0 / 3.0f0]
4041
41-
tspan = (0f0, 100f0)
42+
tspan = (0.0f0, 100.0f0)
4243
prob = ODEProblem{false}(sys, u0, tspan, p)
4344
sol = solve(prob, Tsit5())
4445
```
@@ -64,7 +65,7 @@ sym_setter = setsym_oop(sys, [σ, ρ, β])
6465
The return `sym_setter` is our optimized function, let's see it in action:
6566

6667
```@example mtk
67-
u0, p = sym_setter(prob,@SVector(rand(Float32,3)))
68+
u0, p = sym_setter(prob, @SVector(rand(Float32, 3)))
6869
```
6970

7071
Notice it takes in the vector of values for `[σ, ρ, β]` and spits out the new `u0, p`. So
@@ -73,7 +74,7 @@ we can build and solve an MTK generated ODE on the GPU using the following:
7374
```@example mtk
7475
using DiffEqGPU, CUDA
7576
function prob_func2(prob, i, repeat)
76-
u0, p = sym_setter(prob,@SVector(rand(Float32,3)))
77+
u0, p = sym_setter(prob, @SVector(rand(Float32, 3)))
7778
remake(prob, u0 = u0, p = p)
7879
end
7980

src/DiffEqGPU.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ include("ensemblegpukernel/tableaus/verner_tableaus.jl")
6868
include("ensemblegpukernel/tableaus/rodas_tableaus.jl")
6969
include("ensemblegpukernel/tableaus/kvaerno_tableaus.jl")
7070

71-
72-
7371
include("utils.jl")
7472
include("algorithms.jl")
7573
include("solve.jl")

src/ensemblegpuarray/kernels.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ end
7575

7676
@views @inbounds f(J[section, section], u[:, i + 1], p, t)
7777
@inbounds for j in section, k in section
78+
7879
J[k, j] = J[k, j] * (tspan[2] - tspan[1])
7980
end
8081
end
@@ -94,6 +95,7 @@ end
9495
@views @inbounds x = f(u[:, i + 1], p, t)
9596

9697
@inbounds for j in section, k in section
98+
9799
J[k, j] = x[k, j] * (tspan[2] - tspan[1])
98100
end
99101
end
@@ -117,6 +119,7 @@ end
117119
@views @inbounds x = f(u[:, i + 1], p[i + 1], t)
118120
end
119121
@inbounds for j in section, k in section
122+
120123
J[k, j] = x[k, j]
121124
end
122125
end

src/ensemblegpuarray/problem_generation.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ function generate_problem(prob::SciMLBase.AbstractODEProblem,
5858
_tgrad = nothing
5959
end
6060

61-
6261
f_func = ODEFunction(_f, Wfact = _Wfact!,
6362
Wfact_t = _Wfact!_t,
6463
#colorvec=colorvec,

src/ensemblegpukernel/integrators/integrator_utils.jl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ end
108108
saved_in_cb::Bool, callback::GPUDiscreteCallback,
109109
args...) where {AlgType <: GPUODEAlgorithm, IIP,
110110
S, T}
111-
bool, saved_in_cb2 = apply_discrete_callback!(integrator, ts, us,
111+
bool,
112+
saved_in_cb2 = apply_discrete_callback!(integrator, ts, us,
112113
apply_discrete_callback!(integrator, ts,
113114
us, callback)...,
114115
args...)
@@ -243,14 +244,19 @@ end
243244
if !(continuous_callbacks isa Tuple{})
244245
event_occurred = false
245246

246-
time, upcrossing, event_occurred, event_idx, idx, counter = DiffEqBase.find_first_continuous_callback(
247+
time, upcrossing,
248+
event_occurred,
249+
event_idx,
250+
idx,
251+
counter = DiffEqBase.find_first_continuous_callback(
247252
integrator,
248253
continuous_callbacks...)
249254

250255
if event_occurred
251256
integrator.event_last_time = idx
252257
integrator.vector_event_last_time = event_idx
253-
continuous_modified, saved_in_cb = apply_callback!(integrator,
258+
continuous_modified,
259+
saved_in_cb = apply_callback!(integrator,
254260
continuous_callbacks[1],
255261
time, upcrossing,
256262
event_idx, ts, us)
@@ -260,7 +266,8 @@ end
260266
end
261267
end
262268
if !(discrete_callbacks isa Tuple{})
263-
discrete_modified, saved_in_cb = apply_discrete_callback!(integrator, ts, us,
269+
discrete_modified,
270+
saved_in_cb = apply_discrete_callback!(integrator, ts, us,
264271
discrete_callbacks...)
265272
return discrete_modified, saved_in_cb
266273
end
@@ -278,7 +285,10 @@ end
278285
callback::DiffEqGPU.GPUContinuousCallback,
279286
counter) where {AlgType <: GPUODEAlgorithm,
280287
IIP, S, T}
281-
event_occurred, interp_index, prev_sign, prev_sign_index, event_idx = DiffEqBase.determine_event_occurrence(
288+
event_occurred, interp_index,
289+
prev_sign,
290+
prev_sign_index,
291+
event_idx = DiffEqBase.determine_event_occurrence(
282292
integrator,
283293
callback,
284294
counter)

src/ensemblegpukernel/linalg/lu.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function __lu(A::StaticLUMatrix{M, N, T}, ::Val{Pivot}) where {M, N, T, Pivot}
148148
Lrest, Urest, prest = __lu(Arest, Val(Pivot))
149149
p = [SVector{1, Int}(kp); ps[prest]]
150150
L = [[SVector{1}(one(eltype(Ls))); Ls[prest]] [zeros(typeof(SMatrix{1}(Lrest[1,
151-
:])));
151+
:])));
152152
Lrest]]
153153
U = [Ufirst; [zeros(typeof(Urest[:, 1])) Urest]]
154154
end

src/ensemblegpukernel/perform_step/gpu_kvaerno3_perform_step.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
f = integ.f
77
integ.uprev = integ.u
88
uprev = integ.u
9-
@unpack γ, a31, a32, a41, a42, a43, btilde1, btilde2, btilde3, btilde4, c3, α31, α32 = integ.tab
9+
@unpack γ, a31, a32, a41, a42, a43, btilde1, btilde2, btilde3, btilde4, c3, α31,
10+
α32 = integ.tab
1011

1112
integ.tprev = t
1213
saved_in_cb = false
@@ -86,7 +87,8 @@
8687
end
8788

8889
@inline function step!(integ::GPUAKvaerno3I{false, S, T}, ts, us) where {T, S}
89-
beta1, beta2, qmax, qmin, gamma, qoldinit, _ = build_adaptive_controller_cache(
90+
beta1, beta2, qmax, qmin, gamma, qoldinit,
91+
_ = build_adaptive_controller_cache(
9092
integ.alg,
9193
T)
9294

@@ -104,7 +106,8 @@ end
104106
abstol = integ.abstol
105107
reltol = integ.reltol
106108

107-
@unpack γ, a31, a32, a41, a42, a43, btilde1, btilde2, btilde3, btilde4, c3, α31, α32 = integ.tab
109+
@unpack γ, a31, a32, a41, a42, a43, btilde1, btilde2, btilde3, btilde4, c3, α31,
110+
α32 = integ.tab
108111

109112
if integ.u_modified
110113
k1 = f(uprev, p, t)

src/ensemblegpukernel/perform_step/gpu_kvaerno5_perform_step.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
f = integ.f
77
integ.uprev = integ.u
88
uprev = integ.u
9-
@unpack γ, a31, a32, a41, a42, a43, a51, a52, a53, a54, a61, a63, a64, a65, a71, a73, a74, a75, a76, c3, c4, c5, c6 = integ.tab
9+
@unpack γ, a31, a32, a41, a42, a43, a51, a52, a53, a54, a61, a63, a64,
10+
a65, a71, a73, a74, a75, a76, c3, c4, c5, c6 = integ.tab
1011
@unpack btilde1, btilde3, btilde4, btilde5, btilde6, btilde7 = integ.tab
1112
@unpack α31, α32, α41, α42, α43, α51, α52, α53, α61, α62, α63 = integ.tab
1213

@@ -117,7 +118,8 @@
117118
end
118119

119120
@inline function step!(integ::GPUAKvaerno5I{false, S, T}, ts, us) where {T, S}
120-
beta1, beta2, qmax, qmin, gamma, qoldinit, _ = build_adaptive_controller_cache(
121+
beta1, beta2, qmax, qmin, gamma, qoldinit,
122+
_ = build_adaptive_controller_cache(
121123
integ.alg,
122124
T)
123125

@@ -135,7 +137,8 @@ end
135137
abstol = integ.abstol
136138
reltol = integ.reltol
137139

138-
@unpack γ, a31, a32, a41, a42, a43, a51, a52, a53, a54, a61, a63, a64, a65, a71, a73, a74, a75, a76, c3, c4, c5, c6 = integ.tab
140+
@unpack γ, a31, a32, a41, a42, a43, a51, a52, a53, a54, a61, a63, a64,
141+
a65, a71, a73, a74, a75, a76, c3, c4, c5, c6 = integ.tab
139142
@unpack btilde1, btilde3, btilde4, btilde5, btilde6, btilde7 = integ.tab
140143
@unpack α31, α32, α41, α42, α43, α51, α52, α53, α61, α62, α63 = integ.tab
141144

0 commit comments

Comments
 (0)