Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proof of Concept] Use symmetry to speed up the main loop #85

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/nhs_grid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ end
for neighbor_ in eachindex(neighbors)
neighbor = @inbounds neighbors[neighbor_]

# Skip half of the neighbors and use symmetry below.
# Note that this only works when `system_coords == neighbor_system_coords`.
point <= neighbor || continue

# Making the following `@inbounds` yields a ~2% speedup on an NVIDIA H100.
# But we don't know if `neighbor` (extracted from the cell list) is in bounds.
neighbor_coords = extract_svector(neighbor_system_coords,
Expand All @@ -390,6 +394,9 @@ end
# Inline to avoid loss of performance
# compared to not using `foreach_point_neighbor`.
@inline f(point, neighbor, pos_diff, distance)
if point < neighbor
@inline f(neighbor, point, -pos_diff, distance)
end
end
end
end
Expand Down
Loading