Skip to content

[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

Open
wants to merge 1 commit into
base: sycl
Choose a base branch
from

Conversation

maksimsab
Copy link
Contributor

This change allows later reuse of specialization constant's processing in the New Offloading Model and sycl-jit.

…st-link to SYCLPostLink library.

This change allows later reuse in the New Offloading Model and sycl-jit.
@maksimsab maksimsab requested a review from a team as a code owner June 17, 2025 12:25
@maksimsab
Copy link
Contributor Author

The interface of a functionhandleSpecializationConstants is controversial. It allows to invoke the function in the following manner if you don't need to generate new modules with spec constants replaced by default values:

SmallVector<ModuleDesc> MDs;
Modified |= handleSpecializationConstants(MDs, Mode);

If you have a better alternative for the function's interface let me know.

Copy link
Contributor

@maarquitos14 maarquitos14 left a 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.

@@ -0,0 +1,97 @@
//= SpecializationConstants.h - Processing of SYCL Specialization Constants ==//
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
//= SpecializationConstants.h - Processing of SYCL Specialization Constants ==//
//= SpecializationConstants.cpp - Processing of SYCL Specialization Constants ==//

std::optional<SpecConstantsPass::HandlingMode> Mode,
bool GenerateModuleDescWithDefaultSpecConsts,
SmallVectorImpl<module_split::ModuleDesc> *NewModuleDescs) {
assert((GenerateModuleDescWithDefaultSpecConsts ^ !NewModuleDescs) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

This is quite difficult to read. Could we rewrite this to something simpler?
Maybe something like:

Suggested change
assert((GenerateModuleDescWithDefaultSpecConsts ^ !NewModuleDescs) &&
#ifdef NDEBUG
if (GenerateModuleDescWithDefaultSpecConsts)
assert(NewModuleDescs);
#endif

} // namespace

bool llvm::sycl::handleSpecializationConstants(
SmallVectorImpl<module_split::ModuleDesc> &MDs,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
SmallVectorImpl<module_split::ModuleDesc> &MDs,
const SmallVectorImpl<module_split::ModuleDesc> &MDs,

MAM.registerPass([&] { return PassInstrumentationAnalysis(); });
RunSpecConst.addPass(std::move(SCP));

// Perform the spec constant intrinsics transformation on resulting module
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Perform the spec constant intrinsics transformation on resulting module
// Perform the spec constant intrinsics transformation on resulting module.

ModulePassManager RunSpecConst;
ModuleAnalysisManager MAM;
SpecConstantsPass SCP(Mode);
// Register required analysis
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Register required analysis
// Register required analysis.

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.

2 participants