Skip to content

Commit

Permalink
Rename inner function to foreach_neighbor (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
efaulhaber authored Jun 6, 2024
1 parent 51f8fe4 commit 0045290
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
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

0 comments on commit 0045290

Please sign in to comment.