-
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
ede5e8c
c764d7f
c69c62e
483933b
141c039
1729c50
0b6f17f
c249af1
7ad079e
7c96d33
04de3db
877db4b
4987388
2e89d50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,8 @@ | |
// Functionality to split a module by categories. | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_FRONTEND_SYCL_SPLIT_MODULE_H | ||
#define LLVM_FRONTEND_SYCL_SPLIT_MODULE_H | ||
#ifndef LLVM_TRANSFORM_UTILS_SPLIT_MODULE_BY_CATEGORY_H | ||
#define LLVM_TRANSFORM_UTILS_SPLIT_MODULE_BY_CATEGORY_H | ||
|
||
#include "llvm/ADT/STLFunctionalExtras.h" | ||
|
||
|
@@ -22,21 +22,23 @@ namespace llvm { | |
class Module; | ||
class Function; | ||
|
||
namespace sycl { | ||
|
||
/// FunctionCategorizer returns integer category for the given Function. | ||
/// Otherwise, it returns std::nullopt if function doesn't have a category. | ||
using FunctionCategorizer = function_ref<std::optional<int>(const Function &F)>; | ||
|
||
using PostSplitCallbackType = function_ref<void(std::unique_ptr<Module> Part)>; | ||
|
||
/// Splits the given module \p M. | ||
/// Every split image is being passed to \p Callback for further possible | ||
/// Splits the given module \p M using the given \p FunctionCategorizer. | ||
asudarsa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// \p FunctionCategorizer returns integer category for an input Function. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A side note, I think it'd be more helpful (at least putting on my AMD hat) to be able to determine where a global variable goes as well, if we'd like to make this pass generic to support all potential targets. The reason is, for AMDGPU, we probably need to categorize all functions that could potentially reference a global variable in the sam module, due to the lowering of LDS (shared) variables. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leave this for later. |
||
/// It may return std::nullopt if a function doesn't have a category. | ||
/// Module's functions are being grouped by categories. Every such group | ||
/// populates a call graph containing group's functions themselves and all | ||
/// reachable functions and globals. Split outputs are populated from each call | ||
/// graph associated with some category. | ||
maksimsab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// | ||
/// Every split output is being passed to \p Callback for further possible | ||
/// processing. | ||
void splitModuleByCategory(std::unique_ptr<Module> M, FunctionCategorizer FC, | ||
PostSplitCallbackType Callback); | ||
/// | ||
/// Currently, the supported targets are SPIRV, AMDGPU and NVPTX. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update this comment. I am not sure if the targets are restrictive. I think the restriction is whether the input module has recursive calls or not. Thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. Now we have call backs so it should just work for all. Update: This is probably because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes and the algorithm was implemented with assumption that the input is a heterogenous program, which usually don't have recursion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
FWIW, "usually" is doing the heavy lifting here. Please do not assume anything about GPU codes that is not required. So, recursion should be assumed to happen. |
||
void splitModuleByCategory( | ||
std::unique_ptr<Module> M, | ||
function_ref<std::optional<int>(const Function &F)> FunctionCategorizer, | ||
function_ref<void(std::unique_ptr<Module> Part)> Callback); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be helpful to pass the category to the callback in addition to the module. But if this is not needed right now, we can do this later. |
||
|
||
} // namespace sycl | ||
} // namespace llvm | ||
|
||
#endif // LLVM_FRONTEND_SYCL_SPLIT_MODULE_H | ||
#endif // LLVM_TRANSFORM_UTILS_SPLIT_MODULE_BY_CATEGORY_H |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.