-
Notifications
You must be signed in to change notification settings - Fork 734
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
[SYCL][ClangLinkerWrapper] Add SYCL Module split library usage in clang-linker-wrapper #13806
Conversation
30ce597
to
e463a8f
Compare
Note for reviewers. |
e463a8f
to
8789bf1
Compare
@@ -163,6 +163,15 @@ def sycl_post_link_options_EQ : Joined<["--", "-"], "sycl-post-link-options=">, | |||
Flags<[WrapperOnlyOption]>, | |||
HelpText<"Options that will control sycl-post-link step">; | |||
|
|||
def sycl_module_split_mode_EQ : |
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 we will need to add tests to make sure that the existing tests which use the sycl-post-link will run the same way when we use the split library. I think this might be a good place to start adding E2E tests using new offloading model.
Thanks
ModuleDesc MD = std::move(M); // makeModuleDesc() ? | ||
// FIXME: false arguments are temporary for now. | ||
auto Splitter = | ||
getDeviceCodeSplitter(std::move(MD), Settings.Mode, false, false); |
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.
We can try and pass the entries from -sycl-post-link-options via the Settings variable. I am ok to do it in a subsequent PR. There will be other options like -emit-exported-symbols, -emit-imported-symbols if/when we want to add dynamic linking support here.
Thanks
std::vector<SplitModule> OutputImages; | ||
while (Splitter->hasMoreSplits()) { | ||
ModuleDesc MD2 = Splitter->nextSplit(); | ||
MD2.fixupLinkageOfDirectInvokeSimdTargets(); |
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.
We will not be upstreaming this. Do we want to add a TODO marker for tracking that?
Thanks
} | ||
|
||
static Expected<std::vector<module_split::SplitModule>> | ||
runSYCLSplitLibrary(ArrayRef<StringRef> InputFiles, const ArgList &Args, |
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.
We will want to parse the -sycl-post-link-options here.
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.
Can you please share your thoughts on this? Thanks
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.
The issue here is that the library is not complete. The plan is to fulfill missing functionality and add the corresponding splitting option parsing.
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.
The change looks great. Specifically, the move from using 'table' file to using SplitModules is a very good segway to start using the generic 'Image' data structure (extended for SYCL).
I have added a few comments to be addressed. No major concerns from me.
Thanks
This looks great and I should be able to easily react to getting rid of the table in my thinLTO prototype, I'll take an in-depth look once we rebase on top of HEAD to resolve conflicts. |
…er-wrapper This patch introduces -sycl-module-split-mode command line option in clang-linker-wrapper tool and makes the tool invoke either library or sycl-post-link tool depending on the presense of -sycl-module-split-mode option. Also the patch removes funcionality of reading/writing of Table files in clang-linker-wrapper. Instead of them the tool starts using in-memory structures.
450524d
to
fbcc7c6
Compare
I will do final cleanup and reopen this PR for CR. |
Hi @maksimsab Thanks |
auto [PropertyFilePath, SymbolsFilePath] = Rem.split("|"); | ||
llvm::util::PropertySetRegistry Properties; | ||
std::string Symbols; | ||
if (!PropertyFilePath.empty()) { |
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.
Is props/syms being empty valid? Should we error?
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.
lgtm, thanks! only minor comments
return *TempFileOrErr; | ||
llvm::module_split::ModuleSplitterSettings Settings; | ||
Settings.Mode = Mode; | ||
Settings.OutputPrefix = ""; |
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.
Just a question, are there any cases where we're going to set a prefix in the future?
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.
In fact, it should be changed when -save-temps
is used.
@@ -45,6 +46,10 @@ enum IRSplitMode { | |||
SPLIT_NONE // no splitting | |||
}; | |||
|
|||
// \returns IRSplitMode value if \p S is recognized. Otherwise, std::nullopt is |
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.
nit: mix between //
comments here and ///
for parseSplitModulesFromFile
@@ -90,7 +103,7 @@ | |||
// | |||
// RUN: clang-linker-wrapper -sycl-device-libraries=%t3.devicelib.o -sycl-post-link-options="SYCL_POST_LINK_OPTIONS" -llvm-spirv-options="LLVM_SPIRV_OPTIONS" "--host-triple=x86_64-unknown-linux-gnu" "--linker-path=/usr/bin/ld" "--" HOST_LINKER_FLAGS "-dynamic-linker" HOST_DYN_LIB "-o" "a.out" HOST_LIB_PATH HOST_STAT_LIB %t3.o --dry-run 2>&1 | FileCheck -check-prefix=CHK-CMDS-AOT-NV %s | |||
// CHK-CMDS-AOT-NV: "{{.*}}spirv-to-ir-wrapper" {{.*}} -o [[FIRSTLLVMLINKIN:.*]].bc --llvm-spirv-opts --spirv-preserve-auxdata --spirv-target-env=SPV-IR --spirv-builtin-format=global | |||
// CHK-CMDS-AOT-NV-NEXT: "{{.*}}llvm-link" [[FIRSTLLVMLINKIN:.*]].bc -o [[FIRSTLLVMLINKOUT:.*]].bc --suppress-warnings | |||
// CHK-CMDS-AOT-NV-NEXT: "{{.*}}llvm-link" [[FIRSTLLVMLINKIN]].bc -o [[FIRSTLLVMLINKOUT:.*]].bc --suppress-warnings |
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.
Eagle eyes to catch the re-setting of the FIRSTLLVMLINKIN
var!
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.
LGTM. I have one outstanding question about how you plan to handle -sycl-post-link-options in the library version. I am ok with a plan to support it in a future PR. But I would like to see some path forward here.
Thanks again for this PR.
@asudarsa Is it okay if I merge this PR? It doesn't seem like your comment is blocking. I'm dependent on this for thinLTO work. Thanks. |
Sorry Arvind is on vacation for a while. @maksimsab Is it okay if I merge this now and you can address any feedabck from Arvind when he comes back? Thanks. |
@sarnex Sure! I have the upcoming patch that depends on this one. |
Thanks! |
This patch introduces -sycl-module-split-mode command line option in clang-linker-wrapper tool and makes the tool invoke either library or sycl-post-link tool depending on the presense of -sycl-module-split-mode option.
Also the patch removes funcionality of reading/writing of Table files in clang-linker-wrapper. Instead of them the tool starts using in-memory structures.