-
Notifications
You must be signed in to change notification settings - Fork 803
[NewOffloadModel] Fix transition of compile options from image to SYCL Offload Wrapper #19579
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?
Conversation
6c4992c
to
1b4dcc8
Compare
This patch fixes a handling of compile/link options encoded in images. Also the patch fixes a redirection to backend compiler and offload wrapper depending on the Triple (AOT or JIT). This functionality is important for the support of the following clang command line options in the New Offload Model: * -ftarget-compile-fast * -ftarget-export-symbols * -ftarget-register-alloc-mode
@asudarsa Friendly reminder :) Failed tests aren't related to the patch. They will be fixed after rebasing. |
StringRef CompileOptions = OB.getString("compile-opts"); | ||
StringRef LinkOptions = OB.getString("link-opts"); | ||
if (!CompileOptions.empty()) | ||
SYCLCompileOptionsFromImage = CompileOptions.str(); |
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.
What if different files have different compile options? They will be overwritten, won't they? Is this possible?
if (!CompileOptions.empty()) | ||
SYCLCompileOptionsFromImage = CompileOptions.str(); | ||
if (!LinkOptions.empty()) | ||
SYCLLinkOptionsFromImage = LinkOptions.str(); |
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.
Same than compile options.
StringRef OptC = SYCLCompileOptionsFromImage; | ||
OptC.split(CmdArgs, " ", /*MaxSplit=*/-1, /*KeepEmpty=*/false); | ||
OptC = Args.getLastArgValue( | ||
OPT_sycl_backend_compile_options_EQ); // TODO: test this. |
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.
OPT_sycl_backend_compile_options_EQ); // TODO: test this. | |
OPT_sycl_backend_compile_options_EQ); // TODO: test this. |
Is the TODO still necessary?
if (Target.empty()) | ||
return createStringError( | ||
inconvertibleErrorCode(), | ||
"can't wrap SYCL image. -triple argument is missed."); |
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't wrap SYCL image. -triple argument is missed."); | |
"can't wrap SYCL image. -triple argument is missing."); |
@@ -0,0 +1,49 @@ | |||
// Test checks that compile options are transfared to backend in the New |
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.
// Test checks that compile options are transfared to backend in the New | |
// Test checks that compile options are transferred to backend in the New |
// RUN: env SYCL_UR_TRACE=2 %{run} %t_with.out 2>&1 | FileCheck --check-prefix=CHECK-INTEL-GPU-WITH %s | ||
|
||
// CHECK-INTEL-GPU-WITH: <--- urProgramBuild | ||
// CHECK-INTEL-GPU-WITH-SAME: -igc_opts 'PartitionUnit=1,SubroutineThreshold=50000' |
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.
Not sure I understand this check. Can you explain why we expect this?
@@ -158,6 +158,10 @@ static SYCLBIN::BundleState SYCLBINState = SYCLBIN::BundleState::Input; | |||
|
|||
static SmallString<128> OffloadImageDumpDir; | |||
|
|||
static std::string SYCLCompileOptionsFromImage; |
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.
Any specific reason why this is a std::string
and not a StringRef
?
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.
Data-owning containers are more reliable against use-after-free bugs.
llvm::Triple T(Target); | ||
bool isJIT = !(T.getSubArch() == llvm::Triple::SPIRSubArch_gen || | ||
T.getSubArch() == llvm::Triple::SPIRSubArch_x86_64); | ||
SmallString<0> CompileOptions; |
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.
Any reason this is not a StringRef
instead, given that you are assigning a StringRef
value in L1077
?
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 mentioned StringRef
refers to a temporary string and the data should be stored in a data-owning container.
In fact, my code contains the bug use-after-free
and it should be fixed.
This patch fixes a handling of compile/link options encoded in images.
Also the patch fixes a redirection to backend compiler and offload
wrapper depending on the Triple (AOT or JIT).
This functionality is important for the support of the following clang
command line options in the New Offload Model: