-
Notifications
You must be signed in to change notification settings - Fork 18
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
Fix linking of external code from callees #137
base: main
Are you sure you want to change the base?
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.
# 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)
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.