forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 3
[SYCL][Graph] Add error checking to make_edge #264
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
Show all changes
6 commits
Select commit
Hold shift + click to select a range
01b56c6
[SYCL][Graph] Add error checking to make_edge
Bensuo 05c46ce
[SYCL][Graph] Prevent adding duplicate edges
Bensuo 5c45e18
[SYCL][Graph] Address PR feedback
Bensuo 26957f6
[SYCL][Graph] Add unit test for graph structure after a cycle is found
Bensuo e0dc49c
[SYCL][Graph] Add comment explaining visited nodes is unused.
Bensuo dcf0949
[SYCL][Graph] Skip cycle checks when dst has no successors
Bensuo 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// REQUIRES: level_zero, gpu | ||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out | ||
|
||
// Tests that introducing a cycle to the graph will throw when | ||
// property::graph::no_cycle_check is not passed to the graph constructor and | ||
// will not throw when it is. | ||
|
||
#include "../graph_common.hpp" | ||
|
||
void CreateGraphWithCyclesTest(bool DisableCycleChecks) { | ||
|
||
// If we are testing without cycle checks we need to do multiple iterations so | ||
// we can test multiple types of cycle, since introducing a cycle with no | ||
// checks may put the graph into an undefined state. | ||
const size_t Iterations = DisableCycleChecks ? 2 : 1; | ||
|
||
queue Queue; | ||
|
||
property_list Props; | ||
|
||
if (DisableCycleChecks) { | ||
Props = {ext::oneapi::experimental::property::graph::no_cycle_check{}}; | ||
} | ||
|
||
for (size_t i = 0; i < Iterations; i++) { | ||
ext::oneapi::experimental::command_graph Graph{Queue.get_context(), | ||
Queue.get_device(), Props}; | ||
|
||
auto NodeA = Graph.add([&](sycl::handler &CGH) { | ||
CGH.single_task<class testKernelA>([=]() {}); | ||
}); | ||
auto NodeB = Graph.add([&](sycl::handler &CGH) { | ||
CGH.single_task<class testKernelB>([=]() {}); | ||
}); | ||
auto NodeC = Graph.add([&](sycl::handler &CGH) { | ||
CGH.single_task<class testKernelC>([=]() {}); | ||
}); | ||
|
||
// Make normal edges | ||
std::error_code ErrorCode = sycl::make_error_code(sycl::errc::success); | ||
try { | ||
Graph.make_edge(NodeA, NodeB); | ||
Graph.make_edge(NodeB, NodeC); | ||
} catch (const sycl::exception &e) { | ||
ErrorCode = e.code(); | ||
} | ||
|
||
assert(ErrorCode == sycl::errc::success); | ||
|
||
// Introduce cycles to the graph. If we are performing cycle checks we can | ||
// test both cycles, if they are disabled we need to test one per iteration. | ||
if (i == 0 || !DisableCycleChecks) { | ||
ErrorCode = sycl::make_error_code(sycl::errc::success); | ||
try { | ||
Graph.make_edge(NodeC, NodeA); | ||
} catch (const sycl::exception &e) { | ||
ErrorCode = e.code(); | ||
} | ||
|
||
assert(ErrorCode == | ||
(DisableCycleChecks ? sycl::errc::success : sycl::errc::invalid)); | ||
} | ||
|
||
if (i == 1 || !DisableCycleChecks) { | ||
ErrorCode = sycl::make_error_code(sycl::errc::success); | ||
try { | ||
Graph.make_edge(NodeC, NodeB); | ||
} catch (const sycl::exception &e) { | ||
ErrorCode = e.code(); | ||
} | ||
|
||
assert(ErrorCode == | ||
(DisableCycleChecks ? sycl::errc::success : sycl::errc::invalid)); | ||
} | ||
} | ||
} | ||
|
||
int main() { | ||
// Test with cycle checks | ||
CreateGraphWithCyclesTest(false); | ||
// Test without cycle checks | ||
CreateGraphWithCyclesTest(true); | ||
|
||
return 0; | ||
} |
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.