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

Is there a way to bail out of overdubbing? #180

Closed
marius311 opened this issue Nov 18, 2020 · 2 comments
Closed

Is there a way to bail out of overdubbing? #180

marius311 opened this issue Nov 18, 2020 · 2 comments

Comments

@marius311
Copy link

marius311 commented Nov 18, 2020

I'd love to use Cassette to do some nifty things with my code but just a no-op overdub already makes it run 10x slower (probably stuff related to #91). My gut feeling (could well be wrong) is that if I could bail out of overdubbing before I get to the very bottom of my call tree, I can still do everything I want with the high-level function calls but not take the overhead. Is there any mechanism to do this, or would it even work? I'm thinking something like prehook could return a boolean of whether to actually overdub the expression, and if it was false, it would just call the original function.

@vchuravy
Copy link
Member

Since Cassette is the land of endless possibilty variants of that are indeed possible. You can write a bespoke pass that inserts Expr(:nooverdub, ...) around the arguments to call.

https://github.com/JuliaGPU/KernelAbstractions.jl/blob/17469f21826970e4ff14a938e16159c2fb1df524/src/compiler/pass.jl#L66

Now what condition you want to have for that is up to you and depends on what you need to do.

@marius311
Copy link
Author

Thanks, that's interesting. Another option I've found is basically what AutoPreallocation.jl does, just define a no-op overdub at the point you want to stop: https://github.com/oxinabox/AutoPreallocation.jl/blob/1013ac618749ac3bd3534162cb6c176e4c6d19bf/src/inference_fixes.jl#L3-L22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants