-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[offload][SYCL] Add Module splitting by categories. #131347
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
maksimsab
wants to merge
14
commits into
llvm:main
Choose a base branch
from
maksimsab:split_patch3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ede5e8c
[offload][SYCL] Add SYCL Module splitting.
maksimsab c764d7f
Move SYCL Module splitting into llvm/Frontend/SYCL/.
maksimsab c69c62e
apply clang-format
maksimsab 483933b
update comment
maksimsab 141c039
Make splitting algorithm generic. Now function's interface accepts
maksimsab 1729c50
Remove SYCL specialization from the PR.
maksimsab 0b6f17f
Merge branch 'main' into split_patch3
maksimsab c249af1
address most of CR feedback
maksimsab 7ad079e
change function's name and improve the documentation
maksimsab 7c96d33
Change some comments
maksimsab 04de3db
Fix mistake with leaking signature
maksimsab 877db4b
fix grammar and use r-value references
maksimsab 4987388
add comment regarding implementation of group selection
maksimsab 2e89d50
apply clang-format
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,64 @@ | ||
//===-------- 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_TRANSFORMS_UTILS_SYCLSPLITMODULE_H | ||
#define LLVM_TRANSFORMS_UTILS_SYCLSPLITMODULE_H | ||
|
||
#include "llvm/ADT/STLFunctionalExtras.h" | ||
#include "llvm/ADT/StringRef.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)) {} | ||
}; | ||
|
||
using PostSYCLSplitCallbackType = | ||
function_ref<void(std::unique_ptr<Module> Part, std::string Symbols)>; | ||
|
||
/// Splits the given module \p M according to the given \p Settings. | ||
/// Every split image is being passed to \p Callback. | ||
void SYCLSplitModule(std::unique_ptr<Module> M, IRSplitMode Mode, | ||
PostSYCLSplitCallbackType Callback); | ||
|
||
} // namespace llvm | ||
|
||
#endif // LLVM_TRANSFORMS_UTILS_SYCLSPLITMODULE_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. | ||
maksimsab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//===----------------------------------------------------------------------===// | ||
#ifndef LLVM_TRANSFORMS_UTILS_SYCLUTILS_H | ||
#define LLVM_TRANSFORMS_UTILS_SYCLUTILS_H | ||
|
||
#include <llvm/ADT/SmallString.h> | ||
#include <llvm/ADT/SmallVector.h> | ||
maksimsab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
namespace llvm { | ||
|
||
class raw_ostream; | ||
|
||
using SYCLStringTable = SmallVector<SmallVector<SmallString<64>>>; | ||
|
||
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.