Skip to content
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 nextpow2/prevpow2 #28304

Merged
merged 1 commit into from
Jul 31, 2018
Merged

Deprecate nextpow2/prevpow2 #28304

merged 1 commit into from
Jul 31, 2018

Conversation

Keno
Copy link
Member

@Keno Keno commented Jul 27, 2018

Base 2 is an important special case here, but we can just handle that
as a special case in the implementation of nextpow rather than
having a whole separate user facing function.

Note: Done against kf/squeeze, since otherwise NEWS.md conflicts unnecessarily. Merge that one before this and all will be fine.

@Keno
Copy link
Member Author

Keno commented Jul 27, 2018

just to be sure

@nanosoldier runbenchmarks(ALL, vs=":master")

@Keno
Copy link
Member Author

Keno commented Jul 27, 2018

Actually, that's stupid. There'll be a performance regression until the caller upgrade because deprecations are expensive. Is there a command to cancel nanosoldier?

@@ -297,7 +297,6 @@ export
muladd,
nextfloat,
nextpow,
nextpow2,
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also prevpow2?

@JeffBezanson
Copy link
Sponsor Member

I'm fine with these but we might also want to consider nextpower and prevpower. We also have powermod. Then there is ispow2, but there's no general version so it's a bit of an outlier.

@ararslan
Copy link
Member

ararslan commented Jul 27, 2018

Is there a command to cancel nanosoldier?

Yes, you can ping me and I'll ssh into the worker node and manually kill the process. 😛 (That only works well when only one job is running though, because Reasons™)

base/intfuncs.jl Outdated
# Special case fast path for Integer/Unsiged a == 2.
# This is a very common case. Constant prop will make sure that a call site
# specified as `nextpow(2, x)` will get this special case inlined.
a == 2 && (isa(x, Integer) || isa(x, Unsigned)) && return _nextpow2(x)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsigned <: Integer, so isn't this equivalent to just checking isa(x, Integer)?

@ararslan ararslan added maths Mathematical functions deprecation This change introduces or involves a deprecation labels Jul 27, 2018
@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@Keno Keno changed the base branch from kf/squeeze to master July 28, 2018 00:49
@Keno
Copy link
Member Author

Keno commented Jul 28, 2018

I'm fine with nextpower, but pow for power is of course traditional from libm. In any case, it's separate from this PR (though we should decide very soon of course).

base/intfuncs.jl Outdated
# Special case fast path for x::Integer, a == 2.
# This is a very common case. Constant prop will make sure that a call site
# specified as `nextpow(2, x)` will get this special case inlined.
a == 2 && isa(x, Integer) && return _nextpow2(x)
a <= 1 && throw(DomainError(a, "`a` must be greater than 1."))
x <= 0 && throw(DomainError(x, "`x` must be positive."))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this error check needs to come before the check for a == 2. That's causing the test failures, since _nextpow2(x) won't throw a DomainError for x < 1.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which does present a problem though, because the old nextpow2 and prevpow2 functions did not throw an error for x == 0 and returned the next negative power of two for negative integers.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a marginal and debatable behavior that we could break. Or if it’s really useful, we could generalize it. But I suspect it’s not. Negative powers of two are in fact not powers of two at all.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just move the <= 0 check to the top for now; seems like the conservative thing to do.

Base 2 is an important special case here, but we can just handle that
as a special case in the implementation of `nextpow` rather than
having a whole separate user facing function.
@JeffBezanson JeffBezanson merged commit 1f52ab6 into master Jul 31, 2018
@JeffBezanson JeffBezanson deleted the kf/nextpow2 branch July 31, 2018 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation This change introduces or involves a deprecation maths Mathematical functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants