-
-
Notifications
You must be signed in to change notification settings - Fork 488
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
rewrite fast_float to support more datatypes #5093
Comments
comment:1
This looks very interesting, and much further reaching than the original fast_float code I mostly wrote on a plane ride home from DC. Wish I had time to review it. |
Attachment: trac5093-fast-callable.patch.gz |
comment:3
OK, I've put up a new patch which I think is ready for review. The big feature here is support for multiple types -- we get accelerated evaluation over We're also typically somewhat faster than the old fast_float, but often not by a lot. (In the three benchmarks below, the speed gain ranges from 2% faster to more than 2x as fast.) There's still a lot of optimization I can do. Here are the benchmark details:
|
comment:8
Is anyone looking at reviewing this ticket? Lots of people are getting emailed about updates, so apparently there is interest :). I think it could probably benefit from more than one pair of eyes since it is a major rewrite of a very key piece of functionality. I might be able to look at at least some of it next week. Who's with me? :) |
comment:9
I'll be happy to help out too. Should we set a time to get together on IRC? |
comment:10
robertwb: would Monday morning work for you? |
comment:11
cwitty says that only the second patch should be applied. |
comment:12
#5413 also affects this ticket... |
comment:13
(I mean, should affect this patch.) |
comment:14
Sure, Monday morning would work for me (not too early though...) |
comment:15
I'm having troubles with the domain option:
Perhaps that loads/dumps string can help. |
comment:16
OK, this is due to a missing feature in fast_callable. I intended to fix things so that domain=... would not affect integral exponents (and actually documented this intention as fact), but didn't actually implement it. So the failure is caused from:
which happens because RIF exponentiation for an exponent that is not an Integer is based on .log()/.exp(), and .log() of a negative RIF is NaN. The two easy workarounds are:
(BTW, why do you have a multivariate polynomial ring in one variable?) |
comment:17
Shouldn't this work?
|
comment:18
For Jason Grout, the problems I'm having with types and zero:
|
comment:19
OK, I can't fix this so that fast_callable matches the behavior of multivariate polynomials while keeping my code generic, because Singular-based polynomials return values of their base_ring in this case and polydict polynomials return values with the same parent as their first argument (falling back to the base ring if the argument has no parent).
My plan is to use the former behavior for all multivariate polynomials, so it won't exactly match polydict polynomials; is that good enough? (That's much easier to implement.) |
comment:20
I've ready most of the patch, it looks really good, and works on all my examples. I'm still digesting it all... One comment I have is that
could have a better error. Something else that would be really nice is an option that uses a fast domain, if it's there, but ignores the domain parameter if it's not. For elements, we can use the |
comment:21
Something else that would be really nice is an option that uses a fast domain, if it's there, but ignores the domain parameter if it's not. Any suggestions for syntax for this? I'm coming up with things like (..., domain=RIF, ignore_domain_if_no_specialized_interpreter_exists=True), which seems cumbersome :) (I'm probably being too picky about being precise in my parameter names). I've vaguely planned to use The type(x)==type(generic_element) is a good idea. I'll implement it eventually. (Then if I could access the _parent field from C, probably almost all of the element interpreter slowdown would be gone; in conjunction with |
comment:22
I've attached a patch (fast-callable-cleanup.patch, to be applied after trac5093-fast-callable.patch) that fixes many of the issues raised, including everything I considered to be a serious bug. Fixed:
Not fixed:
I'm hoping the reviewers will agree that the unfixed issues can wait until later. |
Attachment: trac5093-fast-callable-cleanup.patch.gz |
comment:23
fast-callable-cleanup.patch had issues (I got confused from developing on two different machines, and based it on the wrong version). So I deleted it, and posted trac5093-fast-callable-cleanup.patch to replace it. (Thanks to Jason for pointing out the problem!) |
comment:24
With the cleanup patch, I am finding the following doctest error:
|
comment:25
I think your list of unfixed issues are fine postponing 'till later, though perhaps we should open followup tickets for them. |
Attachment: trac5093-fast-callable-api.patch.gz |
comment:26
One more patch (hopefully the last for this ticket). I changed my mind about whether to incorporate #5413-style deprecation; if I make sure the functionality is disabled at the start, then I don't have to worry about "deprecation" later. (And if we decide we actually do want some of this functionality, it can safely be added later without backward-compatibility worries.) This also hopefully fixes Nick's OSX doctest failure. |
comment:27
I agree with merging this now, and addressing the above list of unfixed things in other tickets. I give this positive review based on the following.
So with that, positive review! However, it'd be great if robertwb and ncalexan, at least, could give their approval. |
comment:28
okay, if at least one of robertwb or ncalexan also gives this a positive review, please change the title of the ticket to reflect it (unless you want further review) |
comment:29
I am of the same opinion--I have also read most of the code and tried a lot of things and it works great for me. Followup at #5572. |
comment:30
Late to the party, but I agree -- merge now. I have used it for computing Riemann theta functions and it works well for me. |
comment:31
cwitty: could you specify which patches to apply and in what order? |
comment:32
I've deleted the obsolete preliminary patch, so: apply all three posted patches, in the order posted. |
comment:33
Merged all three patches in Sage 3.4.1.alpha0. Cheers, Michael |
I've mentioned several times over the past months that I'm rewriting fast_float. Here's a preliminary patch, that shows the direction I'm taking (automatically generate interpreters for each type, by having Python code write C code).
This version replaces fast_float with the new code, and also adds a new entry point, fast_callable.
fast_callable(EXPR, domain=R)
(where EXPR is a symbolic expression or a polynomial) is essentially equivalent to evaluating EXPR with calls to R() at every node. There's special fast support for domain=RDF or domain=RealField(n), and there's slowish generic code that should work for arbitrary R.
The code is not ready for submission... there are very few doctests, and a lot of the documentation is simply wrong. But if anybody has any comments, I'd be happy to hear them.
CC: @robertwb @jasongrout @sagetrac-bober
Component: basic arithmetic
Issue created by migration from https://trac.sagemath.org/ticket/5093
The text was updated successfully, but these errors were encountered: