Skip to content
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][ESIMD] Rework -O0 behavior #12612

Merged
merged 4 commits into from
Feb 28, 2024
Merged

[SYCL][ESIMD] Rework -O0 behavior #12612

merged 4 commits into from
Feb 28, 2024

Conversation

sarnex
Copy link
Contributor

@sarnex sarnex commented Feb 5, 2024

Let me first say I don't like this change and I wish we didn't have to do this, and it should only be temporary.

The root need is that the IGC VC backend does not support O0 code. It gets miscompiled and produces wrong answers and crashes. The team acknowledges this issue but does not have the resources to fix this at the moment.

From the ESIMD user POV, this is really frustrating. We decided it would be okay if they lost debuggability of device code (but retained it for host code) as long as their program runs and they get the right answer.

So the overall approach is to optimize ESIMD(Not SYCL!!) code even in O0 mode. We are actually already doing this, but this change extends it a bit.

So there are a few main changes in this PR:

  1. Don't pass -O0 to sycl-post-link. Note this option has absolutely no effect on SYCL code today, it is only checked in the ESIMD lowering code in sycl-post-link.
  2. Add a new pass to remove optnone/noinline early for ESIMD code in O0.
  3. Remove optnone/noinline from all functions if we split out ESIMD/SYCL code, and if we don't don't touch it.

All three of these steps are required to fix the tests failing with O0, if we remove any one of them we see many failures.

When running all ESIMD tests with O0, we see the following improvements:

Linux:
Today: 97 failures
With this change: 23 failures, with ~3 root causes. There are no regressions. I'll look into these later.
Windows: 
Today: 38 failures
With this change: 10 failures. There are no regressions. I'll look into these later.

Once IGC VC can actually correctly compile non-optimized code, we should revert this change.

Copy link
Contributor

github-actions bot commented Feb 7, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
@sarnex
Copy link
Contributor Author

sarnex commented Feb 7, 2024

Linux Gen12 failure is not related, failing everywhere:

Failed Tests (1):
  SYCL :: ESIMD/aot_mixed.cpp

@sarnex sarnex marked this pull request as ready for review February 7, 2024 21:14
@sarnex sarnex requested review from a team as code owners February 7, 2024 21:14
@@ -955,6 +955,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
PB.registerPipelineStartEPCallback([&](ModulePassManager &MPM,
OptimizationLevel Level) {
MPM.addPass(ESIMDVerifierPass(LangOpts.SYCLESIMDForceStatelessMem));
if (Level == OptimizationLevel::O0)
MPM.addPass(ESIMDRemoveOptnoneNoinlinePass());
Copy link
Contributor

Choose a reason for hiding this comment

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

I am okay with this ESIMD change.

Copy link
Contributor

@premanandrao premanandrao left a comment

Choose a reason for hiding this comment

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

FE changes are okay with me.

@sarnex
Copy link
Contributor Author

sarnex commented Feb 21, 2024

@intel/dpcpp-esimd-reviewers @intel/dpcpp-tools-reviewers Ping, thanks!

Copy link
Contributor

@maksimsab maksimsab left a comment

Choose a reason for hiding this comment

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

LGTM.

llvm/lib/SYCLLowerIR/ESIMD/ESIMDRemoveOptnoneNoinline.cpp Outdated Show resolved Hide resolved
@@ -1834,6 +1834,15 @@ bool SYCLLowerESIMDPass::prepareForAlwaysInliner(Module &M) {
continue;
}

// If we are splitting by ESIMD, we are guarenteed the entire
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this code still needed after adding the special pass that remove those 2 attributes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I tested many combinations of with/without different changes in this PR and everything we currently have is required.

@sarnex
Copy link
Contributor Author

sarnex commented Feb 28, 2024

Windows fail is not related

@sarnex sarnex merged commit 00749b1 into intel:sycl Feb 28, 2024
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants