-
Notifications
You must be signed in to change notification settings - Fork 791
[SYCL][NFC] Extract specialization constant's processing from sycl-post-link to SYCLPostLink library. #19022
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
Conversation
…st-link to SYCLPostLink library. This change allows later reuse in the New Offloading Model and sycl-jit.
The interface of a function SmallVector<ModuleDesc> MDs;
Modified |= handleSpecializationConstants(MDs, Mode); If you have a better alternative for the function's interface let me know. |
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.
Looks good overall, just a few nits.
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.
Overall looks good. Minor changes requested.
Thanks
Hi @intel/dpcpp-tools-reviewers Could, please, someone take a look at this PR? |
|
||
std::optional<SpecConstantsPass::HandlingMode> SCMode; | ||
if (SpecConstLower.getNumOccurrences() > 0) | ||
SCMode = SpecConstLower == SC_NATIVE_MODE |
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 there a default value we can use instead of having it being optional
? maybe like not_specified
or something?
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.
Would it be better to have not_specified
value? We will have to check that value and return errors deeper in lowering.
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.
personally i would prefer that
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 expected behaviour in the following snippet then would be?
ModulePassManager MPM;
ModuleAnalysisManager MAM;
SpecConstantsPass SCP(SpecConstantsPass::HandlingMode::not_specified);
MAM.registerPass([&] { return PassInstrumentationAnalysis(); });
MPM.addPass(std::move(SCP));
PreservedAnalyses Res = MPM.run(NewMD->getModule(), MAM);
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.
@sarnex , @maksimsab , I guess the answer to Nick's question in this thread is: there is no default value currently that can be used instead of having SCMode to be optional.
This PR is about extracting existing spec const processing to a library. Updating SpecConstantsPass and introducing new HandlingMode is out of scope of this PR. We can consider it as a future refactoring, but it should not hold this PR from merging.
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.
it's not worth blocking the PR over, but i'm not sure i understand, the old code does not seem to use optional for the handling mode, so im wondering why we need it in this NFC change
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.
That is a good question! The reason is how logic was split between sycl-post-link
and SYCLPostLink
library.
The info about spec const mode comes from cl::opt
option in sycl-post-link
tool, which is:
cl::opt<SpecConstLowerMode> SpecConstLower
and is cl::Optional
.
Since in the old code SpecConstLower
is global for that file and the logic which depends on its optionality is in the same file, we did not need additional optional variable. So there is code like:
if (SpecConstLower.getNumOccurrences() == 0)
return false;
So, semantically, old code used optional
, just not std::optional
.
In the new code, we need to keep optional behavior and pass this information somehow to the library function. It seems using std::optional
is the closest way to keep the original semantics.
The alternative (to keep the code as close to the original as possible) that I see is to pass cl::opt<SpecConstLowerMode> SpecConstLower
as parameter, instead of std::optional<SpecConstantsPass::HandlingMode> Mode
.
That doesn't look better to me...
What do you think?
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.
Updating SpecConstantsPass and introducing new HandlingMode is out of scope of this PR.
That is correct. Introducing default value would lead to many changes in SpecConstsPass which worth a separate patch.
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 agree that calling getNumOccurences() == 0
is similar to checking if the optional is empty. so yeah feel free to merge the pr and address this in a follow up
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 this already covered by current testing or should we add new testing?
@maarquitos14 Yes, we have plenty of sycl-post-link's testing. Later this testing should be migrated for New Offloading Model's tools. |
@intel/llvm-gatekeepers please consider merging |
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
@intel/llvm-gatekeepers Can we merge that please? |
This change allows later reuse of specialization constant's processing in the New Offloading Model and sycl-jit.