Skip to content

Commit 03326f7

Browse files
[SYCL] Fix program::get_compile/build_options (#1202)
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 <[email protected]>
1 parent 52c8ca5 commit 03326f7

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

sycl/source/detail/program_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ void program_impl::compile(const string_class &Options) {
300300
ProgramManager::getProgramBuildLog(MProgram, MContext));
301301
}
302302
MCompileOptions = Options;
303+
MBuildOptions = Options;
303304
}
304305

305306
void program_impl::build(const string_class &Options) {
@@ -316,7 +317,6 @@ void program_impl::build(const string_class &Options) {
316317
ProgramManager::getProgramBuildLog(MProgram, MContext));
317318
}
318319
MBuildOptions = Options;
319-
MCompileOptions = Options;
320320
}
321321

322322
vector_class<RT::PiDevice> program_impl::get_pi_devices() const {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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

Comments
 (0)