Skip to content

Commit 70f0835

Browse files
authored
[SYCL][Fusion] Error if fusion unsupported on device (#12171)
The kernel fusion extension document says that an error will be thrown if a `queue` is constructed with `sycl::ext::codeplay::experimental::property::queue::enable_fusion`, but the underlying device does not support fusion (i.e., returns false for `get_info<sycl::ext::codeplay::experimental::info::device::supports_fusion>()`). This change implements this behavior. Also, kernel fusion is currently not supported for SYCL devices of device type accelerator, as devices such as FPGAs do not support JIT compilation at runtime. Therefore, mark all end-to-end tests related to kernel fusion as unsupported for devices of type accelerator. In addition, use the newly created file to make the fact that kernel fusion is currently unsupported on Windows more explicit. --------- Signed-off-by: Lukas Sommer <[email protected]>
1 parent 31d5579 commit 70f0835

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

sycl/source/detail/device_info.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,8 +1009,13 @@ struct get_device_info_impl<
10091009
#if SYCL_EXT_CODEPLAY_KERNEL_FUSION
10101010
// Currently fusion is only supported for SPIR-V based backends,
10111011
// CUDA and HIP.
1012+
if (Dev->getBackend() == backend::opencl) {
1013+
// Exclude all non-CPU or non-GPU devices on OpenCL, in particular
1014+
// accelerators.
1015+
return Dev->is_cpu() || Dev->is_gpu();
1016+
}
1017+
10121018
return (Dev->getBackend() == backend::ext_oneapi_level_zero) ||
1013-
(Dev->getBackend() == backend::opencl) ||
10141019
(Dev->getBackend() == backend::ext_oneapi_cuda) ||
10151020
(Dev->getBackend() == backend::ext_oneapi_hip);
10161021
#else // SYCL_EXT_CODEPLAY_KERNEL_FUSION

sycl/source/detail/queue_impl.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <sycl/event.hpp>
2626
#include <sycl/exception.hpp>
2727
#include <sycl/exception_list.hpp>
28+
#include <sycl/ext/codeplay/experimental/fusion_properties.hpp>
2829
#include <sycl/handler.hpp>
2930
#include <sycl/properties/context_properties.hpp>
3031
#include <sycl/properties/queue_properties.hpp>
@@ -146,6 +147,14 @@ class queue_impl {
146147
"Queue compute index must be a non-negative number less than "
147148
"device's number of available compute queue indices.");
148149
}
150+
if (has_property<
151+
ext::codeplay::experimental::property::queue::enable_fusion>() &&
152+
!MDevice->get_info<
153+
ext::codeplay::experimental::info::device::supports_fusion>()) {
154+
throw sycl::exception(
155+
make_error_code(errc::invalid),
156+
"Cannot enable fusion if device does not support fusion");
157+
}
149158
if (!Context->isDeviceValid(Device)) {
150159
if (!Context->is_host() && Context->getBackend() == backend::opencl)
151160
throw sycl::invalid_object_error(
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import platform
2+
3+
config.unsupported_features += ['accelerator']
4+
5+
# TODO: enable on Windows once kernel fusion is supported on Windows.
6+
if platform.system() != "Linux":
7+
config.unsupported = True

sycl/unittests/Extensions/CommandGraph.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,15 @@ TEST_F(CommandGraphTest, DependencyLeavesKeyword4) {
15251525
}
15261526

15271527
TEST_F(CommandGraphTest, FusionExtensionExceptionCheck) {
1528-
queue Q{ext::codeplay::experimental::property::queue::enable_fusion{}};
1528+
device D;
1529+
if (!D.get_info<
1530+
ext::codeplay::experimental::info::device::supports_fusion>()) {
1531+
// Skip this test if the device does not support fusion. Otherwise, the
1532+
// queue construction in the next step would fail.
1533+
GTEST_SKIP();
1534+
}
1535+
1536+
queue Q{D, ext::codeplay::experimental::property::queue::enable_fusion{}};
15291537

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

0 commit comments

Comments
 (0)