Skip to content

Commit 8fdee10

Browse files
Format for JuliaFormatter v2
1 parent 251caa5 commit 8fdee10

File tree

64 files changed

+492
-364
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+492
-364
lines changed

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ makedocs(;
4848
"https://twitter.com/ChrisRackauckas/status/1544743542094020615",
4949
"https://link.springer.com/article/10.1007/s40096-020-00339-4",
5050
"https://dl.acm.org/doi/10.1145/210089.210111",
51-
"https://www.sciencedirect.com/science/article/abs/pii/S0045782523007156",
51+
"https://www.sciencedirect.com/science/article/abs/pii/S0045782523007156"
5252
],
5353
checkdocs = :exports,
5454
warnonly = [:missing_docs],

docs/src/tutorials/large_systems.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,19 @@ function brusselator_2d_loop(du, u, p)
7474
@inbounds for I in CartesianIndices((N, N))
7575
i, j = Tuple(I)
7676
x, y = xyd_brusselator[I[1]], xyd_brusselator[I[2]]
77-
ip1, im1, jp1, jm1 = limit(i + 1, N), limit(i - 1, N), limit(j + 1, N),
77+
ip1, im1, jp1,
78+
jm1 = limit(i + 1, N), limit(i - 1, N), limit(j + 1, N),
7879
limit(j - 1, N)
79-
du[i, j, 1] = alpha * (u[im1, j, 1] + u[ip1, j, 1] + u[i, jp1, 1] + u[i, jm1, 1] -
80-
4u[i, j, 1]) +
81-
B +
82-
u[i, j, 1]^2 * u[i, j, 2] - (A + 1) * u[i, j, 1] + brusselator_f(x, y)
83-
du[i, j, 2] = alpha * (u[im1, j, 2] + u[ip1, j, 2] + u[i, jp1, 2] + u[i, jm1, 2] -
84-
4u[i, j, 2]) + A * u[i, j, 1] - u[i, j, 1]^2 * u[i, j, 2]
80+
du[i,
81+
j,
82+
1] = alpha * (u[im1, j, 1] + u[ip1, j, 1] + u[i, jp1, 1] + u[i, jm1, 1] -
83+
4u[i, j, 1]) +
84+
B +
85+
u[i, j, 1]^2 * u[i, j, 2] - (A + 1) * u[i, j, 1] + brusselator_f(x, y)
86+
du[i,
87+
j,
88+
2] = alpha * (u[im1, j, 2] + u[ip1, j, 2] + u[i, jp1, 2] + u[i, jm1, 2] -
89+
4u[i, j, 2]) + A * u[i, j, 1] - u[i, j, 1]^2 * u[i, j, 2]
8590
end
8691
end
8792
p = (3.4, 1.0, 10.0, step(xyd_brusselator))

docs/src/tutorials/nonlinear_solve_gpus.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ using the first form.
3131
In this tutorial we will highlight both use cases in separate parts.
3232

