Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/nhs_precomputed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ function copy_neighborhood_search(nhs::PrecomputedNeighborhoodSearch,
update_neighborhood_search,
backend = typeof(nhs.neighbor_lists),
transpose_backend,
max_neighbors = max_neighbors_)
max_neighbors = max_neighbors_,
sort_neighbor_lists = nhs.sort_neighbor_lists)
end

@inline function freeze_neighborhood_search(search::PrecomputedNeighborhoodSearch)
Expand Down
14 changes: 12 additions & 2 deletions src/vector_of_vectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ end
# Outer bounds check
@boundscheck checkbounds(vov, i)

lengths[i] += 1
@inbounds lengths[i] += 1

# Inner bounds check
@boundscheck check_list_bounds(vov, i)

# Activate new entry in column `i`
backend[lengths[i], i] = value
@inbounds backend[lengths[i], i] = value

return vov
end
Expand Down Expand Up @@ -175,6 +175,16 @@ end

# Sort each inner vector
@inline function sorteach!(vov::DynamicVectorOfVectors)
@threaded default_backend(vov.backend) for i in eachindex(vov)
# QuickSort is ~1.6x faster here than the default
sort!(view(vov.backend, 1:vov.lengths[i], i), alg = QuickSort)
end
Comment thread
efaulhaber marked this conversation as resolved.

return vov
end

# GPU version
@inline function sorteach!(vov::DynamicVectorOfVectors{<:Any, <:Any, <:AbstractGPUArray})
# TODO remove this check when Metal supports sorting
if nameof(typeof(default_backend(vov.backend))) == :MetalBackend
@warn "sorting neighbor lists is not supported on Metal. Skipping sort."
Expand Down
Loading