-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL][Graph] Support sycl_ext_oneapi_raw_kernel_arg #15252
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// 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 %} | ||
|
||
// REQUIRES: ocloc && level_zero | ||
|
||
#define GRAPH_E2E_EXPLICIT | ||
|
||
#include "../Inputs/raw_kernel_arg.cpp" |
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,49 @@ | ||
// Tests using a raw_kernel_arg with 32-bit sized scalars. | ||
|
||
#include "../graph_common.hpp" | ||
|
||
auto constexpr CLSource = R"===( | ||
__kernel void RawArgKernel(int scalar, __global int *out) { | ||
size_t id = get_global_id(0); | ||
out[id] = id + scalar; | ||
} | ||
)==="; | ||
|
||
int main() { | ||
queue Queue{}; | ||
|
||
auto SourceKB = | ||
sycl::ext::oneapi::experimental::create_kernel_bundle_from_source( | ||
Queue.get_context(), | ||
sycl::ext::oneapi::experimental::source_language::opencl, CLSource); | ||
auto ExecKB = sycl::ext::oneapi::experimental::build(SourceKB); | ||
|
||
exp_ext::command_graph Graph{Queue}; | ||
|
||
int32_t *Ptr = malloc_device<int32_t>(Size, Queue); | ||
Queue.memset(Ptr, 0, Size * sizeof(int32_t)).wait(); | ||
|
||
int32_t Scalar = 42; | ||
exp_ext::raw_kernel_arg RawScalar(&Scalar, sizeof(int32_t)); | ||
|
||
auto KernelNode = add_node(Graph, Queue, [&](handler &cgh) { | ||
cgh.set_arg(0, RawScalar); | ||
cgh.set_arg(1, Ptr); | ||
cgh.parallel_for(sycl::range<1>{Size}, | ||
ExecKB.ext_oneapi_get_kernel("RawArgKernel")); | ||
}); | ||
|
||
auto ExecGraph = Graph.finalize(); | ||
|
||
// Ptr should be filled with values based on Scalar | ||
Queue.ext_oneapi_graph(ExecGraph).wait(); | ||
|
||
std::vector<int32_t> HostData(Size); | ||
Queue.copy(Ptr, HostData.data(), Size).wait(); | ||
|
||
for (size_t i = 0; i < Size; i++) { | ||
assert(HostData[i] == (i + Scalar)); | ||
} | ||
|
||
return 0; | ||
} |
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,78 @@ | ||
// Tests whole graph update with raw argument extensions | ||
|
||
#include "../graph_common.hpp" | ||
|
||
void SubmitKernelNode( | ||
exp_ext::command_graph<exp_ext::graph_state::modifiable> Graph, queue Queue, | ||
int32_t *Ptr, exp_ext::raw_kernel_arg &RawArg) { | ||
|
||
auto constexpr CLSource = R"===( | ||
__kernel void RawArgKernel(int scalar, __global int *out) { | ||
size_t id = get_global_id(0); | ||
out[id] = id + scalar; | ||
} | ||
)==="; | ||
|
||
auto SourceKB = | ||
sycl::ext::oneapi::experimental::create_kernel_bundle_from_source( | ||
Queue.get_context(), | ||
sycl::ext::oneapi::experimental::source_language::opencl, CLSource); | ||
auto ExecKB = sycl::ext::oneapi::experimental::build(SourceKB); | ||
|
||
add_node(Graph, Queue, [&](handler &cgh) { | ||
cgh.set_arg(0, RawArg); | ||
cgh.set_arg(1, Ptr); | ||
cgh.parallel_for(sycl::range<1>{Size}, | ||
ExecKB.ext_oneapi_get_kernel("RawArgKernel")); | ||
}); | ||
} | ||
|
||
int main() { | ||
queue Queue{}; | ||
|
||
exp_ext::command_graph GraphA{Queue}; | ||
|
||
const size_t N = 1024; | ||
int32_t *PtrA = malloc_device<int32_t>(N, Queue); | ||
Queue.memset(PtrA, 0, N * sizeof(int32_t)).wait(); | ||
|
||
int32_t ScalarA = 42; | ||
sycl::ext::oneapi::experimental::raw_kernel_arg RawScalarA(&ScalarA, | ||
sizeof(int32_t)); | ||
|
||
SubmitKernelNode(GraphA, Queue, PtrA, RawScalarA); | ||
auto ExecGraphA = GraphA.finalize(exp_ext::property::graph::updatable{}); | ||
|
||
// PtrA should be filled with values based on ScalarA | ||
Queue.ext_oneapi_graph(ExecGraphA).wait(); | ||
|
||
std::vector<int32_t> HostDataA(N); | ||
Queue.copy(PtrA, HostDataA.data(), N).wait(); | ||
for (size_t i = 0; i < N; i++) { | ||
assert(HostDataA[i] == (i + ScalarA)); | ||
} | ||
|
||
exp_ext::command_graph GraphB{Queue.get_context(), Queue.get_device()}; | ||
|
||
int32_t *PtrB = malloc_device<int32_t>(N, Queue); | ||
Queue.memset(PtrB, 0, N * sizeof(int32_t)).wait(); | ||
|
||
int32_t ScalarB = 0xA; | ||
sycl::ext::oneapi::experimental::raw_kernel_arg RawScalarB(&ScalarB, | ||
sizeof(int32_t)); | ||
|
||
// Swap ScalarB and PtrB to be the new inputs/outputs | ||
SubmitKernelNode(GraphB, Queue, PtrB, RawScalarB); | ||
ExecGraphA.update(GraphB); | ||
Queue.ext_oneapi_graph(ExecGraphA).wait(); | ||
|
||
std::vector<int32_t> HostDataB(N); | ||
Queue.copy(PtrA, HostDataA.data(), N); | ||
Queue.copy(PtrB, HostDataB.data(), N); | ||
Queue.wait(); | ||
for (size_t i = 0; i < N; i++) { | ||
assert(HostDataA[i] == (i + ScalarA)); | ||
assert(HostDataB[i] == (i + ScalarB)); | ||
} | ||
return 0; | ||
} |
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,12 @@ | ||
// 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 %} | ||
|
||
// REQUIRES: ocloc && level_zero | ||
|
||
#define GRAPH_E2E_RECORD_REPLAY | ||
|
||
#include "../Inputs/raw_kernel_arg.cpp" |
12 changes: 12 additions & 0 deletions
12
sycl/test-e2e/Graph/Update/Explicit/whole_update_raw_arg.cpp
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,12 @@ | ||
// 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 %} | ||
|
||
// REQUIRES: ocloc && level_zero | ||
|
||
#define GRAPH_E2E_EXPLICIT | ||
|
||
#include "../../Inputs/whole_update_raw_arg.cpp" |
12 changes: 12 additions & 0 deletions
12
sycl/test-e2e/Graph/Update/RecordReplay/whole_update_raw_arg.cpp
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,12 @@ | ||
// 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 %} | ||
|
||
// REQUIRES: ocloc && level_zero | ||
|
||
#define GRAPH_E2E_RECORD_REPLAY | ||
|
||
#include "../../Inputs/whole_update_raw_arg.cpp" |
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,84 @@ | ||
// 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 %} | ||
|
||
// REQUIRES: ocloc && level_zero | ||
|
||
// Tests updating a raw_kernel_arg with 32-bit sized scalars. | ||
|
||
#include "../graph_common.hpp" | ||
|
||
auto constexpr CLSource = R"===( | ||
__kernel void RawArgKernel(int scalar, __global int *out) { | ||
size_t id = get_global_id(0); | ||
out[id] = id + scalar; | ||
} | ||
)==="; | ||
|
||
int main() { | ||
queue Queue{}; | ||
|
||
auto SourceKB = | ||
sycl::ext::oneapi::experimental::create_kernel_bundle_from_source( | ||
Queue.get_context(), | ||
sycl::ext::oneapi::experimental::source_language::opencl, CLSource); | ||
auto ExecKB = sycl::ext::oneapi::experimental::build(SourceKB); | ||
|
||
exp_ext::command_graph Graph{Queue}; | ||
|
||
const size_t N = 1024; | ||
int32_t *PtrA = malloc_device<int32_t>(N, Queue); | ||
int32_t *PtrB = malloc_device<int32_t>(N, Queue); | ||
Queue.memset(PtrA, 0, N * sizeof(int32_t)); | ||
Queue.memset(PtrB, 0, N * sizeof(int32_t)); | ||
Queue.wait(); | ||
|
||
int32_t ScalarA = 42; | ||
exp_ext::raw_kernel_arg RawScalarA(&ScalarA, sizeof(int32_t)); | ||
|
||
int32_t ScalarB = 0xA; | ||
exp_ext::raw_kernel_arg RawScalarB(&ScalarB, sizeof(int32_t)); | ||
|
||
exp_ext::dynamic_parameter PtrParam(Graph, PtrA); | ||
exp_ext::dynamic_parameter ScalarParam(Graph, RawScalarA); | ||
|
||
auto KernelNode = Graph.add([&](handler &cgh) { | ||
cgh.set_arg(0, ScalarParam); | ||
cgh.set_arg(1, PtrParam); | ||
cgh.parallel_for(sycl::range<1>{Size}, | ||
ExecKB.ext_oneapi_get_kernel("RawArgKernel")); | ||
}); | ||
|
||
auto ExecGraph = Graph.finalize(exp_ext::property::graph::updatable{}); | ||
|
||
// PtrA should be filled with values based on ScalarA | ||
Queue.ext_oneapi_graph(ExecGraph).wait(); | ||
|
||
std::vector<int> HostDataA(N); | ||
std::vector<int> HostDataB(N); | ||
|
||
Queue.copy(PtrA, HostDataA.data(), N); | ||
Queue.copy(PtrB, HostDataB.data(), N); | ||
Queue.wait(); | ||
for (size_t i = 0; i < N; i++) { | ||
assert(HostDataA[i] == (i + ScalarA)); | ||
assert(HostDataB[i] == 0); | ||
} | ||
|
||
// Swap ScalarB and PtrB to be the new inputs/outputs | ||
PtrParam.update(PtrB); | ||
ScalarParam.update(RawScalarB); | ||
ExecGraph.update(KernelNode); | ||
Queue.ext_oneapi_graph(ExecGraph).wait(); | ||
|
||
Queue.copy(PtrA, HostDataA.data(), N).wait(); | ||
Queue.copy(PtrB, HostDataB.data(), N).wait(); | ||
for (size_t i = 0; i < N; i++) { | ||
assert(HostDataA[i] == (i + ScalarA)); | ||
assert(HostDataB[i] == (i + ScalarB)); | ||
} | ||
return 0; | ||
} |
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
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.