Skip to content
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

[SYCL] Updating program compile, link and build options per spec #71

Closed
wants to merge 4 commits into from
Closed
Changes from 2 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
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