3333
!!! note
34-
34+
3535
If you're looking for GPU-accelerated neural networks inside of nonlinear solvers,
3636
check out [DeepEquilibriumNetworks.jl](https://docs.sciml.ai/DeepEquilibriumNetworks/stable/).
3737

@@ -58,7 +58,7 @@ f(u, p) = u .* u .- p
5858
u0 = cu(ones(1000))
5959
p = cu(collect(1:1000))
6060
prob = NonlinearProblem(f, u0, p)
61-
sol = solve(prob, NewtonRaphson(), abstol=1f-4)
61+
sol = solve(prob, NewtonRaphson(), abstol = 1.0f-4)
6262
```
6363

6464
Notice a few things here. One, nothing is different except the input array types. But
@@ -106,7 +106,7 @@ is saying, "for the ith call, get the i'th parameter set and solve with these pa
106106
The ith result is then this solution".
107107

108108
!!! note
109-
109+
110110
Because kernel code needs to be able to be compiled to a GPU kernel, it has very strict
111111
specifications of what's allowed because GPU cores are not as flexible as CPU cores.
112112
In general, this means that you need to avoid any runtime operations in kernel code,
@@ -137,16 +137,16 @@ Now let's build a nonlinear system to test it on.
137137
out2 = sqrt(p[2]) * (x[3] - x[4])
138138
out3 = (x[2] - p[3] * x[3])^2
139139
out4 = sqrt(p[4]) * (x[1] - x[4]) * (x[1] - x[4])
140-
SA[out1,out2,out3,out4]
140+
SA[out1, out2, out3, out4]
141141
end
142142

143143
p = @SVector [@SVector(rand(Float32, 4)) for _ in 1:1024]
144-
u0 = SA[1f0, 2f0, 3f0, 4f0]
144+
u0 = SA[1.0f0, 2.0f0, 3.0f0, 4.0f0]
145145
prob = NonlinearSolveBase.ImmutableNonlinearProblem{false}(p2_f, u0, p)
146146
```
147147

148148
!!! note
149-
149+
150150
Because the custom kernel is going to need to embed the the code for our nonlinear
151151
problem into the kernel, it also must be written to be GPU compatible.
152152
In general, this means that you need to avoid any runtime operations in kernel code,
@@ -173,4 +173,5 @@ vectorized_solve(prob, SimpleNewtonRaphson(); backend = Metal.MetalBackend())
173173
```
174174

175175
!!! warn
176+
176177
The GPU-based calls will only work on your machine if you have a compatible GPU!

ext/NonlinearSolveFastLevenbergMarquardtExt.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ function SciMLBase.__solve(
2121
termination_condition, alg
2222
)
2323

24-
f_wrapped, u, resid = NonlinearSolveBase.construct_extension_function_wrapper(
24+
f_wrapped, u,
25+
resid = NonlinearSolveBase.construct_extension_function_wrapper(
2526
prob; alias_u0, can_handle_oop = Val(prob.u0 isa SArray)
2627
)
2728
f = if prob.u0 isa SArray
@@ -49,7 +50,8 @@ function SciMLBase.__solve(
4950
)
5051

5152
if prob.u0 isa SArray
52-
res, fx, info, iter, nfev, njev = FastLM.lmsolve(
53+
res, fx, info, iter, nfev,
54+
njev = FastLM.lmsolve(
5355
f, jac_fn, prob.u0; solver_kwargs...
5456
)
5557
LM, solver = nothing, nothing
@@ -68,7 +70,8 @@ function SciMLBase.__solve(
6870

6971
LM = FastLM.LMWorkspace(u, resid, J)
7072

71-
res, fx, info, iter, nfev, njev, LM, solver = FastLM.lmsolve!(
73+
res, fx, info, iter, nfev, njev,
74+
LM, solver = FastLM.lmsolve!(
7275
f, jac_fn, LM; solver, solver_kwargs...
7376
)
7477
end

ext/NonlinearSolveFixedPointAccelerationExt.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ function SciMLBase.__solve(
1515
termination_condition, alg
1616
)
1717

18-
f, u0, resid = NonlinearSolveBase.construct_extension_function_wrapper(
18+
f, u0,
19+
resid = NonlinearSolveBase.construct_extension_function_wrapper(
1920
prob; alias_u0, make_fixed_point = Val(true), force_oop = Val(true)
2021
)
2122

ext/NonlinearSolveMINPACKExt.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ function SciMLBase.__solve(
1717
termination_condition, alg
1818
)
1919

20-
f_wrapped!, u0, resid = NonlinearSolveBase.construct_extension_function_wrapper(
20+
f_wrapped!, u0,
21+
resid = NonlinearSolveBase.construct_extension_function_wrapper(
2122
prob; alias_u0
2223
)
2324
resid_size = size(resid)

ext/NonlinearSolveNLSolversExt.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ function SciMLBase.__solve(
3333
prob.f, autodiff, prob.u0, Constant(prob.p)
3434
)
3535

36-
fj_scalar = @closure (Jx, x) -> begin
36+
fj_scalar = @closure (Jx,
37+
x) -> begin
3738
return DifferentiationInterface.value_and_derivative(
3839
prob.f, prep, autodiff, x, Constant(prob.p)
3940
)

ext/NonlinearSolvePETScExt.jl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ function SciMLBase.__solve(
2222
termination_condition, alg; abs_norm_supported = false
2323
)
2424

25-
f_wrapped!, u0, resid = NonlinearSolveBase.construct_extension_function_wrapper(
25+
f_wrapped!, u0,
26+
resid = NonlinearSolveBase.construct_extension_function_wrapper(
2627
prob; alias_u0
2728
)
2829
T = eltype(u0)
@@ -48,7 +49,9 @@ function SciMLBase.__solve(
4849

4950
nf = Ref{Int}(0)
5051

51-
f! = @closure (cfx, cx, user_ctx) -> begin
52+
f! = @closure (cfx,
53+
cx,
54+
user_ctx) -> begin
5255
nf[] += 1
5356
fx = cfx isa Ptr{Nothing} ? PETSc.unsafe_localarray(T, cfx; read = false) : cfx
5457
x = cx isa Ptr{Nothing} ? PETSc.unsafe_localarray(T, cx; write = false) : cx
@@ -76,7 +79,8 @@ function SciMLBase.__solve(
7679
)
7780
J_init = zeros(T, 1, 1)
7881
else
79-
jac!, J_init = NonlinearSolveBase.construct_extension_jac(
82+
jac!,
83+
J_init = NonlinearSolveBase.construct_extension_jac(
8084
prob, alg, u0, resid; autodiff, initial_jacobian = Val(true)
8185
)
8286
end
@@ -85,7 +89,10 @@ function SciMLBase.__solve(
8589

8690
if J_init isa AbstractSparseMatrix
8791
PJ = PETSc.MatSeqAIJ(J_init)
88-
jac_fn! = @closure (cx, J, _, user_ctx) -> begin
92+
jac_fn! = @closure (cx,
93+
J,
94+
_,
95+
user_ctx) -> begin
8996
njac[] += 1
9097
x = cx isa Ptr{Nothing} ? PETSc.unsafe_localarray(T, cx; write = false) : cx
9198
if J isa PETSc.AbstractMat
@@ -102,7 +109,10 @@ function SciMLBase.__solve(
102109
snes.user_ctx = (; jacobian = J_init)
103110
else
104111
PJ = PETSc.MatSeqDense(J_init)
105-
jac_fn! = @closure (cx, J, _, user_ctx) -> begin
112+
jac_fn! = @closure (cx,
113+
J,
114+
_,
115+
user_ctx) -> begin
106116
njac[] += 1
107117
x = cx isa Ptr{Nothing} ? PETSc.unsafe_localarray(T, cx; write = false) : cx
108118
jac!(J, x)

ext/NonlinearSolveSIAMFANLEquationsExt.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ function SciMLBase.__solve(
6464
elseif method == :secant
6565
sol = secant(f, prob.u0; maxit = maxiters, atol, rtol, printerr)
6666
elseif method == :anderson
67-
f_aa, u, _ = NonlinearSolveBase.construct_extension_function_wrapper(
67+
f_aa, u,
68+
_ = NonlinearSolveBase.construct_extension_function_wrapper(
6869
prob; alias_u0, make_fixed_point = Val(true)
6970
)
7071
sol = aasol(
@@ -73,7 +74,8 @@ function SciMLBase.__solve(
7374
)
7475
end
7576
else
76-
f, u, resid = NonlinearSolveBase.construct_extension_function_wrapper(
77+
f, u,
78+
resid = NonlinearSolveBase.construct_extension_function_wrapper(
7779
prob; alias_u0, make_fixed_point = Val(method == :anderson)
7880
)
7981
N = length(u)

ext/NonlinearSolveSpeedMappingExt.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ function SciMLBase.__solve(
1616
termination_condition, alg
1717
)
1818

19-
m!, u, resid = NonlinearSolveBase.construct_extension_function_wrapper(
19+
m!, u,
20+
resid = NonlinearSolveBase.construct_extension_function_wrapper(
2021
prob; alias_u0, make_fixed_point = Val(true)
2122
)
2223
tol = NonlinearSolveBase.get_tolerance(abstol, eltype(u))

0 commit comments

Comments
 (0)