-
Notifications
You must be signed in to change notification settings - Fork 734
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
[Driver][SYCL][NewOffloadModel] Incorporate -device settings for GPU #14151
Conversation
One of the models that is used for specifying the device architecture for spir64_gen is to use the -Xsycl-target-backend "-device arg" syntax on the command line. Hook up the ability to scan the target backend values to embed the proper information in the packaged binary when using the new offload model.
clang/lib/Driver/Driver.cpp
Outdated
bool DeviceSeen = false; | ||
StringRef DeviceArg; | ||
for (StringRef ArgString : TargetArgs) { | ||
// Look for -device <string> and use that as the known arch to |
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.
Do we expect multiple entries here? If so, do we expect to honor the right most entry?
Also, can we please have a test case to cover this?
Thanks
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.
Typical usage is to not have multiple entries - but we need to make sure we have a behavior that covers it. I will add a test.
clang/lib/Driver/Driver.cpp
Outdated
// Capture the argument for '-device' | ||
bool DeviceSeen = false; | ||
StringRef DeviceArg; | ||
for (StringRef ArgString : TargetArgs) { |
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 can think of a few ways to optimize this.
for (int i = TargetArgs.size()-1; i >=0; --i)
if (TargetArgs[i] == "-device") {
Arch = TargetArgs[i+1];
break;
}
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 - I will update.
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.
for (int i = TargetArgs.size()-1; i >=0; --i)
It should be TargetArgs.size()-2
instead of TargetArgs.size()-1
to avoid potential out-of-bounds access in Arch = TargetArgs[i+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.
LGTM. A few minor suggestions. Thanks @mdtoguchi
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. Thanks much.
@intel/llvm-gatekeepers, could this PR be merged? thanks! |
…ntel#14151) One of the models that is used for specifying the device architecture for spir64_gen is to use the -Xsycl-target-backend "-device arg" syntax on the command line. Hook up the ability to scan the target backend values to embed the proper information in the packaged binary when using the new offload model.
One of the models that is used for specifying the device architecture for spir64_gen is to use the -Xsycl-target-backend "-device arg" syntax on the command line.
Hook up the ability to scan the target backend values to embed the proper information in the packaged binary when using the new offload model.