Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

[SYCL] Adds regression test for ensuring SYCL_EXTERNAL is ignored by kernel bundles #486

Merged
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
40 changes: 40 additions & 0 deletions SYCL/Regression/kernel_bundle_ignore_sycl_external.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %ACC_RUN_PLACEHOLDER %t.out
//
// XFAIL: cuda || hip

#include <CL/sycl.hpp>

class KernelName;

SYCL_EXTERNAL
int f(int a) { return a + 1; }

int main() {
const sycl::device Dev{sycl::default_selector{}};
const sycl::context Ctx{Dev};
sycl::queue Q{Ctx, Dev};

assert(sycl::get_kernel_ids().size() == 1);

sycl::kernel_bundle EmptyKernelBundle =
sycl::get_kernel_bundle<sycl::bundle_state::executable>(Ctx, {Dev}, {});

assert(EmptyKernelBundle.get_kernel_ids().size() == 0);

sycl::kernel_bundle KernelBundle =
sycl::get_kernel_bundle<sycl::bundle_state::executable>(Ctx, {Dev});
sycl::kernel_id KernelID = sycl::get_kernel_id<KernelName>();

assert(KernelBundle.get_kernel_ids().size() == 1);
assert(KernelBundle.has_kernel(KernelID));

cl::sycl::buffer<int, 1> Buf(sycl::range<1>{1});
Q.submit([&](sycl::handler &CGH) {
auto Acc = Buf.get_access<sycl::access::mode::write>(CGH);
CGH.use_kernel_bundle(KernelBundle);
CGH.single_task<KernelName>([=]() { Acc[0] = 42; });
});
}