-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate manually vectorized methods in favor of dot syntax, monolithic edition #19791
Conversation
@@ -1,4 +1,4 @@ | |||
# This file is a part of Julia. License is MIT: http://julialang.org/license | |||
<# This file is a part of Julia. License is MIT: http://julialang.org/license |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Top-of-file gremlin strikes again. Fixed. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#19721 also means rebase needed for end-of-deprecated.jl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased. Thanks!
c813e37
to
0ae0262
Compare
@@ -1405,7 +1405,6 @@ conj!(A::SparseMatrixCSC) = (broadcast!(conj, A.nzval, A.nzval); A) | |||
|
|||
# TODO: The following definitions should be deprecated. | |||
ceil{To}(::Type{To}, A::SparseMatrixCSC) = ceil.(To, A) | |||
floor{To}(::Type{To}, A::SparseMatrixCSC) = floor.(To, A) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had this been missing a To<:Integer
constraint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on how you interpret the docstring? floor(T, x) converts the result to type T, throwing an InexactError if the value is not representable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing vectorized methods on a lot of these rounding functions were a bit inconsistent on whether or not they constrained the type argument to Integer subtypes. Is that just a matter of when you want your MethodError, or does it make a real difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I thought perhaps the docstring implies that e.g. floor(Float32, 1.7) == 1.0f0
should yield true
(though floor(Float32, 1.7)
presently fails), and hence the absence of <:Integer
constraints. Or is the docstring itself too loose? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dunno, but I guess the deprecations may as well leave off the Integer constraint and hand off the problem to the scalar method, seems safer than an incomplete deprecation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good :).
This will likely show big regressions for any of the benchmarks that are using now-deprecated syntax. I'm more curious about whether it shows any medium regressions for any refactorings of the internals here that might be using different code paths than they used to be: @nanosoldier (also question for @jrevels, does nanosoldier use a different branch of basebenchmarks for testing against different branches of Julia?) |
|
…c functions in favor of compact broadcast syntax.
…x over SparseMatrixCSCs with similar tests of sparse map.
Fixed the ambiguities introduced by rebasing post #19690-merge (and in the appropriate commits). With benefit of #19690, added a separate commit that removes a few vectorized methods over |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels |
That's less change than I expected. string join is often noisy, but |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed my own review comments in Sacha0#1 - any perf regressions can hopefully be fixed after feature freeze
Your benchmark job has completed - no performance regressions were detected. A full report can be found here. cc @jrevels |
This is such a conflict-magnet that I'm going to merge now and open my trivial little PR against master instead. Almost all of the pieces of this have been open for weeks/months. |
No, all versions of Julia benchmark against the |
Tony, you're amazing. Do you ever sleep, or instead just recover in blocks of hypnagogic PR review? Thanks for your tremendous efforts! |
Likewise. I doubt generic sparse broadcast matches the performance of specializations like that. Making a note to benchmark this case when time allows. Thanks! |
Going from the old manually vectorized method of the 2-arg variant of Before this PR (manually vectorized method): julia> versioninfo()
Julia Version 0.6.0-dev.1843
Commit c38a5a304 (2017-01-01 14:09 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: Intel(R) Core(TM) i7-4700MQ CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
julia> using BenchmarkTools
julia> const arr = collect(0.0:0.1:10.0);
julia> @benchmark trunc(Int, arr)
BenchmarkTools.Trial:
memory estimate: 912.00 bytes
allocs estimate: 2
--------------
minimum time: 289.054 ns (0.00% GC)
median time: 301.209 ns (0.00% GC)
mean time: 354.579 ns (13.37% GC)
maximum time: 5.139 μs (93.19% GC)
--------------
samples: 10000
evals/sample: 278
time tolerance: 5.00%
memory tolerance: 1.00% after the PR (dot syntax): julia> versioninfo()
Julia Version 0.6.0-dev.1807
Commit 26c8d856a (2016-12-31 04:12 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: Intel(R) Core(TM) i7-4700MQ CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
julia> using BenchmarkTools
julia> const arr = collect(0.0:0.1:10.0);
julia> @benchmark trunc.(Int, arr)
BenchmarkTools.Trial:
memory estimate: 2.56 kb
allocs estimate: 108
--------------
minimum time: 28.058 μs (0.00% GC)
median time: 28.583 μs (0.00% GC)
mean time: 29.254 μs (0.00% GC)
maximum time: 70.405 μs (0.00% GC)
--------------
samples: 10000
evals/sample: 1
time tolerance: 5.00%
memory tolerance: 1.00% Can someone please confirm? |
Make sure to not benchmark in global scope or use |
Thanks, I updated my benchmarks with the use of |
We somehow didn't see this in any tests, but ref https://discourse.julialang.org/t/is-0-a-1-going-away/1313/2 - chained comparisons like |
It should be equivalent to the former behavior if we made it use |
@tkelman, generic sparse julia> using BenchmarkTools
julia> begin
vecabs(v::SparseVector) = SparseVector(v.n, copy(v.nzind), abs.(v.nzval))
xs = sprand(10^2, 0.2);
ds = @benchmark abs.($xs);
vs = @benchmark vecabs($xs);
println(judge(median(ds), median(vs)))
xm = sprand(10^4, 0.1);
dm = @benchmark abs.($xm);
vm = @benchmark vecabs($xm);
println(judge(median(dm), median(vm)))
xl = sprand(10^6, 0.1);
dl = @benchmark abs.($xl);
vl = @benchmark vecabs($xl);
println(judge(median(dl), median(vl)))
end
BenchmarkTools.TrialJudgement:
time: +44.44% => regression (5.00% tolerance)
memory: +0.00% => invariant (1.00% tolerance)
BenchmarkTools.TrialJudgement:
time: +43.54% => regression (5.00% tolerance)
memory: +0.00% => invariant (1.00% tolerance)
BenchmarkTools.TrialJudgement:
time: +27.62% => regression (5.00% tolerance)
memory: +0.00% => invariant (1.00% tolerance) Eking out a bit more performance might be possible (e.g. with a few |
Cool. I'd add the one line of code specialization (despite the fact it'll be circumvented in fusing cases) if cleverer tweaks to the general case can't get within 10-20ish percent, but it's not that bad. |
Note that the above comparison isn't apples-to-apples: sparse |
This pull request deprecates almost all remaining manually vectorized methods, incorporating #19713, #19710, #19709, #18609, #18608, #18607, #18593, #18590, #18586, #18576, #18575, #18571, #18564, and #18512 into a single pull request. The last commit reinstates a few
&
,|
, andxor
methods overBitArray
s asbroadcast
specializations (in accord with discussion in the corresponding pull requests).(I dropped #19712 from this set: #19712 turned out to need a fair bit more work and touches a lot of code. Best done as a separate pull request if consensus favors deprecating those methods (two-arg vectorized
complex
); I might be able to put that together tomorrow if so.)Best!