[llvm] [offload][SYCL] Add SYCL Module splitting (PR #119713)
Alexey Bader via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 9 21:49:38 PST 2025
================
@@ -70,6 +76,66 @@ static cl::opt<std::string>
MCPU("mcpu", cl::desc("Target CPU, ignored if --mtriple is not used"),
cl::value_desc("cpu"), cl::cat(SplitCategory));
+static cl::opt<IRSplitMode> SYCLSplitMode(
+ "sycl-split",
+ cl::desc("SYCL Split Mode. If present, SYCL splitting algorithm is used "
+ "with the specified mode."),
+ cl::Optional, cl::init(IRSplitMode::IRSM_NONE),
+ cl::values(clEnumValN(IRSplitMode::IRSM_PER_TU, "source",
+ "1 ouptput module per translation unit"),
+ clEnumValN(IRSplitMode::IRSM_PER_KERNEL, "kernel",
+ "1 output module per kernel")),
+ cl::cat(SplitCategory));
+
+static cl::opt<bool> OutputAssembly{
+ "S", cl::desc("Write output as LLVM assembly"), cl::cat(SplitCategory)};
+
+void writeStringToFile(std::string_view Content, StringRef Path) {
+ std::error_code EC;
+ raw_fd_ostream OS(Path, EC);
+ if (EC) {
+ errs() << formatv("error opening file: {0}\n", Path);
+ exit(1);
+ }
+
+ OS << Content << "\n";
+}
+
+void writeSplitModulesAsTable(ArrayRef<ModuleAndSYCLMetadata> Modules,
+ StringRef Path) {
+ std::vector<std::string> Columns = {"Code", "Symbols"};
----------------
bader wrote:
Please, use one LLVM's containers instead of `std::vector` (e.g. `SmallVector`).
https://llvm.org/docs/ProgrammersManual.html#llvm-adt-smallvector-h
The same applies to `std::string`. https://llvm.org/docs/ProgrammersManual.html#string-like-containers
https://github.com/llvm/llvm-project/pull/119713
More information about the llvm-commits
mailing list