-
Notifications
You must be signed in to change notification settings - Fork 15k
[offload][SYCL] Add SYCL Module splitting #119713
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
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
bf48915
[offload][SYCL] Add SYCL Module splitting
maksimsab 115cf87
Address code review feedback.
maksimsab 521ff0d
Merge branch 'main' into split_patch2
maksimsab c054d0f
rename splitSYCLModule to SYCLSplitModule
maksimsab 122425c
Resolve recent CR nits
maksimsab 33b8865
Address some CR issues
maksimsab 18843ff
Perform renaming and simplification of the test
maksimsab e9101e6
remove per-reqd-* tests since corresponding functionality was exclude…
maksimsab 7e84a25
Rework split-with-kernel-declarations.ll.
maksimsab cf807da
remove basic-module-split.ll since it is a copy of split-by-source.ll
maksimsab 92ee37b
Simplify and remove trash
maksimsab 306e3f6
rename the test
maksimsab e223023
add source mode to complex-indirect-call-chain.ll
maksimsab 0a8cc6f
rework tests
maksimsab 9cc3f7f
Merge branch 'main' into split_patch2
maksimsab e0b2b9c
fix typo
maksimsab 958552a
address CR issue
maksimsab 5785d76
fix mistake
maksimsab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| //===-------- SYCLSplitModule.h - module split ------------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // Functionality to split a module into callgraphs. A callgraph here is a set | ||
| // of entry points with all functions reachable from them via a call. The result | ||
| // of the split is new modules containing corresponding callgraph. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_SYCL_SPLIT_MODULE_H | ||
| #define LLVM_SYCL_SPLIT_MODULE_H | ||
|
|
||
| #include "llvm/ADT/SmallVector.h" | ||
| #include "llvm/ADT/StringRef.h" | ||
| #include "llvm/Support/Error.h" | ||
|
|
||
| #include <memory> | ||
| #include <optional> | ||
| #include <string> | ||
|
|
||
| namespace llvm { | ||
|
|
||
| class Module; | ||
|
|
||
| enum class IRSplitMode { | ||
| IRSM_PER_TU, // one module per translation unit | ||
| IRSM_PER_KERNEL, // one module per kernel | ||
| IRSM_NONE // no splitting | ||
| }; | ||
|
|
||
| /// \returns IRSplitMode value if \p S is recognized. Otherwise, std::nullopt is | ||
| /// returned. | ||
| std::optional<IRSplitMode> convertStringToSplitMode(StringRef S); | ||
|
|
||
| /// The structure represents a split LLVM Module accompanied by additional | ||
| /// information. Split Modules are being stored at disk due to the high RAM | ||
| /// consumption during the whole splitting process. | ||
| struct ModuleAndSYCLMetadata { | ||
| std::string ModuleFilePath; | ||
| std::string Symbols; | ||
|
|
||
| ModuleAndSYCLMetadata() = default; | ||
| ModuleAndSYCLMetadata(const ModuleAndSYCLMetadata &) = default; | ||
| ModuleAndSYCLMetadata &operator=(const ModuleAndSYCLMetadata &) = default; | ||
| ModuleAndSYCLMetadata(ModuleAndSYCLMetadata &&) = default; | ||
| ModuleAndSYCLMetadata &operator=(ModuleAndSYCLMetadata &&) = default; | ||
|
|
||
| ModuleAndSYCLMetadata(std::string_view File, std::string Symbols) | ||
| : ModuleFilePath(File), Symbols(std::move(Symbols)) {} | ||
| }; | ||
|
|
||
| struct ModuleSplitterSettings { | ||
| IRSplitMode Mode; | ||
| bool OutputAssembly = false; // Bitcode or LLVM IR. | ||
| StringRef OutputPrefix; | ||
| }; | ||
|
|
||
| /// Parses the string table. | ||
| Expected<SmallVector<ModuleAndSYCLMetadata, 0>> | ||
| parseModuleAndSYCLMetadataFromFile(StringRef File); | ||
|
|
||
| /// Splits the given module \p M according to the given \p Settings. | ||
| Expected<SmallVector<ModuleAndSYCLMetadata, 0>> | ||
| SYCLSplitModule(std::unique_ptr<Module> M, ModuleSplitterSettings Settings); | ||
|
|
||
| } // namespace llvm | ||
|
|
||
| #endif // LLVM_SYCL_SPLIT_MODULE_H | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| //===------------ SYCLUtils.h - SYCL utility functions --------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // Utility functions for SYCL. | ||
| //===----------------------------------------------------------------------===// | ||
| #ifndef LLVM_TRANSFORMS_UTILS_SYCLUTILS_H | ||
| #define LLVM_TRANSFORMS_UTILS_SYCLUTILS_H | ||
|
|
||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| namespace llvm { | ||
|
|
||
| class raw_ostream; | ||
|
|
||
| using SYCLStringTable = std::vector<std::vector<std::string>>; | ||
|
|
||
| void writeSYCLStringTable(const SYCLStringTable &Table, raw_ostream &OS); | ||
|
|
||
| } // namespace llvm | ||
|
|
||
| #endif // LLVM_TRANSFORMS_UTILS_SYCLUTILS_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.