Skip to content

[SYCL][NFC] Remove makeResultFilename function from sycl-post-link #17602

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

Merged
merged 13 commits into from
Jul 16, 2025

Conversation

maksimsab
Copy link
Contributor

@maksimsab maksimsab commented Mar 24, 2025

The functionality of the makeResultFilename function has been moved to the getOutputPrefix function, and it is invoked at the beginning of the program.

Two SaveModuleIR functions have been merged into one function.

The output setup in the saveModuleProperties function has been moved out of the function for simplification.

This simplifying change is mandatory for the later migration of IO utilities of sycl-post-link to the library.

The functionality of the makeResultFilename function has been moved to the getOutputPrefix function, and it is invoked at the beginning of the program.

Two SaveModuleIR functions have been merged into one function.

The output setup in the saveModuleProperties function has been moved out of the function for simplification.

Two dead ifs have been removed.

This simplifying change is mandatory for the later migration of IO utilities of sycl-post-link to the library.
@maksimsab maksimsab requested a review from a team as a code owner March 24, 2025 13:19
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.

A few nits. LGTM otherwise.

@maksimsab
Copy link
Contributor Author

Update: My original statement in the comment "OutputFiless size is never zero" turned out to be false and subsequent refactorings weren't correct. Therefore, I removed changes related to OutIRFileName and IRFilename in saveModule.

@maarquitos14 Could you please rereview this PR?

}

void saveModuleIR(Module &M, StringRef OutFilename) {
void saveModuleIR(Module &M, const StringRef Filename) {
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
void saveModuleIR(Module &M, const StringRef Filename) {
void saveModuleIR(const Module &M, const StringRef Filename) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MPM.run would not accept a const reference.

// the result.
void saveModule(std::vector<std::unique_ptr<util::SimpleTable>> &OutTables,
module_split::ModuleDesc &MD, int I, StringRef IRFilename) {
/// \param OutTables List of tables (one for each target) to output results
Copy link
Contributor

Choose a reason for hiding this comment

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

What is a 'target'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From some time ago we started support targets in sycl-post-link. Therefore, each target gets it's own table.
Links: #12727 and #12252

void saveModuleSymbolTable(const module_split::ModuleDesc &MD,
const StringRef Filename) {
std::string SymT = computeModuleSymbolTable(MD.getModule(), MD.entries());
writeToFile(Filename, SymT);
}

// Compute the filename suffix for the module
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be merged with getOutputSuffix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have only getOutputPrefix at the moment. I've just noticed that we don't need the function getModuleSuffix being used only once.

std::string NewSuff = Suffix.str();
if (!Target.empty())
NewSuff = (Twine("_") + Target).str();

CopyTriple.Prop =
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious. Why do we not use DoPropGen flag here to guard 'saveModuleProperties'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like we do use the flag.

}

++ID;
}
}

if (IsBF16DeviceLibUsed && (DeviceLibDir.getNumOccurrences() > 0)) {
saveDeviceLibModule(Tables, ID, "libsycl-fallback-bfloat16.bc");
saveDeviceLibModule(Tables, ID + 1, "libsycl-native-bfloat16.bc");
saveDeviceLibModule(Tables, OutputPrefix, ID,
Copy link
Contributor

@asudarsa asudarsa Jul 2, 2025

Choose a reason for hiding this comment

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

It might be cleaner to populate a global constant with the list of device library module filenames and use that here? Ideally, it should be passed in as an option to sycl-post-link.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could leave that for later.

Copy link
Contributor

@asudarsa asudarsa left a comment

Choose a reason for hiding this comment

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

Few nitpicks. May be update PR title as something like 'Code changes to prepare for sycl-post-link librarification'?

Thanks

@maksimsab
Copy link
Contributor Author

Hi @intel/llvm-gatekeepers !
Could we please merge this PR?

@uditagarwal97 uditagarwal97 merged commit f9de199 into intel:sycl Jul 16, 2025
26 checks passed
@maksimsab maksimsab deleted the refactor_io1 branch July 16, 2025 14:34
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.

5 participants