From 0f1b30c19610a4802c43747665d092628cd9a387 Mon Sep 17 00:00:00 2001 From: Sergey Semenov Date: Wed, 26 Feb 2020 15:20:13 +0300 Subject: [PATCH] [SYCL] Fix program::get_compile/build_options get_build_options should return compile options for a program in a compiled state and not the other way around. Signed-off-by: Sergey Semenov --- sycl/source/detail/program_impl.cpp | 2 +- sycl/test/kernel-and-program/get-options.cpp | 45 ++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 sycl/test/kernel-and-program/get-options.cpp diff --git a/sycl/source/detail/program_impl.cpp b/sycl/source/detail/program_impl.cpp index 3125008515487..915c210393579 100644 --- a/sycl/source/detail/program_impl.cpp +++ b/sycl/source/detail/program_impl.cpp @@ -300,6 +300,7 @@ void program_impl::compile(const string_class &Options) { ProgramManager::getProgramBuildLog(MProgram, MContext)); } MCompileOptions = Options; + MBuildOptions = Options; } void program_impl::build(const string_class &Options) { @@ -316,7 +317,6 @@ void program_impl::build(const string_class &Options) { ProgramManager::getProgramBuildLog(MProgram, MContext)); } MBuildOptions = Options; - MCompileOptions = Options; } vector_class program_impl::get_pi_devices() const { diff --git a/sycl/test/kernel-and-program/get-options.cpp b/sycl/test/kernel-and-program/get-options.cpp new file mode 100644 index 0000000000000..6bb889a4c09ec --- /dev/null +++ b/sycl/test/kernel-and-program/get-options.cpp @@ -0,0 +1,45 @@ +// RUN: %clangxx -fsycl %s -o %t.out +// RUN: env SYCL_DEVICE_TYPE=HOST %t.out +// RUN: %CPU_RUN_PLACEHOLDER %t.out + +#include + +#include + +// Check program::get_compile/link/build_options functions + +class KernelName; +void submitKernel() { + cl::sycl::queue q; + q.submit( + [&](cl::sycl::handler &cgh) { cgh.single_task([]() {}); }); +} + +int main() { + const cl::sycl::string_class CompileOpts{"-cl-opt-disable"}; + const cl::sycl::string_class LinkOpts{"-cl-fast-relaxed-math"}; + const cl::sycl::string_class BuildOpts{ + "-cl-opt-disable -cl-fast-relaxed-math"}; + + cl::sycl::context Ctx; + cl::sycl::program PrgA{Ctx}; + assert(PrgA.get_compile_options().empty()); + assert(PrgA.get_link_options().empty()); + assert(PrgA.get_build_options().empty()); + + PrgA.build_with_kernel_type(BuildOpts); + assert(PrgA.get_compile_options().empty()); + assert(PrgA.get_link_options().empty()); + assert(PrgA.get_build_options() == (PrgA.is_host() ? "" : BuildOpts)); + + cl::sycl::program PrgB{Ctx}; + PrgB.compile_with_kernel_type(CompileOpts); + assert(PrgB.get_compile_options() == (PrgB.is_host() ? "" : CompileOpts)); + assert(PrgB.get_link_options().empty()); + assert(PrgB.get_build_options() == (PrgB.is_host() ? "" : CompileOpts)); + + PrgB.link(LinkOpts); + assert(PrgB.get_compile_options() == (PrgB.is_host() ? "" : CompileOpts)); + assert(PrgB.get_link_options() == (PrgB.is_host() ? "" : LinkOpts)); + assert(PrgB.get_build_options() == (PrgB.is_host() ? "" : LinkOpts)); +}