Skip to content

Commit

Permalink
Optimization made from JET reports
Browse files Browse the repository at this point in the history
  • Loading branch information
pnavaro committed Jan 29, 2024
1 parent e0243d1 commit 6dcdec6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/h1fh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ function step!(

op.fS1 .= fft(S1)

op.partial .= -K_xc * n_i * 0.5 * 1im .* op.mesh.kx .* op.fS1
for i in eachindex(op.mesh.kx)
op.partial[i] = -K_xc * n_i * 0.5 * 1im * op.mesh.kx[i] * op.fS1[i]
end

ifft!(op.partial)

Expand Down
6 changes: 4 additions & 2 deletions src/h2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ function step!(
op.partial .= 1im .* kx .* A3
ifft!(op.partial)

f0 .= op.u1 .+ op.u2
f2 .= op.u1 ./ sqrt(3) .- op.u2 ./ sqrt(3)
for i in eachindex(f0, f2)
f0[i] = op.u1[i] + op.u2[i]
f2[i] = op.u1[i] / sqrt(3) - op.u2[i] / sqrt(3)
end

@sync begin
@spawn op.u1 .=
Expand Down
15 changes: 10 additions & 5 deletions src/h2fh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ function step!(

K_xc = tiK

op.u1 .= f1
op.u2 .= f3
copyto!(op.u1, f1)
copyto!(op.u2, f3)

@inbounds for i in eachindex(S2)
B20 = -K_xc * op.n_i * 0.5 * S2[i]
Expand All @@ -69,7 +69,10 @@ function step!(

op.fS2 .= fft(S2)

op.partial .= -K_xc * op.n_i * 0.5 * 1im .* op.mesh.kx .* op.fS2
for i in eachindex(op.mesh.kx)
op.partial[i] = - K_xc * op.n_i * 0.5 * 1im * op.mesh.kx[i] * op.fS2[i]
end

ifft!(op.partial)

for i = 1:op.mesh.nx
Expand Down Expand Up @@ -101,8 +104,10 @@ function step!(
op.v2[i] = sin(dt * temi) * S1[i] + cos(dt * temi) * S3[i]
end

f0 .= op.u1 .+ op.u2
f2 .= op.u1 .- op.u2
for i in eachindex(f0, f2)
f0[i] = op.u1[i] + op.u2[i]
f2[i] = op.u1[i] - op.u2[i]
end

copyto!(S1, op.v1)
copyto!(S3, op.v2)
Expand Down
6 changes: 4 additions & 2 deletions src/h3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ function step!(
op.partial .= 1im .* k .* A2
ifft!(op.partial)

f0 .= op.u1 .+ op.u2
f3 .= op.u1 ./ sqrt(3) .- op.u2 ./ sqrt(3)
for i in eachindex(f0, f3)
f0[i] = op.u1[i] + op.u2[i]
f3[i] = op.u1[i] / sqrt(3) - op.u2[i] / sqrt(3)
end

@sync begin
@spawn op.u1 .=
Expand Down
2 changes: 1 addition & 1 deletion src/hv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct HvSubsystem{T}
ff2 = zeros(Complex{T}, mesh.nx, mesh.nv)
ff3 = zeros(Complex{T}, mesh.nx, mesh.nv)

ev = exp.(-1im .* mesh.kx .* mesh.vnode')
ev = zeros(Complex{T}, mesh.nx, mesh.nv)

p0 = plan_fft(f0, 1, flags = FFTW.PATIENT)
p1 = plan_fft(f1, 1, flags = FFTW.PATIENT)
Expand Down

0 comments on commit 6dcdec6

Please sign in to comment.