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

[SYCL] Add a built-in kernel test #576

Closed
wants to merge 2 commits into from
Closed
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
35 changes: 35 additions & 0 deletions SYCL/KernelAndProgram/built-in-kernel-ids.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we have this test in intel/llvm:sycl/unittests?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose so. Are you suggesting not performing a real device query at all and manually adding something into the program manager built-in kernel cache?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to check that sycl::device::get_info<sycl::info::device::built_in_kernel_ids> returns expected value if piDeviceGetInfo with CL_​DEVICE_​BUILT_​IN_​KERNELS returns non-empty list of kernels(we can emulate piDeviceGetInfo). And then check that an attempt to get a kernel bundle containing this kernel leads to exception.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// RUN: %HOST_RUN_PLACEHOLDER %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// RUN: %ACC_RUN_PLACEHOLDER %t.out

#include <CL/sycl.hpp>

int main() {
sycl::queue q;
auto ctx = q.get_context();
auto dev = q.get_device();

auto ids = dev.get_info<sycl::info::device::built_in_kernel_ids>();

if (ids.empty()) // exception is only thrown when there are built-in kernels
return 0;

sycl::errc val = sycl::errc::success;
std::string msg;
try {
sycl::get_kernel_bundle<sycl::bundle_state::executable>(ctx, {dev}, ids);
} catch (sycl::exception &e) {
val = sycl::errc(e.code().value());
msg = e.what();
}

if (val != sycl::errc::kernel_argument)
return 1;
if (msg !=
"Attempting to use a built-in kernel. They are not fully supported")
return 1;

return 0;
}