Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions clang/include/clang/Driver/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,13 @@ class Driver {
/// @name Helper Methods
/// @{

/// Utility function to parse all devices passed via -fsycl-targets.
/// Return 'true' for JIT, AOT Intel CPU/GPUs and NVidia/AMD targets.
/// Otherwise return 'false'.
bool
GetUseNewOffloadDriverForSYCLOffload(Compilation &C,
const llvm::opt::ArgList &Args) const;

/// getSYCLDeviceTriple - Returns the SYCL device triple for the
/// specified subarch
// TODO: Additional Arg input parameter is for diagnostic output information
Expand Down
37 changes: 32 additions & 5 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,33 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt) {
}
}

/// Utility function to parse all devices passed via -fsycl-targets.
/// Return 'true' for JIT, AOT Intel CPU/GPUs and NVidia/AMD targets.
/// Otherwise return 'false'.
bool Driver::GetUseNewOffloadDriverForSYCLOffload(Compilation &C,
const ArgList &Args) const {
// Check only if enabled with -fsycl
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Check only if enabled with -fsycl
// Check only if enabled with -fsycl.

Copy link
Contributor Author

@YixingZhang007 YixingZhang007 Oct 28, 2025

Choose a reason for hiding this comment

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

Thank you for your suggestions! The changes for enabling the new offloading model in this PR were copied directly from another PR (#15121). This PR specifically focuses on resolving test failures in fp64-conv-emu-1.cpp and fp64-conv-emu-2.cpp that occur after enabling the new offloading model. I will move any comments related to the new offloading model changes to the original PR where that functionality was implemented. The changes related to enabling the new offloading model have been reverted and removed from this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, I'm good with keeping it as is for this PR, but we can follow up on a subsequent PR to address this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For sure! I guess I will add these comments to PR #15121, which contains changes for enabling the new offloading model as the default. These changes will be applied when we reopen the PR after all SYCL E2E test issues have been resolved.

if (!Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false))
return false;

if (Args.hasFlag(options::OPT_no_offload_new_driver,
options::OPT_offload_new_driver, false))
return false;

if (Args.hasArg(options::OPT_fintelfpga))
Copy link
Contributor

Choose a reason for hiding this comment

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

Support for FPGA related options have been removed in this PR.
Don't think this check is necessary.

Copy link
Contributor Author

@YixingZhang007 YixingZhang007 Oct 28, 2025

Choose a reason for hiding this comment

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

Thank you for your suggestions! The changes for enabling the new offloading model in this PR were copied directly from another PR (#15121). This PR specifically focuses on resolving test failures in fp64-conv-emu-1.cpp and fp64-conv-emu-2.cpp that occur after enabling the new offloading model. I will move any comments related to the new offloading model changes to the original PR where that functionality was implemented. The changes related to enabling the new offloading model have been reverted and removed from this PR.

return false;

if (const Arg *A = Args.getLastArg(options::OPT_fsycl_targets_EQ)) {
for (const char *Val : A->getValues()) {
llvm::Triple TT(C.getDriver().getSYCLDeviceTriple(Val));
if ((!TT.isSPIROrSPIRV()) || TT.isSPIRAOT())
return false;
}
}
return true;
}


bool Driver::readConfigFile(StringRef FileName,
llvm::cl::ExpansionContext &ExpCtx) {
// Try opening the given file.
Expand Down Expand Up @@ -2186,11 +2213,10 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
// Use new offloading path for OpenMP. This is disabled as the SYCL
// offloading path is not properly setup to use the updated device linking
// scheme.
if ((C->isOffloadingHostKind(Action::OFK_OpenMP) &&
TranslatedArgs->hasFlag(options::OPT_fopenmp_new_driver,
options::OPT_no_offload_new_driver, true)) ||
if (C->isOffloadingHostKind(Action::OFK_OpenMP) ||
TranslatedArgs->hasFlag(options::OPT_offload_new_driver,
options::OPT_no_offload_new_driver, false))
options::OPT_no_offload_new_driver, false) ||
GetUseNewOffloadDriverForSYCLOffload(*C, *TranslatedArgs))
setUseNewOffloadingDriver();

// Construct the list of abstract actions to perform for this compilation. On
Expand Down Expand Up @@ -7080,7 +7106,8 @@ void Driver::BuildDefaultActions(Compilation &C, DerivedArgList &Args,
options::OPT_fno_offload_via_llvm, false) ||
Args.hasFlag(options::OPT_offload_new_driver,
options::OPT_no_offload_new_driver,
C.isOffloadingHostKind(Action::OFK_Cuda));
C.isOffloadingHostKind(Action::OFK_Cuda)) ||
GetUseNewOffloadDriverForSYCLOffload(C, Args);

bool HIPNoRDC =
C.isOffloadingHostKind(Action::OFK_HIP) &&
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5289,7 +5289,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
(JA.isHostOffloading(C.getActiveOffloadKinds()) &&
Args.hasFlag(options::OPT_offload_new_driver,
options::OPT_no_offload_new_driver,
C.isOffloadingHostKind(Action::OFK_Cuda)));
C.isOffloadingHostKind(Action::OFK_Cuda))) ||
(JA.isHostOffloading(Action::OFK_SYCL) &&
C.getDriver().GetUseNewOffloadDriverForSYCLOffload(C, Args));

