File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments