MCPcopy Create free account
hub / github.com/ROCm/clr / compile

Method compile

rocclr/platform/program.cpp:188–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188int32_t Program::compile(const std::vector<Device*>& devices, size_t numHeaders,
189 const std::vector<const Program*>& headerPrograms,
190 const char** headerIncludeNames, const char* options,
191 void(CL_CALLBACK* notifyFptr)(cl_program, void*), void* data,
192 bool optionChangable) {
193 ScopedLock sl(&programLock_);
194
195 int32_t retval = CL_SUCCESS;
196
197 // Clear the program object
198 clear();
199
200 // Process build options.
201 std::string cppstr(options ? options : "");
202 optionChangable &= adjustOptionsOnIgnoreEnv(cppstr);
203
204 std::vector<const std::string*> headers(numHeaders);
205 for (size_t i = 0; i < numHeaders; ++i) {
206 const std::string& header = headerPrograms[i]->sourceCode();
207 headers[i] = &header;
208 }
209
210 // Compile the program programs associated with the given devices.
211 for (const auto& it : devices) {
212 option::Options parsedOptions;
213 constexpr bool LinkOptsOnly = false;
214 if (!ParseAllOptions(cppstr, parsedOptions, optionChangable, LinkOptsOnly)) {
215 programLog_ = parsedOptions.optionsLog();
216 LogError("Parsing compile options failed.");
217 return CL_INVALID_COMPILER_OPTIONS;
218 }
219 device::Program* devProgram = getDeviceProgram(*it);
220 if (devProgram == NULL) {
221 const binary_t& bin = binary(*it);
222 retval =
223 addDeviceProgram(*it, std::get<0>(bin), std::get<1>(bin).first, false, &parsedOptions);
224 if (retval != CL_SUCCESS) {
225 return retval;
226 }
227 devProgram = getDeviceProgram(*it);
228 }
229
230 if (devProgram->type() == device::Program::TYPE_INTERMEDIATE || language_ == SPIRV) {
231 continue;
232 }
233 // We only build a Device-Program once
234 if (devProgram->buildStatus() != CL_BUILD_NONE) {
235 continue;
236 }
237 if (sourceCode_.empty()) {
238 return CL_INVALID_OPERATION;
239 }
240 int32_t result =
241 devProgram->compile(sourceCode_, headers, headerIncludeNames, options, &parsedOptions);
242
243 // Check if the previous device failed a build
244 if ((result != CL_SUCCESS) && (retval != CL_SUCCESS)) {
245 retval = CL_INVALID_OPERATION;

Callers

nothing calls this directly

Calls 6

adjustOptionsOnIgnoreEnvFunction · 0.85
as_clFunction · 0.85
buildStatusMethod · 0.80
emptyMethod · 0.80
clearFunction · 0.50
typeMethod · 0.45

Tested by

no test coverage detected