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

speed regression with fast_callable #5616

Closed
robertwb opened this issue Mar 26, 2009 · 5 comments
Closed

speed regression with fast_callable #5616

robertwb opened this issue Mar 26, 2009 · 5 comments

Comments

@robertwb
Copy link
Contributor

Before (vanilla 3.4)

sage: var('x,y')
(x, y)
sage: time P = parametric_plot3d((x, y, x*y), (x, -10, 10), (y, -10, 10), plot_points=(500,500))
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00 s
sage: time P.triangulate()
CPU times: user 0.06 s, sys: 0.02 s, total: 0.08 s
Wall time: 0.08 s

after (3.4 + #5093)

sage: sage: var('x,y')
(x, y)
sage: sage: time P = parametric_plot3d((x, y, x*y), (x, -10, 10), (y, -10, 10), plot_points=(500,500))
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00 s
sage: sage: time P.triangulate()
CPU times: user 0.28 s, sys: 0.02 s, total: 0.30 s
Wall time: 0.30 s

I think this is due to there not being an interface to evaluate fast_callable objects without passing through Python. Perhaps a

cdef int call_c(void* args, void* ret) except -1

method should be attached to the generic interpreter wrapper class (to be overridden by the subclasses), and those with specific knowledge about the various implementations could then use this interface (e.g. RDF passes double*).

Component: basic arithmetic

Issue created by migration from https://trac.sagemath.org/ticket/5616

@sagetrac-cwitty
Copy link
Mannequin

sagetrac-cwitty mannequin commented Mar 28, 2009

Attachment: trac5616-fast-callable-gen-pxd.patch.gz

@sagetrac-cwitty
Copy link
Mannequin

sagetrac-cwitty mannequin commented Mar 28, 2009

@sagetrac-cwitty
Copy link
Mannequin

sagetrac-cwitty mannequin commented Mar 28, 2009

comment:1

The attached patches should fix this problem. (Apply both patches, in order.)

I split the fix into two logically separate pieces. The first only generates .pxd files for the fast_callable interpreters; this should have no observable effect. The second adds a .call_c() cdef method to the interpreters. (Each interpreter has its own call_c, rather than inheriting a common method as Robert suggested; I did it this way because I like typechecking.)

The second patch also modifies parametric_surface.pyx to take advantage of the call_c() method when generating the surface. I left the old code in as well; this means you can benchmark fast_eval vs. fast_callable by setting sage.ext.fast_eval.new_fast_float to False/True.

These patches depend on #5622.

@sagetrac-cwitty sagetrac-cwitty mannequin changed the title speed regression with fast_callable [needs reivew] speed regression with fast_callable Mar 28, 2009
@sagetrac-cwitty sagetrac-cwitty mannequin modified the milestones: sage-3.4.2, sage-3.4.1 Mar 28, 2009
@robertwb
Copy link
Contributor Author

comment:2

Excellent. Yes, generating specific pxd files with typed call_c methods is a better way to go. Code is good and this completely resolves the issue.

@robertwb robertwb changed the title [needs reivew] speed regression with fast_callable [positive reivew] speed regression with fast_callable Mar 29, 2009
@robertwb robertwb changed the title [positive reivew] speed regression with fast_callable speed regression with fast_callable Mar 29, 2009
@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Mar 31, 2009

comment:4

Merged both patches in Sage 3.4.1.rc0.

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Mar 31, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant