-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Clean up finished command nodes of the execution graph #1066
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 all commits
Commits
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
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
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
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,92 @@ | ||
// RUN: %clangxx -fsycl %s -o %t.out | ||
// RUN: %t.out | ||
#include <CL/sycl.hpp> | ||
|
||
#include <algorithm> | ||
#include <vector> | ||
|
||
#include "SchedulerTestUtils.hpp" | ||
|
||
using namespace cl::sycl; | ||
|
||
// This test checks regular execution graph cleanup at host-device | ||
// synchronization points | ||
int main() { | ||
TestScheduler TS; | ||
queue Queue; | ||
buffer<int, 1> BufA(range<1>(1)); | ||
buffer<int, 1> BufB(range<1>(1)); | ||
buffer<int, 1> BufC(range<1>(1)); | ||
detail::Requirement FakeReqA = getFakeRequirement(BufA); | ||
detail::Requirement FakeReqB = getFakeRequirement(BufB); | ||
detail::Requirement FakeReqC = getFakeRequirement(BufC); | ||
detail::MemObjRecord *RecC = | ||
TS.getOrInsertMemObjRecord(detail::getSyclObjImpl(Queue), &FakeReqC); | ||
|
||
// Create a graph and check that all inner nodes have been deleted and | ||
// their users have had the corresponding dependency replaced with a | ||
// dependency on the alloca. The graph should undergo the following | ||
// transformation: | ||
// +---------+ +---------+ +---------++---------+ | ||
// | LeafA | <-- | InnerA | | LeafA || LeafB | | ||
// +---------+ +---------+ +---------++---------+ | ||
// | | | | | ||
// | | ===> | | | ||
// v v v v | ||
// +---------+ +---------+ +---------++---------+ | ||
// | InnerC | | InnerB | | AllocaA || AllocaB | | ||
// +---------+ +---------+ +---------++---------+ | ||
// | | | ||
// | | | ||
// v v | ||
// +---------+ +---------+ | ||
// | AllocaA | | LeafB | | ||
// +---------+ +---------+ | ||
// | | ||
// | | ||
// v | ||
// +---------+ | ||
// | AllocaB | | ||
// +---------+ | ||
detail::AllocaCommand AllocaA{detail::getSyclObjImpl(Queue), FakeReqA}; | ||
detail::AllocaCommand AllocaB{detail::getSyclObjImpl(Queue), FakeReqB}; | ||
|
||
int NInnerCommandsAlive = 3; | ||
std::function<void()> Callback = [&]() { --NInnerCommandsAlive; }; | ||
|
||
FakeCommand *InnerC = new FakeCommandWithCallback( | ||
detail::getSyclObjImpl(Queue), FakeReqA, Callback); | ||
addEdge(InnerC, &AllocaA, &AllocaA); | ||
|
||
FakeCommand LeafB{detail::getSyclObjImpl(Queue), FakeReqB}; | ||
addEdge(&LeafB, &AllocaB, &AllocaB); | ||
TS.AddNodeToLeaves(RecC, &LeafB); | ||
|
||
FakeCommand LeafA{detail::getSyclObjImpl(Queue), FakeReqA}; | ||
addEdge(&LeafA, InnerC, &AllocaA); | ||
TS.AddNodeToLeaves(RecC, &LeafA); | ||
|
||
FakeCommand *InnerB = new FakeCommandWithCallback( | ||
detail::getSyclObjImpl(Queue), FakeReqB, Callback); | ||
addEdge(InnerB, &LeafB, &AllocaB); | ||
|
||
FakeCommand *InnerA = new FakeCommandWithCallback( | ||
detail::getSyclObjImpl(Queue), FakeReqA, Callback); | ||
addEdge(InnerA, &LeafA, &AllocaA); | ||
addEdge(InnerA, InnerB, &AllocaB); | ||
|
||
TS.cleanupFinishedCommands(InnerA); | ||
TS.removeRecordForMemObj(detail::getSyclObjImpl(BufC).get()); | ||
|
||
assert(NInnerCommandsAlive == 0); | ||
|
||
assert(LeafA.MDeps.size() == 1); | ||
assert(LeafA.MDeps[0].MDepCommand == &AllocaA); | ||
assert(AllocaA.MUsers.size() == 1); | ||
assert(*AllocaA.MUsers.begin() == &LeafA); | ||
|
||
assert(LeafB.MDeps.size() == 1); | ||
assert(LeafB.MDeps[0].MDepCommand == &AllocaB); | ||
assert(AllocaB.MUsers.size() == 1); | ||
assert(*AllocaB.MUsers.begin() == &LeafB); | ||
} |
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.