-
Notifications
You must be signed in to change notification settings - Fork 745
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 testing for sycl_ext_oneapi_local_memory (#16379)
- Adds testing that verifies the interaction between sycl_ext_oneapi_local_memory and sycl_ext_oneapi_graph. - Reorder the extensions in the sycl graph spec to be listed in alphabetical order. - Explicitly state in the sycl graph spec that using sycl_ext_oneapi_local_memory is supported.
- Loading branch information
1 parent
839f0af
commit 2a97b05
Showing
4 changed files
with
168 additions
and
69 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
10 changes: 10 additions & 0 deletions
10
sycl/test-e2e/Graph/Explicit/compile_time_local_memory.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,10 @@ | ||
// 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 %} | ||
|
||
#define GRAPH_E2E_EXPLICIT | ||
|
||
#include "../Inputs/compile_time_local_memory.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,73 @@ | ||
// Tests adding kernel nodes with local memory that is allocated using | ||
// the sycl_ext_oneapi_local_memory extension. | ||
|
||
#include "../graph_common.hpp" | ||
#include <sycl/ext/oneapi/group_local_memory.hpp> | ||
|
||
int main() { | ||
queue Queue{}; | ||
|
||
using T = int; | ||
constexpr size_t LocalSize = 128; | ||
|
||
std::vector<T> HostData(Size); | ||
std::iota(HostData.begin(), HostData.end(), 10); | ||
|
||
exp_ext::command_graph Graph{Queue.get_context(), Queue.get_device()}; | ||
|
||
T *PtrA = malloc_device<T>(Size, Queue); | ||
|
||
Queue.copy(HostData.data(), PtrA, Size); | ||
Queue.wait_and_throw(); | ||
|
||
auto NodeA = add_node(Graph, Queue, [&](handler &CGH) { | ||
CGH.parallel_for(nd_range({Size}, {LocalSize}), [=](nd_item<1> Item) { | ||
multi_ptr<size_t[LocalSize], access::address_space::local_space> | ||
LocalMem = sycl::ext::oneapi::group_local_memory<size_t[LocalSize]>( | ||
Item.get_group()); | ||
*LocalMem[Item.get_local_linear_id()] = Item.get_global_linear_id() * 2; | ||
PtrA[Item.get_global_linear_id()] += | ||
*LocalMem[Item.get_local_linear_id()]; | ||
}); | ||
}); | ||
|
||
add_node( | ||
Graph, Queue, | ||
[&](handler &CGH) { | ||
depends_on_helper(CGH, NodeA); | ||
CGH.parallel_for(nd_range({Size}, {LocalSize}), [=](nd_item<1> Item) { | ||
multi_ptr<size_t[LocalSize], access::address_space::local_space> | ||
LocalMem = sycl::ext::oneapi::group_local_memory_for_overwrite< | ||
size_t[LocalSize]>(Item.get_group()); | ||
*LocalMem[Item.get_local_linear_id()] = | ||
Item.get_global_linear_id() + 4; | ||
PtrA[Item.get_global_linear_id()] *= | ||
*LocalMem[Item.get_local_linear_id()]; | ||
}); | ||
}, | ||
NodeA); | ||
|
||
auto GraphExec = Graph.finalize(); | ||
|
||
for (unsigned n = 0; n < Iterations; n++) { | ||
Queue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(GraphExec); }); | ||
} | ||
|
||
Queue.wait_and_throw(); | ||
|
||
Queue.copy(PtrA, HostData.data(), Size); | ||
Queue.wait_and_throw(); | ||
|
||
free(PtrA, Queue); | ||
|
||
for (size_t i = 0; i < Size; i++) { | ||
T Ref = 10 + i; | ||
for (size_t iter = 0; iter < Iterations; ++iter) { | ||
Ref += (i * 2); | ||
Ref *= (i + 4); | ||
} | ||
assert(check_value(i, Ref, HostData[i], "PtrA")); | ||
} | ||
|
||
return 0; | ||
} |
10 changes: 10 additions & 0 deletions
10
sycl/test-e2e/Graph/RecordReplay/compile_time_local_memory.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,10 @@ | ||
// 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 %} | ||
|
||
#define GRAPH_E2E_RECORD_REPLAY | ||
|
||
#include "../Inputs/compile_time_local_memory.cpp" |