Skip to content
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

Merged
merged 4 commits into from
Jun 13, 2024

Conversation

mdtoguchi
Copy link
Contributor

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.
@mdtoguchi mdtoguchi requested a review from a team as a code owner June 12, 2024 17:42
bool DeviceSeen = false;
StringRef DeviceArg;
for (StringRef ArgString : TargetArgs) {
// Look for -device <string> and use that as the known arch to
Copy link
Contributor

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

Copy link
Contributor Author

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.

// Capture the argument for '-device'
bool DeviceSeen = false;
StringRef DeviceArg;
for (StringRef ArgString : TargetArgs) {
Copy link
Contributor

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;
}

Copy link
Contributor Author

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.

Copy link
Contributor

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];.

Copy link
Contributor

@asudarsa asudarsa left a 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

Copy link
Contributor

@asudarsa asudarsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks much.

@mdtoguchi
Copy link
Contributor Author

@intel/llvm-gatekeepers, could this PR be merged? thanks!

@sarnex sarnex merged commit f9fd95e into intel:sycl Jun 13, 2024
14 checks passed
ianayl pushed a commit to ianayl/sycl that referenced this pull request Jun 13, 2024
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants