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

Pass -foffload-lto instead of -flto for cuda/hip kernels in clangLinkerWrapper #16605

Merged

Conversation

omarahmed1111
Copy link
Contributor

ClangLinkerWrapper tool in one of its clang commands to generate ptx kernel binary from llvm bitcode kernel was using -flto option which should be only used for cpu code not gpu kernel code. This PR fixes that by changing that to -foffload-lto for cuda/hip kernels.

This fixes 16413 issue.

@omarahmed1111 omarahmed1111 force-pushed the fix-NewOffloadDrivers-failed-tests branch from 633d90b to ccf221a Compare January 13, 2025 17:26
@omarahmed1111 omarahmed1111 marked this pull request as ready for review January 13, 2025 21:56
@omarahmed1111 omarahmed1111 requested review from a team as code owners January 13, 2025 21:56
for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm))
CmdArgs.append(
{"-Xlinker",
Args.MakeArgString("--plugin-opt=" + StringRef(Arg->getValue()))});

if (Triple.isNVPTX() || Triple.isAMDGPU()) {
CmdArgs.push_back("-foffload-lto");
Copy link
Contributor

Choose a reason for hiding this comment

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

should this go upstream?

Copy link
Contributor

@asudarsa asudarsa Jan 14, 2025

Choose a reason for hiding this comment

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

+1 on adding this change to upstream code. I am also wondering why it is not an issue in the upstream compiler and why we see it only with SYCL offloading.

Also @omarahmed1111 can you please comment on the test failure?

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.

The test failure for loop_extended is a flaky failure not related to this PR, the failed test disabled on this PR: #16612 . I updated the PR, so should be solved now.

for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm))
CmdArgs.append(
{"-Xlinker",
Args.MakeArgString("--plugin-opt=" + StringRef(Arg->getValue()))});

if (Triple.isNVPTX() || Triple.isAMDGPU()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is there an upstream pr for this based on previous feedback?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought we are going to do this after merging this. I will open one for that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok as long as you'll make an upstream PR lgtm to merge here first

Copy link
Contributor

@sarnex sarnex left a comment

Choose a reason for hiding this comment

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

lgtm assuming future upstream pr

@omarahmed1111
Copy link
Contributor Author

@intel/llvm-gatekeepers please merge, Thanks!

@martygrant martygrant merged commit 11a73e7 into intel:sycl Jan 29, 2025
17 checks passed
@omarahmed1111
Copy link
Contributor Author

@sarnex llvm upstream PR: llvm/llvm-project#125243

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.

3 NewOffloadDriver tests failing on CUDA
5 participants