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

Support for dynamic method overlays #2

Open
vchuravy opened this issue Apr 7, 2021 · 3 comments
Open

Support for dynamic method overlays #2

vchuravy opened this issue Apr 7, 2021 · 3 comments
Assignees

Comments

@vchuravy
Copy link

vchuravy commented Apr 7, 2021

IIRC the way Mixtape is currently doing overlays breaks with dynamic function calls, and thus is not dynamically correct.

  1. Case function passed as arguemt
f(func, args...) = func(args...)
  1. Case function not inferrable
function f(x)
   g = rand() < 0.5 ? sin : cos
   g(x)
end

The way to fix this (I realized this morning) is to replace all f(args...) with lookup_in_ctx(Ctx, f)(args...) and then writing an inference rule that turns lookup_in_ctx(Ctx, f) into the result of the overlay table. Ctx should be the type and you shan't be allowed to make runtime decisions.

@femtomc
Copy link
Member

femtomc commented Apr 7, 2021

@vchuravy this appears to work -- tell me what I'm misunderstanding tho

Re (in reference to IIRC) old architecture: I recently changed it to use a much different perspective.

@vchuravy
Copy link
Author

Just talked with @aviatesk about this. One would want to pass a context_function in https://github.com/JuliaGPU/GPUCompiler.jl/blob/6301d4155bad9fe7eb4d161cc1ab2ff43c4659b5/src/jlgen.jl#L356

which will turn every apply_generic into context_function(f, args...). And then one can re-enter mixtape from there.

@aviatesk aviatesk self-assigned this Feb 28, 2022
@femtomc
Copy link
Member

femtomc commented Feb 28, 2022

@vchuravy should this functionality (Mixtape) even live externally from GPUCompiler?

The reason why I ask this is because of AbsInt composition issues outside of native pipeline -- here this is a package with another interpreter (which prevents, I presume, usage of Mixtape and Enzyme, or Mixtape and JET).

And regarding Tom's recent PR: tshort/StaticCompiler.jl#69 I wonder if putting it somewhere close to GPUCompiler is a better idea.

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

3 participants