|
| 1 | +// RUN: %clangxx -fsycl %s -o %t.out |
| 2 | +// RUN: env SYCL_DEVICE_TYPE=HOST %t.out |
| 3 | +// RUN: %CPU_RUN_PLACEHOLDER %t.out |
| 4 | + |
| 5 | +#include <CL/sycl.hpp> |
| 6 | + |
| 7 | +#include <cassert> |
| 8 | + |
| 9 | +// Check program::get_compile/link/build_options functions |
| 10 | + |
| 11 | +class KernelName; |
| 12 | +void submitKernel() { |
| 13 | + cl::sycl::queue q; |
| 14 | + q.submit( |
| 15 | + [&](cl::sycl::handler &cgh) { cgh.single_task<KernelName>([]() {}); }); |
| 16 | +} |
| 17 | + |
| 18 | +int main() { |
| 19 | + const cl::sycl::string_class CompileOpts{"-cl-opt-disable"}; |
| 20 | + const cl::sycl::string_class LinkOpts{"-cl-fast-relaxed-math"}; |
| 21 | + const cl::sycl::string_class BuildOpts{ |
| 22 | + "-cl-opt-disable -cl-fast-relaxed-math"}; |
| 23 | + |
| 24 | + cl::sycl::context Ctx; |
| 25 | + cl::sycl::program PrgA{Ctx}; |
| 26 | + assert(PrgA.get_compile_options().empty()); |
| 27 | + assert(PrgA.get_link_options().empty()); |
| 28 | + assert(PrgA.get_build_options().empty()); |
| 29 | + |
| 30 | + PrgA.build_with_kernel_type<KernelName>(BuildOpts); |
| 31 | + assert(PrgA.get_compile_options().empty()); |
| 32 | + assert(PrgA.get_link_options().empty()); |
| 33 | + assert(PrgA.get_build_options() == (PrgA.is_host() ? "" : BuildOpts)); |
| 34 | + |
| 35 | + cl::sycl::program PrgB{Ctx}; |
| 36 | + PrgB.compile_with_kernel_type<KernelName>(CompileOpts); |
| 37 | + assert(PrgB.get_compile_options() == (PrgB.is_host() ? "" : CompileOpts)); |
| 38 | + assert(PrgB.get_link_options().empty()); |
| 39 | + assert(PrgB.get_build_options() == (PrgB.is_host() ? "" : CompileOpts)); |
| 40 | + |
| 41 | + PrgB.link(LinkOpts); |
| 42 | + assert(PrgB.get_compile_options() == (PrgB.is_host() ? "" : CompileOpts)); |
| 43 | + assert(PrgB.get_link_options() == (PrgB.is_host() ? "" : LinkOpts)); |
| 44 | + assert(PrgB.get_build_options() == (PrgB.is_host() ? "" : LinkOpts)); |
| 45 | +} |
0 commit comments