forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL][Graph] Test WGU kernel mismatch (intel#14379)
We cannot currently update the kernel binary of a node in Whole Graph Update. Rather than silently accepting inconsistent kernel functions, which indicates the graphs aren't topologically identical, throw an error when the kernel types of two nodes are mismatched. This change requires removing the unittest for barrier nodes in Whole Graph Update as the mock infrastructure does not setup the internal `CG` class to the depth required to test working functionality. This functionality is already covered by `test-e2e/Graph/Update/whole_update_barrier_node.cpp`
- Loading branch information
Showing
4 changed files
with
149 additions
and
46 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
103 changes: 103 additions & 0 deletions
103
sycl/test-e2e/Graph/Update/whole_update_kernel_type_mismatch.cpp
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,103 @@ | ||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out | ||
// Extra run to check for leaks in Level Zero using UR_L0_LEAKS_DEBUG | ||
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %} | ||
// Extra run to check for immediate-command-list in Level Zero | ||
// RUN: %if level_zero %{env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 %{l0_leak_check} %{run} %t.out 2>&1 | FileCheck %s --implicit-check-not=LEAK %} | ||
|
||
// Test that an error is thrown when the types of kernels do not match in Whole | ||
// Graph Update | ||
|
||
#include "../graph_common.hpp" | ||
|
||
void testFunctors(queue Queue, int *Data) { | ||
exp_ext::command_graph Graph{Queue}; | ||
exp_ext::command_graph UpdateGraph{Queue}; | ||
struct KernelFunctorA { | ||
KernelFunctorA(int *Data) : Data(Data) {} | ||
|
||
void operator()() const { Data[0] = 42; } | ||
|
||
int *Data; | ||
}; | ||
|
||
struct KernelFunctorB { | ||
KernelFunctorB(int *Data) : Data(Data) {} | ||
void operator()() const { Data[0] = 42; } | ||
|
||
int *Data; | ||
}; | ||
|
||
Graph.add([&](handler &CGH) { CGH.single_task(KernelFunctorA{Data}); }); | ||
|
||
UpdateGraph.add([&](handler &CGH) { CGH.single_task(KernelFunctorB{Data}); }); | ||
|
||
auto GraphExec = Graph.finalize(exp_ext::property::graph::updatable{}); | ||
|
||
// Check it's an error if kernel types don't match | ||
std::error_code ErrorCode = make_error_code(sycl::errc::success); | ||
try { | ||
GraphExec.update(UpdateGraph); | ||
} catch (const sycl::exception &e) { | ||
ErrorCode = e.code(); | ||
} | ||
assert(ErrorCode == sycl::errc::invalid); | ||
} | ||
|
||
void testUnNamedLambdas(queue Queue, int *Data) { | ||
exp_ext::command_graph Graph{Queue}; | ||
exp_ext::command_graph UpdateGraph{Queue}; | ||
|
||
Graph.add([&](handler &CGH) { CGH.single_task([=]() { Data[0] = 42; }); }); | ||
|
||
UpdateGraph.add( | ||
[&](handler &CGH) { CGH.single_task([=]() { Data[0] = 42; }); }); | ||
|
||
auto GraphExec = Graph.finalize(exp_ext::property::graph::updatable{}); | ||
|
||
// Check it's an error if kernel types don't match | ||
std::error_code ErrorCode = make_error_code(sycl::errc::success); | ||
try { | ||
GraphExec.update(UpdateGraph); | ||
} catch (const sycl::exception &e) { | ||
ErrorCode = e.code(); | ||
} | ||
assert(ErrorCode == sycl::errc::invalid); | ||
} | ||
void testNamedLambdas(queue Queue, int *Data) { | ||
exp_ext::command_graph Graph{Queue}; | ||
exp_ext::command_graph UpdateGraph{Queue}; | ||
|
||
auto LambdaA = [=]() { Data[0] = 42; }; | ||
|
||
Graph.add([&](handler &CGH) { CGH.single_task<class TestLambdaA>(LambdaA); }); | ||
|
||
auto LambdaB = [=]() { Data[0] = 42; }; | ||
|
||
UpdateGraph.add( | ||
[&](handler &CGH) { CGH.single_task<class TestLambdaB>(LambdaB); }); | ||
|
||
auto GraphExec = Graph.finalize(exp_ext::property::graph::updatable{}); | ||
|
||
// Check it's an error if kernel types don't match | ||
std::error_code ErrorCode = make_error_code(sycl::errc::success); | ||
try { | ||
GraphExec.update(UpdateGraph); | ||
} catch (const sycl::exception &e) { | ||
ErrorCode = e.code(); | ||
} | ||
assert(ErrorCode == sycl::errc::invalid); | ||
} | ||
|
||
int main() { | ||
queue Queue{}; | ||
int *Data = malloc_device<int>(1, Queue); | ||
|
||
testNamedLambdas(Queue, Data); | ||
testUnNamedLambdas(Queue, Data); | ||
testFunctors(Queue, Data); | ||
|
||
sycl::free(Data, Queue); | ||
|
||
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