-
Notifications
You must be signed in to change notification settings - Fork 754
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] Move SYCLLowerWGLocalMemoryPass to OptimizerEarlyEPCallback #16347
Conversation
The pass transforms __sycl_allocateLocalMemory call to access of global variable @WGLocalMem . Move the transform to beginning of the optimizer since the access could enable more optimization than the function call. In addition, intel gpu compiler has a pass to transform global variable in addrspace(3) to alloca, we must run SYCLLowerWGLocalMemoryPass before it.
Similar to #16183 but tweak the position of the pass to satisfy the requirements. |
@jsji, is this PR ready for review? Thanks for putting the motivation for the change to the description. It sounds reasonable except this part:
DPC++ runs all passes before the translation to SPIR-V and IGC runs its passes after the translation to SPIR-V, so existing location satisfies the requirement already. |
Update comments. Co-authored-by: Victor Lomuller <[email protected]>
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.
FE change looks ok to me but I do not know the functionality well enough to approve the new pass location. I defer to @bader for approval
@@ -1043,7 +1043,14 @@ void EmitAssemblyHelper::RunOptimizationPipeline( | |||
/*ExcludeAspects=*/{"fp64"})); | |||
MPM.addPass(SYCLPropagateJointMatrixUsagePass()); | |||
}); | |||
else if (LangOpts.SYCLIsHost && !LangOpts.SYCLESIMDBuildHostCode) | |||
PB.registerOptimizerEarlyEPCallback([](ModulePassManager &MPM, |
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 is the reason to use registerOptimizerEarlyEPCallback
instead of registerPipelineStartEPCallback
?
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.
As mentioned in https://github.com/intel/llvm/pull/16183/files/43526397fa2b4c559666fdfd6f302bfba7409255#r1857546652, we need to make sure this pass run after AlwaysIniner, moving to PipelineStart
is what was tried in #16183, it is before alwaysinliner and too early.
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.
@jsji, could you please extend the comment at lines 1049-1050 with the requirement to run AlwaysInliner pass before SYCLLowerWGLocalMemoryPass?
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.
For sure.
If we are sure that the pass needs to be moved to an earlier stage, I had an idea that we can remove the pass's implicit dependency on alwaysinliner pass and move the pass to pipeline start: wenju-he@e6ce584 |
Thanks @wenju-he ! Yes, looks good idea to handle the inlining of these two functions inside the pass itself. Please post your PR for review instead. |
|
Close, use #16356 instead. |
The pass transforms __sycl_allocateLocalMemory call to access of global
variable @WGLocalMem .
Move the transform to beginning of the optimizer since the access
could enable more optimization than the function call.