Skip to content

Commit

Permalink
[SYCL] Updating program compile, link and build options per spec
Browse files Browse the repository at this point in the history
clarifications

Signed-off-by: Sindhu Chittireddy <sindhu.chittireddy@intel.com>
  • Loading branch information
schittir committed Apr 10, 2019
1 parent 39e2c74 commit fee305f
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions sycl/include/CL/sycl/detail/program_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class program_impl {

program_impl(vector_class<std::shared_ptr<program_impl>> ProgramList,
string_class LinkOptions = "")
: State(program_state::linked), LinkOptions(LinkOptions) {
: State(program_state::linked), LinkOptions(LinkOptions),
BuildOptions(LinkOptions) {
// Verify arguments
if (ProgramList.empty()) {
throw runtime_error("Non-empty vector of programs expected");
Expand Down Expand Up @@ -79,8 +80,6 @@ class program_impl {

program_impl(const context &Context, cl_program ClProgram)
: ClProgram(ClProgram), Context(Context) {
// TODO it's unclear how to handle getting compile, link and build options
// in this case
// TODO handle the case when cl_program build is in progress
cl_uint NumDevices;
CHECK_OCL_CODE(clGetProgramInfo(ClProgram, CL_PROGRAM_NUM_DEVICES,
Expand All @@ -95,16 +94,29 @@ class program_impl {
CHECK_OCL_CODE(clGetProgramBuildInfo(
ClProgram, Devices[0].get(), CL_PROGRAM_BINARY_TYPE,
sizeof(cl_program_binary_type), &BinaryType, nullptr));
size_t Size = 0;
CHECK_OCL_CODE(clGetProgramBuildInfo(ClProgram, Devices[0].get(),
CL_PROGRAM_BUILD_OPTIONS, 0, nullptr,
&Size));
std::vector<char> OptionsVector(Size);
CHECK_OCL_CODE(clGetProgramBuildInfo(ClProgram, Devices[0].get(),
CL_PROGRAM_BUILD_OPTIONS, Size,
OptionsVector.data(), nullptr));
string_class Options(OptionsVector.begin(), OptionsVector.end());
switch (BinaryType) {
case CL_PROGRAM_BINARY_TYPE_NONE:
State = program_state::none;
break;
case CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT:
State = program_state::compiled;
CompileOptions = Options;
BuildOptions = Options;
break;
case CL_PROGRAM_BINARY_TYPE_LIBRARY:
case CL_PROGRAM_BINARY_TYPE_EXECUTABLE:
State = program_state::linked;
LinkOptions = "";
BuildOptions = Options;
}
CHECK_OCL_CODE(clRetainProgram(ClProgram));
}
Expand Down Expand Up @@ -189,7 +201,8 @@ class program_impl {
ClDevices.size(), ClDevices.data(), LinkOptions.c_str(),
1, &ClProgram, nullptr, nullptr, &Err);
CHECK_OCL_CODE_THROW(Err, compile_program_error);
LinkOptions = LinkOptions;
this->LinkOptions = LinkOptions;
BuildOptions = LinkOptions;
}
State = program_state::linked;
}
Expand Down Expand Up @@ -304,6 +317,7 @@ class program_impl {
throw compile_program_error("Program compilation error");
}
CompileOptions = Options;
BuildOptions = Options;
}

void build(const string_class &Options) {
Expand Down

0 comments on commit fee305f

Please sign in to comment.