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

Rename inner function to foreach_neighbor #24

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/PointNeighbors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ include("neighborhood_search.jl")
include("nhs_trivial.jl")
include("nhs_grid.jl")

export for_particle_neighbor
export for_particle_neighbor, foreach_neighbor
export TrivialNeighborhoodSearch, GridNeighborhoodSearch
export initialize!, update!, initialize_grid!, update_grid!

Expand Down
17 changes: 6 additions & 11 deletions src/neighborhood_search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ end
@inline function for_particle_neighbor(f, system_coords, neighbor_coords,
neighborhood_search, particles, parallel::Val{true})
@threaded for particle in particles
for_particle_neighbor_inner(f, system_coords, neighbor_coords, neighborhood_search,
particle)
foreach_neighbor(f, system_coords, neighbor_coords, neighborhood_search, particle)
end

return nothing
Expand All @@ -76,20 +75,16 @@ end
@inline function for_particle_neighbor(f, system_coords, neighbor_coords,
neighborhood_search, particles, parallel::Val{false})
for particle in particles
for_particle_neighbor_inner(f, system_coords, neighbor_coords, neighborhood_search,
particle)
foreach_neighbor(f, system_coords, neighbor_coords, neighborhood_search, particle)
end

return nothing
end

# Use this function barrier and unpack inside to avoid passing closures to Polyester.jl
# with `@batch` (`@threaded`).
# Otherwise, `@threaded` does not work here with Julia ARM on macOS.
# See https://github.com/JuliaSIMD/Polyester.jl/issues/88.
@inline function for_particle_neighbor_inner(f, system_coords, neighbor_system_coords,
neighborhood_search, particle)
(; search_radius, periodic_box) = neighborhood_search
@inline function foreach_neighbor(f, system_coords, neighbor_system_coords,
neighborhood_search, particle;
search_radius = neighborhood_search.search_radius)
(; periodic_box) = neighborhood_search

particle_coords = extract_svector(system_coords, Val(ndims(neighborhood_search)),
particle)
Expand Down