Skip to content

Commit d616546

Browse files
authored
[SYCL][Fusion] Stop fusion attempt early if nothing is enqueued (#12065)
Previously, fusion would fail because an empty list of ND ranges is determined to be incompatible. Signed-off-by: Julian Oppermann <[email protected]>
1 parent 3373db1 commit d616546

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

sycl/source/detail/jit_compiler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,11 @@ std::unique_ptr<detail::CG>
630630
jit_compiler::fuseKernels(QueueImplPtr Queue,
631631
std::vector<ExecCGCommand *> &InputKernels,
632632
const property_list &PropList) {
633+
if (InputKernels.empty()) {
634+
printPerformanceWarning("Fusion list is empty");
635+
return nullptr;
636+
}
637+
633638
// Retrieve the device binary from each of the input
634639
// kernels to hand them over to the JIT compiler.
635640
std::vector<::jit_compiler::SYCLKernelInfo> InputKernelInfo;

sycl/test-e2e/KernelFusion/abort_fusion.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ void performFusion(queue &q, range<Kernel1Dim> k1Global,
7474
assert(numErrors == 0);
7575
}
7676

77+
static void emptyFusionList(queue &q) {
78+
ext::codeplay::experimental::fusion_wrapper fw(q);
79+
fw.start_fusion();
80+
assert(fw.is_in_fusion_mode() && "Queue should be in fusion mode");
81+
fw.complete_fusion();
82+
assert(!fw.is_in_fusion_mode() &&
83+
"Queue should not be in fusion mode anymore");
84+
}
85+
7786
int main() {
7887

7988
queue q{ext::codeplay::experimental::property::queue::enable_fusion{}};
@@ -86,5 +95,11 @@ int main() {
8695
// CHECK-NEXT: Cannot fuse kernels with different offsets or local sizes
8796
// CHECK: COMPUTATION OK
8897

98+
// Scenario: An empty fusion list should not be classified as having
99+
// incompatible ND ranges.
100+
emptyFusionList(q);
101+
// CHECK-NOT: Cannot fuse kernels with different offsets or local sizes
102+
// CHECK: WARNING: Fusion list is empty
103+
89104
return 0;
90105
}

0 commit comments

Comments
 (0)