-
Couldn't load subscription status.
- Fork 793
[NewOffloadModel] Fix argument parsing in Clang Linker Wrapper #20470
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
base: sycl
Are you sure you want to change the base?
Changes from all commits
edae614
6340ea0
c7bb8d5
1708433
263ce30
f8a1c0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1556,6 +1556,32 @@ 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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| 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)) | ||||||
| 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. | ||||||
|
|
@@ -2186,11 +2212,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 | ||||||
|
|
@@ -7080,7 +7105,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) && | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -955,14 +955,21 @@ 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; | ||
| BeforeOptions.split(BeforeArgs, " ", /*MaxSplit=*/-1, | ||
| /*KeepEmpty=*/false); | ||
| for (const 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)); | ||
| // Split the options string by spaces and rejoin to normalize whitespace | ||
| SmallVector<StringRef, 8> AfterArgs; | ||
| AfterOptions.split(AfterArgs, " ", /*MaxSplit=*/-1, /*KeepEmpty=*/false); | ||
| std::string JoinedOptions = llvm::join(AfterArgs, " "); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this pass all tests? It was similar to this before and I had to add the |
||
| CmdArgs.push_back(Args.MakeArgString(JoinedOptions)); | ||
| } | ||
| } | ||
| StringRef OptL = | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,13 @@ | |
| // UNSUPPORTED: cuda, hip | ||
| // UNSUPPORTED-INTENDED: FP64 emulation is an Intel specific feature. | ||
|
|
||
| // 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: %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 --no-offload-new-driver %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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we also try with |
||
| // 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 -g %O0 %s -o %t.out | ||
| // RUN: %{run} %t.out | ||
|
|
||
| // Tests that aspect::fp64 is not emitted correctly when -fsycl-fp64-conv-emu | ||
|
|
||
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 think the name doesn't describe very well what the function is doing, or at least doesn't align very well with the description in the comment above. I would expect something including the words
GetandDevicesat least.