-
-
Notifications
You must be signed in to change notification settings - Fork 15
Closed
Description
Hi,
It seems as PrecompileTools does not "work" in the following case. By that I mean that compilatiin still hqppen before running the function. Please see below:
module MSort
using PrecompileTools
function quicksort(
v::Vector{T};
lo::Int = 1,
hi::Int = length(v),
) where {T <: Union{Int64, Float64}}
x = copy(v)
quick!(x, lo, hi)
x
end
function partition(
xp::Vector{T},
pivot::T,
left::Int,
right::Int,
) where {T <: Union{Int64, Float64}}
while left <= right
while xp[left] < pivot
left += 1
end
while pivot < xp[right]
right -= 1
end
if left <= right
xp[left], xp[right] = xp[right], xp[left]
left += 1
right -= 1
end
end
left, right
end
function quick!(
xp::Vector{T},
i::Int,
j::Int,
) where {T <: Union{Int64, Float64}}
if j > i
left, right = partition(xp, xp[(j+i)>>>1], i, j)
quick!(xp, i, right)
quick!(xp, left, j)
end
end
@setup_workload begin
@compile_workload begin
quicksort(rand(64))
end
end
end
x = rand(64); @time Msort.quicksort(x);
# 0.004929 seconds (29 allocations: 2.047 KiB, 99.56% compilation time)
However if I replace Vector{T}
by Vector{Float64}
, and remove all T
in the code, then it works.
Is that expected that compilation happen in the first version ?
If yes, could we have PrecompileTools work with parametric type? If no, I suppose it is a bug?
Thank you
Metadata
Metadata
Assignees
Labels
No labels