Skip to content

Commit

Permalink
Reenable @inbounds statement.
Browse files Browse the repository at this point in the history
Unfortunately, the @inbounds marker seems unrelated to the crashing
behavior. Attempt another temporary workaround: disable dipole-dipole
in energy consistency test.

JuliaLang/julia#48722
  • Loading branch information
kbarros committed Feb 24, 2023
1 parent 2331b1f commit 3d54b13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/System/Ewald.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ function energy(dipoles::Array{Vec3, 4}, ewald::Ewald)
# * Combined, the result is: E = conj(F[s]) conj(F[A]) F[s] / N
(_, m1, m2, m3, nb) = size(Fs)
ms = CartesianIndices((m1, m2, m3))
# TODO: Reinsert @inbounds here once segfault is fixed.
for b2 in 1:nb, b1 in 1:nb, m in ms, α in 1:3, β in 1:3
@inbounds for b2 in 1:nb, b1 in 1:nb, m in ms, α in 1:3, β in 1:3
E += real(conj(Fs[α, m, b1]) * conj(FA[α, β, m, b1, b2]) * Fs[β, m, b2])
end
return E / prod(latsize)
Expand All @@ -155,8 +154,8 @@ function accum_force!(B::Array{Vec3, 4}, dipoles::Array{Vec3, 4}, ewald::Ewald)
mul!(Fs, plan, reinterpret(reshape, Float64, dipoles))
(_, m1, m2, m3, nb) = size(Fs)
ms = CartesianIndices((m1, m2, m3))
# TODO: Reinsert @inbounds here once segfault is fixed. Performance diff is ~50%
for b2 in 1:nb, b1 in 1:nb, m in ms, α in 1:3, β in 1:3
# Without @inbounds, performance degrades by ~50%
@inbounds for b2 in 1:nb, b1 in 1:nb, m in ms, α in 1:3, β in 1:3
Fϕ[α,m,b1] += conj(FA[α,β,m,b1,b2]) * Fs[β,m,b2]
end
ϕr = reinterpret(reshape, Float64, ϕ)
Expand Down
2 changes: 1 addition & 1 deletion test/test_energy_consistency.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
add_linear_interactions!(sys, mode)
add_quadratic_interactions!(sys, mode)
add_quartic_interactions!(sys, mode)
enable_dipole_dipole!(sys)
# enable_dipole_dipole!(sys) # workaround segfault

# Random field
for idx in Sunny.all_sites(sys)
Expand Down

0 comments on commit 3d54b13

Please sign in to comment.