Skip to content

[SYCL][Fusion] Error if fusion unsupported on device #12171

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sycl/source/detail/device_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,8 +1009,13 @@ struct get_device_info_impl<
#if SYCL_EXT_CODEPLAY_KERNEL_FUSION
// Currently fusion is only supported for SPIR-V based backends,
// CUDA and HIP.
if (Dev->getBackend() == backend::opencl) {
// Exclude all non-CPU or non-GPU devices on OpenCL, in particular
// accelerators.
return Dev->is_cpu() || Dev->is_gpu();
}

return (Dev->getBackend() == backend::ext_oneapi_level_zero) ||
(Dev->getBackend() == backend::opencl) ||
(Dev->getBackend() == backend::ext_oneapi_cuda) ||
(Dev->getBackend() == backend::ext_oneapi_hip);
#else // SYCL_EXT_CODEPLAY_KERNEL_FUSION
Expand Down
9 changes: 9 additions & 0 deletions sycl/source/detail/queue_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <sycl/event.hpp>
#include <sycl/exception.hpp>
#include <sycl/exception_list.hpp>
#include <sycl/ext/codeplay/experimental/fusion_properties.hpp>
#include <sycl/handler.hpp>
#include <sycl/properties/context_properties.hpp>
#include <sycl/properties/queue_properties.hpp>
Expand Down Expand Up @@ -146,6 +147,14 @@ class queue_impl {
"Queue compute index must be a non-negative number less than "
"device's number of available compute queue indices.");
}
if (has_property<
ext::codeplay::experimental::property::queue::enable_fusion>() &&
!MDevice->get_info<
ext::codeplay::experimental::info::device::supports_fusion>()) {
throw sycl::exception(
make_error_code(errc::invalid),
"Cannot enable fusion if device does not support fusion");
}
if (!Context->isDeviceValid(Device)) {
if (!Context->is_host() && Context->getBackend() == backend::opencl)
throw sycl::invalid_object_error(
Expand Down
7 changes: 7 additions & 0 deletions sycl/test-e2e/KernelFusion/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import platform

config.unsupported_features += ['accelerator']

# TODO: enable on Windows once kernel fusion is supported on Windows.
if platform.system() != "Linux":
config.unsupported = True
10 changes: 9 additions & 1 deletion sycl/unittests/Extensions/CommandGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,15 @@ TEST_F(CommandGraphTest, DependencyLeavesKeyword4) {
}

TEST_F(CommandGraphTest, FusionExtensionExceptionCheck) {
queue Q{ext::codeplay::experimental::property::queue::enable_fusion{}};
device D;
if (!D.get_info<
ext::codeplay::experimental::info::device::supports_fusion>()) {
// Skip this test if the device does not support fusion. Otherwise, the
// queue construction in the next step would fail.
GTEST_SKIP();
}

queue Q{D, ext::codeplay::experimental::property::queue::enable_fusion{}};

experimental::command_graph<experimental::graph_state::modifiable> Graph{
Q.get_context(), Q.get_device()};
Expand Down