-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
RFC: CodegenHooks for external language implementations #19290
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
Conversation
051a17d
to
228aa19
Compare
argv[0] = hook; | ||
for (int i = 0; i < N; i++) | ||
argv[i+1] = args[i]; | ||
jl_apply(argv, N+1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to be adding calls to the runtime system inside codegen. It should actually be OK, since we aren't going to be adding this the result to the JIT, but we should make sure that the interface enforces that you can't add a function to the JIT that has been generated via a hook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a check to compile_linfo
:
if (params != &jl_default_cgparams /* fast path */ &&
!compare_cgparams(params, &jl_default_cgparams) && params->cached)
jl_error("functions compiled with custom codegen params mustn't be cached");
4bc043f
to
9673821
Compare
2d7bb5a
to
f3ccae6
Compare
Bump - should we merge this? Would be nice to have CUDANative.jl on master. |
I just started working on this again, needs some love after #19416. I'll finish this up before the end of the week. |
f3ccae6
to
cf0c67b
Compare
Should be good to go, unless somebody has some comments / ideas for improvements. |
@nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels |
lgtm. I would like to merge on top of #17057 though, since there's going to be a trivial conflict with the |
cf0c67b
to
18b6a06
Compare
The error on i686 looks like a timeout so I restarted the build (backup of the log at https://gist.github.com/vchuravy/adaae760b733b513535fc5e047d31256) |
Yeah should be good to go. Let me do a final rebase + CI, and merge if that turns out good. |
18b6a06
to
0607ae0
Compare
Yeah! 🎆 🍾 |
Epic. |
Summary: extends the codegen parameters from #19046, adding a
hooks
struct for users to put callback routines in. If any of the hooks is set, the compiler will call said method instead of emitting code. By using a package like LLVM.jl, those callback routines can then emit code themselves.See here for example use of this functionality.
Similar to the codegen hooks, this functionality might not be top-notch yet, but I'd prefer to be developing on top of master instead of maintaining my own forks. I'll keep on improving this interface, figuring out exactly which hooks are important, and what the parameters should be (eg. how much of
jl_codectx_t
should be exposed?). Tests and proper documentation are to follow after that, I don't want to set anything in stone for now.Except for some patches to LLVM (and a bump to 3.9, see my tb/cuda branch), this is the last required part of functionality for CUDAnative.jl to work on vanilla master.
cc @vchuravy