forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL][Graph] Add exceptions on invalid event and queue usage (#250)
- Throws when waiting on a queue in recording mode - Throws when waiting on an event from a graph submission - Throws when calling depends_on with an event outside the graph - Add tests for these exceptions --------- Co-authored-by: Ewan Crawford <ewan@codeplay.com>
- Loading branch information
Showing
10 changed files
with
198 additions
and
7 deletions.
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
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
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,79 @@ | ||
// REQUIRES: level_zero, gpu | ||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out | ||
|
||
// Tests that calling handler::depends_on() for events not part of the graph | ||
// throws. | ||
|
||
#include "graph_common.hpp" | ||
|
||
int main() { | ||
queue Queue; | ||
|
||
ext::oneapi::experimental::command_graph Graph{Queue.get_context(), | ||
Queue.get_device()}; | ||
ext::oneapi::experimental::command_graph Graph2{Queue.get_context(), | ||
Queue.get_device()}; | ||
|
||
auto NormalEvent = Queue.submit( | ||
[&](handler &CGH) { CGH.single_task<class TestKernel1>([=]() {}); }); | ||
|
||
Graph2.begin_recording(Queue); | ||
|
||
auto OtherGraphEvent = Queue.submit( | ||
[&](handler &CGH) { CGH.single_task<class TestKernel2>([=]() {}); }); | ||
|
||
Graph2.end_recording(Queue); | ||
|
||
Graph.begin_recording(Queue); | ||
|
||
// Test that depends_on in explicit and record and replay throws from an event | ||
// outside any graph. | ||
|
||
std::error_code ErrorCode = make_error_code(sycl::errc::success); | ||
try { | ||
auto GraphEvent = Queue.submit([&](handler &CGH) { | ||
CGH.depends_on(NormalEvent); | ||
CGH.single_task<class TestKernel3>([=]() {}); | ||
}); | ||
} catch (const sycl::exception &e) { | ||
ErrorCode = e.code(); | ||
} | ||
assert(ErrorCode == sycl::errc::invalid); | ||
|
||
ErrorCode = make_error_code(sycl::errc::success); | ||
try { | ||
Graph.add([&](handler &CGH) { | ||
CGH.depends_on(NormalEvent); | ||
CGH.single_task<class TestKernel4>([=]() {}); | ||
}); | ||
} catch (const sycl::exception &e) { | ||
ErrorCode = e.code(); | ||
} | ||
assert(ErrorCode == sycl::errc::invalid); | ||
|
||
// Test that depends_on throws from an event from another graph. | ||
ErrorCode = make_error_code(sycl::errc::success); | ||
try { | ||
auto GraphEvent = Queue.submit([&](handler &CGH) { | ||
CGH.depends_on(OtherGraphEvent); | ||
CGH.single_task<class TestKernel5>([=]() {}); | ||
}); | ||
} catch (const sycl::exception &e) { | ||
ErrorCode = e.code(); | ||
} | ||
assert(ErrorCode == sycl::errc::invalid); | ||
|
||
ErrorCode = make_error_code(sycl::errc::success); | ||
try { | ||
Graph.add([&](handler &CGH) { | ||
CGH.depends_on(OtherGraphEvent); | ||
CGH.single_task<class TestKernel6>([=]() {}); | ||
}); | ||
} catch (const sycl::exception &e) { | ||
ErrorCode = e.code(); | ||
} | ||
assert(ErrorCode == sycl::errc::invalid); | ||
|
||
return 0; | ||
} |
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,31 @@ | ||
// REQUIRES: level_zero, gpu | ||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out | ||
|
||
// Tests that waiting on an event returned from a Record and Replay submission | ||
// throws. | ||
|
||
#include "graph_common.hpp" | ||
|
||
int main() { | ||
queue Queue; | ||
|
||
ext::oneapi::experimental::command_graph Graph{Queue.get_context(), | ||
Queue.get_device()}; | ||
Graph.begin_recording(Queue); | ||
|
||
auto GraphEvent = Queue.submit( | ||
[&](handler &CGH) { CGH.single_task<class TestKernel>([=]() {}); }); | ||
|
||
Graph.end_recording(Queue); | ||
|
||
std::error_code ErrorCode = make_error_code(sycl::errc::success); | ||
try { | ||
GraphEvent.wait(); | ||
} catch (const sycl::exception &e) { | ||
ErrorCode = e.code(); | ||
} | ||
assert(ErrorCode == sycl::errc::invalid); | ||
|
||
return 0; | ||
} |
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,26 @@ | ||
// REQUIRES: level_zero, gpu | ||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out | ||
|
||
// Tests that waiting on a Queue in recording mode throws. | ||
|
||
#include "graph_common.hpp" | ||
|
||
int main() { | ||
queue Queue; | ||
|
||
ext::oneapi::experimental::command_graph Graph{Queue.get_context(), | ||
Queue.get_device()}; | ||
Graph.begin_recording(Queue); | ||
|
||
std::error_code ErrorCode = make_error_code(sycl::errc::success); | ||
|
||
try { | ||
Queue.wait(); | ||
} catch (const sycl::exception &e) { | ||
ErrorCode = e.code(); | ||
} | ||
assert(ErrorCode == sycl::errc::invalid); | ||
|
||
return 0; | ||
} |
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