Skip to content

[SYCL] Fix program::get_compile/build_options #1202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion sycl/source/detail/program_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -316,7 +317,6 @@ void program_impl::build(const string_class &Options) {
ProgramManager::getProgramBuildLog(MProgram, MContext));
}
MBuildOptions = Options;
MCompileOptions = Options;
}

vector_class<RT::PiDevice> program_impl::get_pi_devices() const {
Expand Down
45 changes: 45 additions & 0 deletions sycl/test/kernel-and-program/get-options.cpp
Original file line number Diff line number Diff line change
@@ -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 <CL/sycl.hpp>

#include <cassert>

// 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<KernelName>([]() {}); });
}

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<KernelName>(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<KernelName>(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));
}