@@ -43,7 +43,8 @@ class program_impl {
43
43
44
44
program_impl (vector_class<std::shared_ptr<program_impl>> ProgramList,
45
45
string_class LinkOptions = " " )
46
- : State(program_state::linked), LinkOptions(LinkOptions) {
46
+ : State(program_state::linked), LinkOptions(LinkOptions),
47
+ BuildOptions (LinkOptions) {
47
48
// Verify arguments
48
49
if (ProgramList.empty ()) {
49
50
throw runtime_error (" Non-empty vector of programs expected" );
@@ -79,8 +80,6 @@ class program_impl {
79
80
80
81
program_impl (const context &Context, cl_program ClProgram)
81
82
: ClProgram(ClProgram), Context(Context) {
82
- // TODO it's unclear how to handle getting compile, link and build options
83
- // in this case
84
83
// TODO handle the case when cl_program build is in progress
85
84
cl_uint NumDevices;
86
85
CHECK_OCL_CODE (clGetProgramInfo (ClProgram, CL_PROGRAM_NUM_DEVICES,
@@ -95,16 +94,29 @@ class program_impl {
95
94
CHECK_OCL_CODE (clGetProgramBuildInfo (
96
95
ClProgram, Devices[0 ].get (), CL_PROGRAM_BINARY_TYPE,
97
96
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 ());
98
106
switch (BinaryType) {
99
107
case CL_PROGRAM_BINARY_TYPE_NONE:
100
108
State = program_state::none;
101
109
break ;
102
110
case CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT:
103
111
State = program_state::compiled;
112
+ CompileOptions = Options;
113
+ BuildOptions = Options;
104
114
break ;
105
115
case CL_PROGRAM_BINARY_TYPE_LIBRARY:
106
116
case CL_PROGRAM_BINARY_TYPE_EXECUTABLE:
107
117
State = program_state::linked;
118
+ LinkOptions = " " ;
119
+ BuildOptions = Options;
108
120
}
109
121
CHECK_OCL_CODE (clRetainProgram (ClProgram));
110
122
}
@@ -189,7 +201,8 @@ class program_impl {
189
201
ClDevices.size (), ClDevices.data (), LinkOptions.c_str (),
190
202
1 , &ClProgram, nullptr , nullptr , &Err);
191
203
CHECK_OCL_CODE_THROW (Err, compile_program_error);
192
- LinkOptions = LinkOptions;
204
+ this ->LinkOptions = LinkOptions;
205
+ BuildOptions = LinkOptions;
193
206
}
194
207
State = program_state::linked;
195
208
}
@@ -304,6 +317,7 @@ class program_impl {
304
317
throw compile_program_error (" Program compilation error" );
305
318
}
306
319
CompileOptions = Options;
320
+ BuildOptions = Options;
307
321
}
308
322
309
323
void build (const string_class &Options) {
0 commit comments