Skip to content

Commit

Permalink
[Proof of Concept] Use symmetry to speed up the main loop
Browse files Browse the repository at this point in the history
  • Loading branch information
efaulhaber committed Dec 2, 2024
1 parent 9560a82 commit c213dbf
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit c213dbf

Please sign in to comment.