-
Notifications
You must be signed in to change notification settings - Fork 750
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
[ESIMD] Add set_kernel_properties API and use_double_grf property. #6182
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2e1f97b
[ESIMD] Add set_kernel_properties API and use_double_grf property.
kbobrovs 878cbe3
address review comments
kbobrovs 62879a7
Merge remote-tracking branch 'intel/sycl' into double_grf
kbobrovs 1b5b29f
merge with upstream, move double GRF prop detection into a pass
kbobrovs 4dd50e5
Merge remote-tracking branch 'intel/sycl' into double_grf
kbobrovs 4cda64f
Fix properties propagation
kbobrovs d77bf6e
Fix test failures
kbobrovs c6710c5
clang-format
kbobrovs c8f61b8
Fix Linux build, remove old PM-related code, add specific kernel prop…
kbobrovs 0db3b87
fix typo in comment
kbobrovs b0e8621
Merge remote-tracking branch 'intel/sycl' into double_grf
kbobrovs 9c1e483
One more _NDEBUG -> NDEBUG
kbobrovs 830619e
- When doing nested split of a module, the entry point is now limited to
kbobrovs 6b059f7
Fix/add more comments.
kbobrovs 3918b02
remove unneeded change
kbobrovs 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 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,39 @@ | ||
//===----------- ESIMDUtils.hpp - ESIMD t-forms-related 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 processing ESIMD code. | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "llvm/IR/Function.h" | ||
|
||
#include <functional> | ||
|
||
namespace llvm { | ||
namespace esimd { | ||
|
||
constexpr char ATTR_DOUBLE_GRF[] = "esimd-double-grf"; | ||
|
||
using CallGraphNodeAction = std::function<void(Function *)>; | ||
void traverseCallgraphUp(llvm::Function *F, CallGraphNodeAction NodeF, | ||
bool ErrorOnNonCallUse); | ||
|
||
// Traverses call graph starting from given function up the call chain applying | ||
// given action to each function met on the way. If \c ErrorOnNonCallUse | ||
// parameter is true, then no functions' uses are allowed except calls. | ||
// Otherwise, any function where use of the current one happened is added to the | ||
// call graph as if the use was a call. | ||
template <class CallGraphNodeActionF> | ||
void traverseCallgraphUp(Function *F, CallGraphNodeActionF ActionF, | ||
bool ErrorOnNonCallUse = true) { | ||
traverseCallgraphUp(F, CallGraphNodeAction{ActionF}, ErrorOnNonCallUse); | ||
} | ||
|
||
// Tells whether given function is a ESIMD kernel. | ||
bool isESIMDKernel(const Function &F); | ||
|
||
} // namespace esimd | ||
} // namespace llvm |
This file contains 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
This file contains 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
This file contains 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
This file contains 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,68 @@ | ||
#include "llvm/SYCLLowerIR/ESIMD/ESIMDUtils.h" | ||
|
||
#include "llvm/ADT/SmallPtrSet.h" | ||
#include "llvm/ADT/SmallVector.h" | ||
#include "llvm/IR/Instructions.h" | ||
#include "llvm/Support/Casting.h" | ||
|
||
namespace llvm { | ||
namespace esimd { | ||
|
||
void traverseCallgraphUp(llvm::Function *F, CallGraphNodeAction ActionF, | ||
bool ErrorOnNonCallUse) { | ||
SmallPtrSet<Function *, 32> FunctionsVisited; | ||
SmallVector<Function *, 32> Worklist{F}; | ||
|
||
while (!Worklist.empty()) { | ||
Function *CurF = Worklist.pop_back_val(); | ||
FunctionsVisited.insert(CurF); | ||
// Apply the action function. | ||
ActionF(CurF); | ||
|
||
// Update all callers as well. | ||
for (auto It = CurF->use_begin(); It != CurF->use_end(); It++) { | ||
auto FCall = It->getUser(); | ||
auto ErrMsg = | ||
llvm::Twine(__FILE__ " ") + | ||
"Function use other than call detected while traversing call\n" | ||
"graph up to a kernel"; | ||
if (!isa<CallInst>(FCall)) { | ||
// A use other than a call is met... | ||
if (ErrorOnNonCallUse) { | ||
// ... non-call is an error - report | ||
llvm::report_fatal_error(ErrMsg); | ||
} else { | ||
// ... non-call is OK - add using function to the worklist | ||
if (auto *I = dyn_cast<Instruction>(FCall)) { | ||
auto UseF = I->getFunction(); | ||
|
||
if (!FunctionsVisited.count(UseF)) { | ||
Worklist.push_back(UseF); | ||
} | ||
} | ||
} | ||
} else { | ||
auto *CI = cast<CallInst>(FCall); | ||
|
||
if ((CI->getCalledFunction() != CurF) && ErrorOnNonCallUse) { | ||
// CurF is used in a call, but not as the callee. | ||
llvm::report_fatal_error(ErrMsg); | ||
} else { | ||
auto FCaller = CI->getFunction(); | ||
|
||
if (!FunctionsVisited.count(FCaller)) { | ||
Worklist.push_back(FCaller); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
bool isESIMDKernel(const Function &F) { | ||
return (F.getCallingConv() == CallingConv::SPIR_KERNEL) && | ||
(F.getMetadata("sycl_explicit_simd") != nullptr); | ||
} | ||
|
||
} // namespace esimd | ||
} // namespace llvm |
This file contains 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refactors the original
updateGenXMDNodes
:traverseCallgraphUp
above. This functor represents call graph action.