Skip to content

Commit fee305f

Browse files
committed
[SYCL] Updating program compile, link and build options per spec
clarifications Signed-off-by: Sindhu Chittireddy <sindhu.chittireddy@intel.com>
1 parent 39e2c74 commit fee305f

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

sycl/include/CL/sycl/detail/program_impl.hpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class program_impl {
4343

4444
program_impl(vector_class<std::shared_ptr<program_impl>> ProgramList,
4545
string_class LinkOptions = "")
46-
: State(program_state::linked), LinkOptions(LinkOptions) {
46+
: State(program_state::linked), LinkOptions(LinkOptions),
47+
BuildOptions(LinkOptions) {
4748
// Verify arguments
4849
if (ProgramList.empty()) {
4950
throw runtime_error("Non-empty vector of programs expected");
@@ -79,8 +80,6 @@ class program_impl {
7980

8081
program_impl(const context &Context, cl_program ClProgram)
8182
: ClProgram(ClProgram), Context(Context) {
82-
// TODO it's unclear how to handle getting compile, link and build options
83-
// in this case
8483
// TODO handle the case when cl_program build is in progress
8584
cl_uint NumDevices;
8685
CHECK_OCL_CODE(clGetProgramInfo(ClProgram, CL_PROGRAM_NUM_DEVICES,
@@ -95,16 +94,29 @@ class program_impl {
9594
CHECK_OCL_CODE(clGetProgramBuildInfo(
9695
ClProgram, Devices[0].get(), CL_PROGRAM_BINARY_TYPE,
9796
sizeof(cl_program_binary_type), &BinaryType, nullptr));
97+
size_t Size = 0;
98+
CHECK_OCL_CODE(clGetProgramBuildInfo(ClProgram, Devices[0].get(),
99+
CL_PROGRAM_BUILD_OPTIONS, 0, nullptr,
100+
&Size));
101+
std::vector<char> OptionsVector(Size);
102+
CHECK_OCL_CODE(clGetProgramBuildInfo(ClProgram, Devices[0].get(),
103+
CL_PROGRAM_BUILD_OPTIONS, Size,
104+
OptionsVector.data(), nullptr));
105+
string_class Options(OptionsVector.begin(), OptionsVector.end());
98106
switch (BinaryType) {
99107
case CL_PROGRAM_BINARY_TYPE_NONE:
100108
State = program_state::none;
101109
break;
102110
case CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT:
103111
State = program_state::compiled;
112+
CompileOptions = Options;
113+
BuildOptions = Options;
104114
break;
105115
case CL_PROGRAM_BINARY_TYPE_LIBRARY:
106116
case CL_PROGRAM_BINARY_TYPE_EXECUTABLE:
107117
State = program_state::linked;
118+
LinkOptions = "";
119+
BuildOptions = Options;
108120
}
109121
CHECK_OCL_CODE(clRetainProgram(ClProgram));
110122
}
@@ -189,7 +201,8 @@ class program_impl {
189201
ClDevices.size(), ClDevices.data(), LinkOptions.c_str(),
190202
1, &ClProgram, nullptr, nullptr, &Err);
191203
CHECK_OCL_CODE_THROW(Err, compile_program_error);
192-
LinkOptions = LinkOptions;
204+
this->LinkOptions = LinkOptions;
205+
BuildOptions = LinkOptions;
193206
}
194207
State = program_state::linked;
195208
}
@@ -304,6 +317,7 @@ class program_impl {
304317
throw compile_program_error("Program compilation error");
305318
}
306319
CompileOptions = Options;
320+
BuildOptions = Options;
307321
}
308322

309323
void build(const string_class &Options) {

0 commit comments

Comments
 (0)