-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[TIR] Handle callees on same target, different codegen #14988
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
[TIR] Handle callees on same target, different codegen #14988
Conversation
|
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.
Generated by tvm-bot |
masahi
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.
Makes sense to me.
| Optional<Target> current_target_; | ||
| std::unordered_map<const GlobalVarNode*, KernelInfo> device_info_map_; | ||
| std::unordered_set<const GlobalVarNode*> device_kernel_launch_; | ||
| std::unordered_set<const GlobalVarNode*> extern_method_call_; |
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.
method -> func? Since we don't use that term.
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.
Good point, and renamed extern_method_call_ to extern_function_call_.
Prior to this commit, any caller that uses a different `Target` than
its callee is lowered to a device-kernel launch. However, if the
caller and callee are on the same device, despite using a different
target (e.g. `Target("llvm")` and `Target("c")` both use `kDLCPU`),
then the kernel launch is unnecessary.
This commit updates `LowerDeviceKernelLaunch` to produce a kernel
launch only when the callee is on another device, and to produce
`T.call_extern` for callees on the same device.
0f74875 to
922df81
Compare
* [TIR] Handle callees on same target, different codegen
Prior to this commit, any caller that uses a different `Target` than
its callee is lowered to a device-kernel launch. However, if the
caller and callee are on the same device, despite using a different
target (e.g. `Target("llvm")` and `Target("c")` both use `kDLCPU`),
then the kernel launch is unnecessary.
This commit updates `LowerDeviceKernelLaunch` to produce a kernel
launch only when the callee is on another device, and to produce
`T.call_extern` for callees on the same device.
* Rename "extern_method_call_" to "extern_function_call_"
Prior to this commit, any caller that uses a different
Targetthan its callee is lowered to a device-kernel launch. However, if the caller and callee are on the same device, despite using a different target (e.g.Target("llvm")andTarget("c")both usekDLCPU), then the kernel launch is unnecessary.This commit updates
LowerDeviceKernelLaunchto produce a kernel launch only when the callee is on another device, and to produceT.call_externfor callees on the same device.