Skip to content

[SYCL][Fusion] Stop fusion attempt early if nothing is enqueued #12065

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 1 commit into from
Dec 4, 2023
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
5 changes: 5 additions & 0 deletions sycl/source/detail/jit_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,11 @@ std::unique_ptr<detail::CG>
jit_compiler::fuseKernels(QueueImplPtr Queue,
std::vector<ExecCGCommand *> &InputKernels,
const property_list &PropList) {
if (InputKernels.empty()) {
printPerformanceWarning("Fusion list is empty");
return nullptr;
}

// Retrieve the device binary from each of the input
// kernels to hand them over to the JIT compiler.
std::vector<::jit_compiler::SYCLKernelInfo> InputKernelInfo;
Expand Down
15 changes: 15 additions & 0 deletions sycl/test-e2e/KernelFusion/abort_fusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ void performFusion(queue &q, range<Kernel1Dim> k1Global,
assert(numErrors == 0);
}

static void emptyFusionList(queue &q) {
ext::codeplay::experimental::fusion_wrapper fw(q);
fw.start_fusion();
assert(fw.is_in_fusion_mode() && "Queue should be in fusion mode");
fw.complete_fusion();
assert(!fw.is_in_fusion_mode() &&
"Queue should not be in fusion mode anymore");
}

int main() {

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

// Scenario: An empty fusion list should not be classified as having
// incompatible ND ranges.
emptyFusionList(q);
// CHECK-NOT: Cannot fuse kernels with different offsets or local sizes
// CHECK: WARNING: Fusion list is empty

return 0;
}