bool IsRDCMode =
Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, IsSYCL);
Expand Down
16 changes: 11 additions & 5 deletions clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,14 +955,20 @@ static void addBackendOptions(const ArgList &Args,
// in any of them.
auto [BeforeOptions, AfterOptions] = OptC.split("-options ");
// Only add if not empty, an empty arg can lead to ocloc errors.
if (!BeforeOptions.empty())
CmdArgs.push_back(BeforeOptions);
if (!BeforeOptions.empty()){
SmallVector<StringRef, 8> BeforeArgs;
Copy link
Contributor

Choose a reason for hiding this comment

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

also just wondering, i see one of your commits is titled says 'revert nick's PR' but i don't remember writing that code so if it is referring to me do you mind linking the PR being reverted, 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.

Absolutely! I previously applied the changes directly from your PR #15121 (this PR is currently closed) to enable the new offloading model and verify the CI test results. After confirming that both fp64-conv-emu-1.cpp and fp64-conv-emu-2.cpp passed in CI with the new offloading model enabled, I reverted the changes. If my understanding is correct, I think we would enable the new offloading model changes after the other SYCL E2E test failures are resolved.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe, resolving all SYCL E2E test failures with new offloading model is necessary to enable new model by default, but it is not the only condition.
I think as soon as SYCL E2E pass, we want to enable regular testing (pre-commit? post-commit? nightly?) with new offloading model to make sure no regressions.
Or we might want to even enable it now and mark not-passing tests as XFAIL.
Thoughts?

Copy link
Contributor

@sarnex sarnex Oct 29, 2025

Choose a reason for hiding this comment

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

I would say we should add it to the nightly, but yeah IMO we can do it now if someone has bandwidth do to it. i definitely do not but im happy to help. We need the job to pass though, so we ideally would have a LIT variable so we can XFAIL the failing ones, or more crudely we coukd have some file with a list of either passing or failing tests, in that case we could use LIT_FILTER or LIT_FILTER_OUT

btw that pr isn't from me but doesnt matter either way :P

Copy link
Contributor

Choose a reason for hiding this comment

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

I will ask someone to add it to nightly. I think we should do it similar to how spirv_backend is being tested, likely with a LIT variable.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1.

BeforeOptions.split(BeforeArgs, " ", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
for (auto string : BeforeArgs) {
CmdArgs.push_back(string);
}
}
if (!AfterOptions.empty()) {
// Separator not included by the split function, so explicitly added here.
CmdArgs.push_back("-options");
std::string Replace = AfterOptions.str();
std::replace(Replace.begin(), Replace.end(), ' ', ',');
CmdArgs.push_back(Args.MakeArgString(Replace));
SmallVector<StringRef, 8> AfterArgs;
AfterOptions.split(AfterArgs, " ", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
std::string JoinedOptions = llvm::join(AfterArgs, " ");
CmdArgs.push_back(Args.MakeArgString(JoinedOptions));
}
}
StringRef OptL =
Expand Down
3 changes: 3 additions & 0 deletions sycl/test-e2e/OptionalKernelFeatures/fp64-conv-emu-1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg2_g10,intel_gpu_dg2_g11,intel_gpu_dg2_g12,intel_gpu_pvc,intel_gpu_mtl_h,intel_gpu_mtl_u -fsycl-fp64-conv-emu %O0 %s -o %t.out
// RUN: %{run} %t.out

// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg2_g10,intel_gpu_dg2_g11,intel_gpu_dg2_g12,intel_gpu_pvc,intel_gpu_mtl_h,intel_gpu_mtl_u -fsycl-fp64-conv-emu --offload-new-driver %O0 %s -o %t.out
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we also try with -g? The code you're changing used to have issues with -g, so just to be on the safe side.

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 changes work with '-g' and I have also added a new test command in this file for running the test with -g. Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

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

continue my previous comment: we can keep -g test, but just removing --offload-new-driver.

Copy link
Contributor Author

@YixingZhang007 YixingZhang007 Oct 30, 2025

Choose a reason for hiding this comment

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

Thank you for your suggestion!
This test is currently testing three cases:

  1. old offloading model
  2. new offloading model
  3. new offloading model and -g

Do you mean that we should replace the third case to be "old offloading model and -g"?

Copy link
Contributor

@YuriPlyakhin YuriPlyakhin Oct 30, 2025

Choose a reason for hiding this comment

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

Original test was testing 1 case:

  1. default offloading model

I suggest to add one more case, so result will be:

  1. default offloading model
  2. default offloading model and -g

We should not distinguish between new and old offloading model in this test. Instead, we should just add new entire SYCL E2E testing with new offloading model enabled by option for all tests and of course it should be separate PR.

If you still have questions, feel free to ping me in teams and we can discuss.

Copy link
Contributor

Choose a reason for hiding this comment

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

Following up on this: there is a specific directory for New Offloading Model tests: https://github.com/intel/llvm/blob/sycl/sycl/test-e2e/NewOffloadDriver/

Everything related to the New Offloading Model should go there, I think. Also, I agree that this can be done in a separate PR.

Copy link
Contributor

@YuriPlyakhin YuriPlyakhin Oct 31, 2025

Choose a reason for hiding this comment

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

My point was that instead of adding individual tests for new offloading model duplicating old offloading model tests, we should just start running entire SYCL E2E with new offloading model enabled.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but while we do that, if we need to add individual tests, they should go to the specific directory. Once we start running entire SYCL E2E with new offloading model, we can drop the specific directory, I think.

// RUN: %{run} %t.out

// Tests that aspect::fp64 is not emitted correctly when -fsycl-fp64-conv-emu
// flag is used.

Expand Down
Loading