-
Notifications
You must be signed in to change notification settings - Fork 850
[SYCL][Driver] Add option to specify the location of ocloc #22912
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
b3cac68
da28bd4
6bc28b2
0e0a736
d3b9cfe
a469b82
b4c1da6
7a70b18
03c8be4
fff04f4
5e0620a
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 |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /// | ||
| /// Tests for --ocloc-path=, which provides the location of the externally | ||
| /// acquired ocloc tool used for Intel GPU AOT compilation. | ||
| /// | ||
|
|
||
| // REQUIRES: x86-registered-target | ||
|
|
||
| /// Check that --ocloc-path= is used for the old offloading model. | ||
| // RUN: %clang -### -fsycl --no-offload-new-driver -fsycl-targets=spir64_gen \ | ||
| // RUN: --ocloc-path=/my/ocloc/dir %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHK-OCLOC-PATH-OLD %s | ||
| // RUN: %clang -### -fsycl --no-offload-new-driver \ | ||
| // RUN: -fsycl-targets=intel_gpu_pvc --ocloc-path=/my/ocloc/dir %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHK-OCLOC-PATH-OLD %s | ||
| // CHK-OCLOC-PATH-OLD: "/my/ocloc/dir{{[/\\]+}}ocloc{{(\.exe)?}}" "-output" | ||
|
|
||
| /// Check that the user provided location wins over an ocloc that is visible | ||
| /// via the PATH. The fake ocloc must be findable, which means it needs the | ||
| /// execute bit set on linux and the executable extension on windows. | ||
| // RUN: rm -rf %t.dir && mkdir -p %t.dir | ||
| // RUN: %if system-windows %{ touch %t.dir/ocloc.exe %} \ | ||
| // RUN: %else %{ touch %t.dir/ocloc && chmod +x %t.dir/ocloc %} | ||
| // RUN: env "PATH=%t.dir%{pathsep}%PATH%" %clang -### -fsycl \ | ||
| // RUN: --no-offload-new-driver -fsycl-targets=spir64_gen \ | ||
| // RUN: --ocloc-path=/my/ocloc/dir %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHK-OCLOC-PATH-OLD %s | ||
|
|
||
| /// Check that the 'exe' name is used for windows. | ||
| // RUN: %clang_cl -### -fsycl --no-offload-new-driver \ | ||
| // RUN: -fsycl-targets=spir64_gen --ocloc-path=/my/ocloc/dir -- %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHK-OCLOC-PATH-OLD-WIN %s | ||
| // RUN: %clang -### -target x86_64-pc-windows-msvc -fsycl \ | ||
| // RUN: --no-offload-new-driver -fsycl-targets=spir64_gen \ | ||
| // RUN: --ocloc-path=/my/ocloc/dir %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHK-OCLOC-PATH-OLD-WIN %s | ||
| // CHK-OCLOC-PATH-OLD-WIN: "/my/ocloc/dir{{[/\\]+}}ocloc.exe" "-output" | ||
|
|
||
| /// Check that --ocloc-path= is forwarded to the clang-linker-wrapper for the | ||
| /// new offloading model. | ||
| // RUN: %clang -### -fsycl --offload-new-driver -fsycl-targets=spir64_gen \ | ||
| // RUN: --sysroot=%S/Inputs/SYCL --ocloc-path=/my/ocloc/dir %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHK-OCLOC-PATH-NEW %s | ||
| // RUN: %clang -### -fsycl --offload-new-driver \ | ||
| // RUN: -fsycl-targets=intel_gpu_pvc --sysroot=%S/Inputs/SYCL \ | ||
| // RUN: --ocloc-path=/my/ocloc/dir %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHK-OCLOC-PATH-NEW %s | ||
| // CHK-OCLOC-PATH-NEW: clang-linker-wrapper{{.*}} "--ocloc-path=/my/ocloc/dir" | ||
|
|
||
| /// Check that --ocloc-path= is forwarded to the clang-sycl-linker. | ||
| // RUN: touch %t.bc | ||
| // RUN: %clangxx -### --target=spirv64 --sycl-link \ | ||
| // RUN: --ocloc-path=/my/ocloc/dir %t.bc 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHK-OCLOC-PATH-SYCL-LINK %s | ||
| // CHK-OCLOC-PATH-SYCL-LINK: clang-sycl-linker{{.*}} "--ocloc-path=/my/ocloc/dir" | ||
|
|
||
| /// Check that --ocloc-path= is used when emitting the ocloc help information. | ||
| // RUN: %clang -### -fsycl -fsycl-help=gen --ocloc-path=/my/ocloc/dir %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHK-OCLOC-PATH-HELP %s | ||
| // CHK-OCLOC-PATH-HELP: Emitting help information for ocloc | ||
| // CHK-OCLOC-PATH-HELP: "/my/ocloc/dir{{[/\\]+}}ocloc{{(\.exe)?}}" "--help" | ||
|
|
||
| /// Check that the 'exe' name is used for windows when emitting the ocloc help | ||
| /// information. | ||
| // RUN: %clang -### -target x86_64-pc-windows-msvc -fsycl -fsycl-help=gen \ | ||
| // RUN: --ocloc-path=/my/ocloc/dir %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHK-OCLOC-PATH-HELP-WIN %s | ||
| // CHK-OCLOC-PATH-HELP-WIN: "/my/ocloc/dir{{[/\\]+}}ocloc.exe" "--help" | ||
|
|
||
| /// Check the diagnostic emitted when the given directory does not contain a | ||
| /// usable ocloc. Without -### the tool is actually launched, so the composed | ||
| /// path is expected to be diagnosed instead of being silently ignored. | ||
| // RUN: rm -rf %t.empty.dir && mkdir -p %t.empty.dir | ||
| // RUN: not %clang -fsycl -fsycl-help=gen --ocloc-path=%t.empty.dir %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHK-OCLOC-PATH-HELP-ERR %s | ||
| // CHK-OCLOC-PATH-HELP-ERR: error: unable to execute command: {{.*}}ocloc | ||
|
|
||
| /// Check that an empty --ocloc-path= is rejected instead of falling back to | ||
| /// another ocloc. | ||
| // RUN: not %clang -### -fsycl --no-offload-new-driver \ | ||
| // RUN: -fsycl-targets=spir64_gen --ocloc-path= %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHK-OCLOC-PATH-EMPTY %s | ||
| // RUN: not %clang -fsycl -fsycl-help=gen --ocloc-path= %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHK-OCLOC-PATH-EMPTY %s | ||
| // CHK-OCLOC-PATH-EMPTY: error: invalid value '' in '--ocloc-path=' | ||
| // CHK-OCLOC-PATH-EMPTY-NOT: Emitting help information | ||
|
|
||
| /// Check that --ocloc-path= does not warn as unused when no AOT compilation | ||
| /// for Intel GPU is being performed. | ||
| // RUN: %clang -### -fsycl -fsycl-targets=spir64 --ocloc-path=/my/ocloc/dir \ | ||
| // RUN: --sysroot=%S/Inputs/SYCL %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHK-OCLOC-PATH-UNUSED %s | ||
| // CHK-OCLOC-PATH-UNUSED-NOT: warning: argument unused during compilation |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -338,6 +338,28 @@ Expected<std::string> findProgram(StringRef Name, ArrayRef<StringRef> Paths) { | |
| return *Path; | ||
| } | ||
|
|
||
| /// Locate the 'ocloc' tool used for Intel GPU AOT compilation. | ||
| Expected<std::string> findOcloc(const ArgList &Args) { | ||
|
Contributor
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. Implementation in
Could you please align implementations? |
||
| if (Arg *A = Args.getLastArg(OPT_ocloc_path_EQ)) { | ||
| StringRef Dir = A->getValue(); | ||
| if (Dir.empty()) | ||
| return createStringError("no directory given for '" + A->getSpelling() + | ||
| "'"); | ||
| // Only look in the given directory. The tool name is resolved by | ||
| // findProgramByName, which takes care of any platform specific executable | ||
| // extension. | ||
| if (ErrorOr<std::string> Path = sys::findProgramByName("ocloc", {Dir})) | ||
| return *Path; | ||
| if (DryRun) { | ||
| SmallString<128> OclocPath(Dir); | ||
| sys::path::append(OclocPath, "ocloc"); | ||
| return std::string(OclocPath); | ||
| } | ||
| return createStringError("Unable to find 'ocloc' in '" + Dir + "'"); | ||
| } | ||
| return findProgram("ocloc", {getExecutableDir("ocloc")}); | ||
| } | ||
|
|
||
| bool linkerSupportsLTO(const ArgList &Args) { | ||
| llvm::Triple Triple(Args.getLastArgValue(OPT_triple_EQ)); | ||
| return Triple.isNVPTX() || Triple.isAMDGPU() || | ||
|
|
@@ -1081,8 +1103,7 @@ runAOTCompileIntelGPU(StringRef InputFile, const ArgList &Args, | |
| const llvm::Triple Triple(Args.getLastArgValue(OPT_triple_EQ)); | ||
| StringRef Arch(Args.getLastArgValue(OPT_arch_EQ)); | ||
| SmallVector<StringRef, 8> CmdArgs; | ||
| Expected<std::string> OclocPath = | ||
| findProgram("ocloc", {getExecutableDir("ocloc")}); | ||
| Expected<std::string> OclocPath = findOcloc(Args); | ||
| if (!OclocPath) | ||
| return OclocPath.takeError(); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,10 @@ def linker_path_EQ : Joined<["--"], "linker-path=">, | |
| def cuda_path_EQ : Joined<["--"], "cuda-path=">, | ||
| Flags<[WrapperOnlyOption]>, MetaVarName<"<dir>">, | ||
| HelpText<"Set the system CUDA path">; | ||
| def ocloc_path_EQ : Joined<["--"], "ocloc-path=">, | ||
|
Contributor
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. Please, update documentation for both: clang-linker-wrapper and clang-sycl-linker to document new options (also driver maybe?) Also Options WG??? |
||
| Flags<[WrapperOnlyOption]>, MetaVarName<"<dir>">, | ||
| HelpText<"Path to the ocloc tool, which is used for ahead of time " | ||
| "compilation targeting Intel GPUs">; | ||
| def host_triple_EQ : Joined<["--"], "host-triple=">, | ||
| Flags<[WrapperOnlyOption]>, | ||
| MetaVarName<"<triple>">, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Empty value (
--ocloc-path=) behaves differently across tools/offloading models (SYCL.cpp vs. clang-linker-wrapper/clang-sycl-linker).Here, it silently falls back to a PATH lookup at exec time.
In clang-linker-wrapper/clang-sycl-linker it will be a hard-error:
Unable to find 'ocloc' in ''.Given the stated contract is "the user provided location always wins", I think, it makes sense to also reject an empty value in the driver rather than letting it mean two different things depending on the tool.