Skip to content

Commit 89ba802

Browse files
committed
Add comments
1 parent 2311f1b commit 89ba802

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/vector_of_vectors.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,21 @@ end
172172
return vov
173173
end
174174

175+
# Note that we cannot just do `sort!(vov[i])` on GPUs because that would call `sort!`
176+
# from within a GPU kernel, but this function is not GPU-compatible.
177+
# We might be able to use a sorting function from AcceleratedKernels.jl,
178+
# but for now the following workaround should be sufficient.
179+
180+
# Set all unused entries to `typemax` so that they are sorted to the end
175181
@threaded default_backend(vov.backend) for i in axes(vov.backend, 2)
176182
for j in (vov.lengths[i] + 1):size(vov.backend, 1)
177183
@inbounds vov.backend[j, i] = typemax(eltype(vov.backend))
178184
end
179185
end
180186

187+
# Now we can sort full columns.
188+
# Note that this will forward to highly optimized sorting functions on GPUs.
189+
# It currently does not work on Metal.
181190
sort!(vov.backend, dims = 1)
182191

183192
return vov

0 commit comments

Comments
 (0)