Open xukai92 opened 5 years ago
PS: the GPU support of pairwise
is based the branch of this PR https://github.com/JuliaStats/Distances.jl/pull/142
pairwise
uses an explicit loop, while your implementation calls higher-level implementations like *
and broadcast
. I guess these are optimized for CUDA. Not sure what to do about this, since 1) pairwise
works for many distances, some of which might not be rewritten using high-level operations and 2) Distances.jl shouldn't depend on CuArrays. Maybe we can add special methods once optional dependencies are supported in Julia.
Maybe we can add special methods once optional dependencies are supported in Julia.
I think Requires.jl
provides this feature?
Requires.jl makes loading this package 20x slower (https://github.com/JuliaStats/Distances.jl/pull/123#issuecomment-466438344).
Requires.jl makes loading this package 20x slower
Technically, it's Tables.jl. In my laptop, Requires.jl slows loading this package by 4-6x
# with Requires.jl
julia> @time using Distances
0.276511 seconds (403.27 k allocations: 21.736 MiB, 6.36% gc time)
# without Requires.jl
julia> @time using Distances
0.063862 seconds (63.23 k allocations: 3.801 MiB)
But Requires.jl
is still a heavy dependency compared to Distances.jl
. I guess what we can possibly do now is to create a larger package CudaDistances.jl
, accelerate codes for CuArray
, and reexport Distances.jl
in that package.
One solution to this would be to choose the best algorithm based on traits like those provided by ArrayInterface.
I found the
pairwise
withSqEuclidean
is faster than my own implementation on CPU but slower on GPU. Any idea why and possible optimization on Distances.jl side?MWE: