-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL][Graph] Enable use of kernel properties #12062
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
steffenlarsen
merged 3 commits into
intel:sycl
from
reble:maxime/kernel_properties_extension_support
Dec 8, 2023
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// RUN: %{build} -fsycl-device-code-split=per_kernel -o %t.out | ||
// RUN: %{run} %t.out | ||
// Extra run to check for leaks in Level Zero using UR_L0_LEAKS_DEBUG | ||
// RUN: %if ext_oneapi_level_zero %{env UR_L0_LEAKS_DEBUG=1 %{run} %t.out 2>&1 | FileCheck %s %} | ||
// | ||
// CHECK-NOT: LEAK | ||
|
||
#define GRAPH_E2E_EXPLICIT | ||
|
||
#include "../Inputs/sub_group_prop.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,15 @@ | ||
// 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 ext_oneapi_level_zero %{env UR_L0_LEAKS_DEBUG=1 %{run} %t.out 2>&1 | FileCheck %s %} | ||
// | ||
// CHECK-NOT: LEAK | ||
|
||
// Temporarily disabled for CUDA. | ||
// XFAIL: cuda | ||
// Note: failing negative test with HIP in the original test | ||
// TODO: disable hip when HIP backend will be supported by Graph | ||
|
||
#define GRAPH_E2E_EXPLICIT | ||
|
||
#include "../Inputs/work_group_size_prop.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,160 @@ | ||
// This test is adapted from "test-e2e/Basic/sub_group_size_prop.cpp" | ||
|
||
#include "../graph_common.hpp" | ||
|
||
enum class Variant { Function, Functor, FunctorAndProperty }; | ||
|
||
template <Variant KernelVariant, size_t SGSize> class SubGroupKernel; | ||
|
||
template <size_t SGSize> struct KernelFunctorWithSGSizeProp { | ||
accessor<size_t, 1, access_mode::write> Acc; | ||
|
||
KernelFunctorWithSGSizeProp(accessor<size_t, 1, access_mode::write> Acc) | ||
: Acc(Acc) {} | ||
|
||
void operator()(nd_item<1> NdItem) const { | ||
auto SG = NdItem.get_sub_group(); | ||
if (NdItem.get_global_linear_id() == 0) | ||
Acc[0] = SG.get_local_linear_range(); | ||
} | ||
|
||
auto get(sycl::ext::oneapi::experimental::properties_tag) { | ||
return sycl::ext::oneapi::experimental::properties{ | ||
sycl::ext::oneapi::experimental::sub_group_size<SGSize>}; | ||
} | ||
}; | ||
|
||
template <size_t SGSize> | ||
void test(queue &Queue, const std::vector<size_t> SupportedSGSizes) { | ||
std::cout << "Testing sub_group_size property for sub-group size=" << SGSize | ||
<< std::endl; | ||
|
||
auto SGSizeSupported = | ||
std::find(SupportedSGSizes.begin(), SupportedSGSizes.end(), SGSize) != | ||
SupportedSGSizes.end(); | ||
if (!SGSizeSupported) { | ||
std::cout << "Sub-group size " << SGSize | ||
<< " is not supported on the device." << std::endl; | ||
return; | ||
} | ||
|
||
auto Props = ext::oneapi::experimental::properties{ | ||
ext::oneapi::experimental::sub_group_size<SGSize>}; | ||
|
||
nd_range<1> NdRange(SGSize * 4, SGSize * 2); | ||
|
||
size_t ReadSubGroupSize = 0; | ||
{ | ||
buffer ReadSubGroupSizeBuf(&ReadSubGroupSize, range(1)); | ||
ReadSubGroupSizeBuf.set_write_back(false); | ||
|
||
{ | ||
exp_ext::command_graph Graph{ | ||
Queue.get_context(), | ||
Queue.get_device(), | ||
{exp_ext::property::graph::assume_buffer_outlives_graph{}}}; | ||
|
||
add_node(Graph, Queue, [&](handler &CGH) { | ||
accessor ReadSubGroupSizeBufAcc{ReadSubGroupSizeBuf, CGH, | ||
sycl::write_only, sycl::no_init}; | ||
|
||
CGH.parallel_for<SubGroupKernel<Variant::Function, SGSize>>( | ||
NdRange, Props, [=](nd_item<1> NdItem) { | ||
auto SG = NdItem.get_sub_group(); | ||
if (NdItem.get_global_linear_id() == 0) | ||
ReadSubGroupSizeBufAcc[0] = SG.get_local_linear_range(); | ||
}); | ||
}); | ||
|
||
auto ExecGraph = Graph.finalize(); | ||
Queue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(ExecGraph); }); | ||
Queue.wait_and_throw(); | ||
} | ||
|
||
host_accessor HostAcc(ReadSubGroupSizeBuf); | ||
ReadSubGroupSize = HostAcc[0]; | ||
} | ||
assert(ReadSubGroupSize == SGSize && "Failed check for function."); | ||
|
||
ReadSubGroupSize = 0; | ||
{ | ||
buffer ReadSubGroupSizeBuf(&ReadSubGroupSize, range(1)); | ||
ReadSubGroupSizeBuf.set_write_back(false); | ||
|
||
{ | ||
exp_ext::command_graph Graph{ | ||
Queue.get_context(), | ||
Queue.get_device(), | ||
{exp_ext::property::graph::assume_buffer_outlives_graph{}}}; | ||
|
||
add_node(Graph, Queue, [&](handler &CGH) { | ||
accessor ReadSubGroupSizeBufAcc{ReadSubGroupSizeBuf, CGH, | ||
sycl::write_only, sycl::no_init}; | ||
KernelFunctorWithSGSizeProp<SGSize> KernelFunctor{ | ||
ReadSubGroupSizeBufAcc}; | ||
|
||
CGH.parallel_for<SubGroupKernel<Variant::Functor, SGSize>>( | ||
NdRange, KernelFunctor); | ||
}); | ||
|
||
auto ExecGraph = Graph.finalize(); | ||
Queue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(ExecGraph); }); | ||
Queue.wait_and_throw(); | ||
} | ||
|
||
host_accessor HostAcc(ReadSubGroupSizeBuf); | ||
ReadSubGroupSize = HostAcc[0]; | ||
} | ||
assert(ReadSubGroupSize == SGSize && "Failed check for functor."); | ||
|
||
ReadSubGroupSize = 0; | ||
{ | ||
buffer ReadSubGroupSizeBuf(&ReadSubGroupSize, range(1)); | ||
ReadSubGroupSizeBuf.set_write_back(false); | ||
|
||
{ | ||
exp_ext::command_graph Graph{ | ||
Queue.get_context(), | ||
Queue.get_device(), | ||
{exp_ext::property::graph::assume_buffer_outlives_graph{}}}; | ||
|
||
add_node(Graph, Queue, [&](handler &CGH) { | ||
accessor ReadSubGroupSizeBufAcc{ReadSubGroupSizeBuf, CGH, | ||
sycl::write_only, sycl::no_init}; | ||
KernelFunctorWithSGSizeProp<SGSize> KernelFunctor{ | ||
ReadSubGroupSizeBufAcc}; | ||
|
||
CGH.parallel_for<SubGroupKernel<Variant::Functor, SGSize>>( | ||
NdRange, Props, KernelFunctor); | ||
}); | ||
|
||
auto ExecGraph = Graph.finalize(); | ||
Queue.submit([&](handler &CGH) { CGH.ext_oneapi_graph(ExecGraph); }); | ||
Queue.wait_and_throw(); | ||
} | ||
|
||
host_accessor HostAcc(ReadSubGroupSizeBuf); | ||
ReadSubGroupSize = HostAcc[0]; | ||
} | ||
assert(ReadSubGroupSize == SGSize && | ||
"Failed check for functor and properties."); | ||
} | ||
|
||
int main() { | ||
queue Queue({sycl::ext::intel::property::queue::no_immediate_command_list{}}); | ||
|
||
if (!are_graphs_supported(Queue)) { | ||
return 0; | ||
} | ||
|
||
std::vector<size_t> SupportedSGSizes = | ||
Queue.get_device().get_info<info::device::sub_group_sizes>(); | ||
|
||
test<1>(Queue, SupportedSGSizes); | ||
test<8>(Queue, SupportedSGSizes); | ||
test<16>(Queue, SupportedSGSizes); | ||
test<32>(Queue, SupportedSGSizes); | ||
test<64>(Queue, SupportedSGSizes); | ||
|
||
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.