-
Notifications
You must be signed in to change notification settings - Fork 54
Fix linking of external code from callees #137
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
The original linking implementation for linkable code in device declarations did not consider calls inside callees; this change recurses through the typing to find all calls requiring linkable code.
numba_cuda/numba/cuda/dispatcher.py
Outdated
| # The typemap of the function includes calls, so we can traverse it to find | ||
| # the references we need. | ||
| for name, v in cres.fndesc.typemap.items(): | ||
|
|
||
| # CUDADispatchers represent a call to a device function, so we need to | ||
| # look up the linkable code for those recursively. | ||
| if isinstance(v, cuda_types.CUDADispatcher): | ||
| # We need to locate the signature of the call so we can find the | ||
| # correct overload. | ||
| for call, sig in cres.fndesc.calltypes.items(): | ||
| if isinstance(call, ir.Expr) and call.op == 'call': | ||
| # There will likely be multiple calls in the typemap; we | ||
| # can uniquely identify the relevant one using its SSA | ||
| # name. | ||
| if call.func.name == name: | ||
| called_cres = v.dispatcher.overloads[sig.args] | ||
| called_link_objects = get_cres_link_objects(called_cres) | ||
| link_objects.update(called_link_objects) |
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.
This is cool. I learnt a few things by reading through this section. Do you think the below simplifies the code and reduces the code complexity for a little bit?
I made a PR here:
gmarkall#4
I think this reduces the size of the list for both of the nested for-loop. This is proportional to O(num_calls^2), not O(num_typings^2)
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.
Thanks - I've incorporated your changes. I don't think there's much of a performance impact (the number of calls and typings won't be that large), but I think your modifications improved the readability of the code.
isVoid
left a comment
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.
lgtm
- Fix linking of external code from callees (NVIDIA#137) - Try using a newer branch workflow (NVIDIA#148) - Move publish step out of `wheels-build.yaml` (NVIDIA#147) - Upload wheels to PyPI from GitHub-hosted runner (NVIDIA#142) - Add paddle to interoperability chapter (NVIDIA#144) - Fix the debug info of GridGroup type (NVIDIA#131) - Remove dead `prepare_cuda_kernel()` (NVIDIA#130) - Add a CUDA DI Builder (NVIDIA#104) - dont launch extra kernels when stats counting is disabled (NVIDIA#127) - Fixup debug metadata in kernel fixup (NVIDIA#97) - Implement debuginfo bool name fix (numba/numba#9888) in numba-cuda (NVIDIA#106)
- Fix linking of external code from callees (#137) - Try using a newer branch workflow (#148) - Move publish step out of `wheels-build.yaml` (#147) - Upload wheels to PyPI from GitHub-hosted runner (#142) - Add paddle to interoperability chapter (#144) - Fix the debug info of GridGroup type (#131) - Remove dead `prepare_cuda_kernel()` (#130) - Add a CUDA DI Builder (#104) - dont launch extra kernels when stats counting is disabled (#127) - Fixup debug metadata in kernel fixup (#97) - Implement debuginfo bool name fix (numba/numba#9888) in numba-cuda (#106)
The original linking implementation for linkable code in device declarations did not consider calls inside callees; this change recurses through the typing to find all calls requiring linkable code.