@@ -124,6 +124,32 @@ RT::PiProgram ProgramManager::getClProgramFromClKernel(RT::PiKernel Kernel) {
124
124
return Program;
125
125
}
126
126
127
+ string_class ProgramManager::getProgramBuildLog (const RT::PiProgram &Program) {
128
+ size_t Size = 0 ;
129
+ PI_CALL (RT::piProgramGetInfo (Program, CL_PROGRAM_DEVICES, 0 , nullptr , &Size));
130
+ vector_class<RT::PiDevice> PIDevices (Size / sizeof (RT::PiDevice));
131
+ PI_CALL (RT::piProgramGetInfo (Program, CL_PROGRAM_DEVICES, Size,
132
+ PIDevices.data (), nullptr ));
133
+ string_class Log = " The program was built for " +
134
+ std::to_string (PIDevices.size ()) + " devices" ;
135
+ for (RT::PiDevice &Device : PIDevices) {
136
+ PI_CALL (RT::piProgramGetBuildInfo (Program, Device, CL_PROGRAM_BUILD_LOG, 0 ,
137
+ nullptr , &Size));
138
+ vector_class<char > DeviceBuildInfo (Size);
139
+ PI_CALL (RT::piProgramGetBuildInfo (Program, Device, CL_PROGRAM_BUILD_LOG,
140
+ Size, DeviceBuildInfo.data (), nullptr ));
141
+ PI_CALL (
142
+ RT::piDeviceGetInfo (Device, PI_DEVICE_INFO_NAME, 0 , nullptr , &Size));
143
+ vector_class<char > DeviceName (Size);
144
+ PI_CALL (RT::piDeviceGetInfo (Device, PI_DEVICE_INFO_NAME, Size,
145
+ DeviceName.data (), nullptr ));
146
+
147
+ Log += " \n Build program log for '" + string_class (DeviceName.data ()) +
148
+ " ':\n " + string_class (DeviceBuildInfo.data ());
149
+ }
150
+ return Log;
151
+ }
152
+
127
153
void ProgramManager::build (RT::PiProgram &Program, const string_class &Options,
128
154
std::vector<RT::PiDevice> Devices) {
129
155
@@ -148,29 +174,7 @@ void ProgramManager::build(RT::PiProgram &Program, const string_class &Options,
148
174
Opts, nullptr , nullptr )) == PI_SUCCESS)
149
175
return ;
150
176
151
- // Get OpenCL build log and add it to the exception message.
152
- size_t Size = 0 ;
153
- PI_CALL (RT::piProgramGetInfo (
154
- Program, CL_PROGRAM_DEVICES, 0 , nullptr , &Size));
155
-
156
- std::vector<RT::PiDevice> DevIds (Size / sizeof (RT::PiDevice));
157
- PI_CALL (RT::piProgramGetInfo (
158
- Program, CL_PROGRAM_DEVICES, Size, DevIds.data (), nullptr ));
159
- std::string Log;
160
- for (RT::PiDevice &DevId : DevIds) {
161
- PI_CALL (RT::piProgramGetBuildInfo (
162
- Program, DevId, CL_PROGRAM_BUILD_LOG, 0 , nullptr , &Size));
163
- std::vector<char > BuildLog (Size);
164
- PI_CALL (RT::piProgramGetBuildInfo (
165
- Program, DevId, CL_PROGRAM_BUILD_LOG, Size,
166
- BuildLog.data (), nullptr ));
167
-
168
- device Dev = createSyclObjFromImpl<device>(
169
- std::make_shared<device_impl_pi>(DevId));
170
- Log += " \n Build program fail log for '" +
171
- Dev.get_info <info::device::name>() + " ':\n " + BuildLog.data ();
172
- }
173
- throw compile_program_error (Log.c_str ());
177
+ throw compile_program_error (getProgramBuildLog (Program));
174
178
}
175
179
176
180
void ProgramManager::addImages (pi_device_binaries DeviceBinary) {
0 commit comments