From fee305f806bea6c282551a9de6172440ef515336 Mon Sep 17 00:00:00 2001 From: Sindhu Chittireddy Date: Fri, 5 Apr 2019 02:37:08 -0700 Subject: [PATCH] [SYCL] Updating program compile, link and build options per spec clarifications Signed-off-by: Sindhu Chittireddy --- sycl/include/CL/sycl/detail/program_impl.hpp | 22 ++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/sycl/include/CL/sycl/detail/program_impl.hpp b/sycl/include/CL/sycl/detail/program_impl.hpp index a5c9ddbb8b6fe..1c87932cfa17b 100644 --- a/sycl/include/CL/sycl/detail/program_impl.hpp +++ b/sycl/include/CL/sycl/detail/program_impl.hpp @@ -43,7 +43,8 @@ class program_impl { program_impl(vector_class> 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"); @@ -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, @@ -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 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)); } @@ -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; } @@ -304,6 +317,7 @@ class program_impl { throw compile_program_error("Program compilation error"); } CompileOptions = Options; + BuildOptions = Options; } void build(const string_class &Options) {