|
| 1 | +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out |
| 2 | +// RUN: %CPU_RUN_PLACEHOLDER %t.out |
| 3 | +// RUN: %GPU_RUN_PLACEHOLDER %t.out |
| 4 | +// RUN: %ACC_RUN_PLACEHOLDER %t.out |
| 5 | + |
| 6 | +// This test checks whether the Kernel object returned from |
| 7 | +// kernel_bundle::get_kernel<typename KernelName>() is the same as a Kernel |
| 8 | +// object retrieved via other methods. |
| 9 | + |
| 10 | +#include <sycl/sycl.hpp> |
| 11 | + |
| 12 | +class KernelA; |
| 13 | + |
| 14 | +int main() { |
| 15 | + sycl::queue Queue; |
| 16 | + |
| 17 | + sycl::device Dev = Queue.get_device(); |
| 18 | + |
| 19 | + sycl::context Ctx = Queue.get_context(); |
| 20 | + |
| 21 | + Queue.submit([&](sycl::handler &CGH) { CGH.single_task<KernelA>([=]() {}); }); |
| 22 | + |
| 23 | + sycl::kernel_bundle KernelBundle = |
| 24 | + sycl::get_kernel_bundle<sycl::bundle_state::executable>(Ctx, {Dev}); |
| 25 | + |
| 26 | + auto FoundKernel = KernelBundle.get_kernel<KernelA>(); |
| 27 | + auto ExpectedKernel = KernelBundle.get_kernel(sycl::get_kernel_id<KernelA>()); |
| 28 | + |
| 29 | + // operator== isn't guaranteed to work in this scenario, so compare traits |
| 30 | + // about the kernels instead. |
| 31 | + auto FoundKernelName = |
| 32 | + FoundKernel.get_info<sycl::info::kernel::function_name>(); |
| 33 | + auto ExpectedKernelName = |
| 34 | + ExpectedKernel.get_info<sycl::info::kernel::function_name>(); |
| 35 | + |
| 36 | + auto FoundKernelNumArgs = |
| 37 | + FoundKernel.get_info<sycl::info::kernel::num_args>(); |
| 38 | + auto ExpectedKernelNumArgs = |
| 39 | + ExpectedKernel.get_info<sycl::info::kernel::num_args>(); |
| 40 | + |
| 41 | + auto FoundKernelContext = FoundKernel.get_info<sycl::info::kernel::context>(); |
| 42 | + auto ExpectedKernelContext = |
| 43 | + ExpectedKernel.get_info<sycl::info::kernel::context>(); |
| 44 | + |
| 45 | + assert(FoundKernelName == ExpectedKernelName); |
| 46 | + assert(FoundKernelNumArgs == ExpectedKernelNumArgs); |
| 47 | + assert(FoundKernelContext == ExpectedKernelContext); |
| 48 | + |
| 49 | + return 0; |
| 50 | +} |
0 commit comments