| 405 | } |
| 406 | |
| 407 | int32_t Program::build(const std::vector<Device*>& devices, const char* options, |
| 408 | void(CL_CALLBACK* notifyFptr)(cl_program, void*), void* data, |
| 409 | bool optionChangable, bool newDevProg) { |
| 410 | ScopedLock sl(&programLock_); |
| 411 | |
| 412 | int32_t retval = CL_SUCCESS; |
| 413 | |
| 414 | if (symbolTable_ == NULL) { |
| 415 | symbolTable_ = new symbols_t; |
| 416 | if (symbolTable_ == NULL) { |
| 417 | return CL_OUT_OF_HOST_MEMORY; |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | if (OCL_STUB_PROGRAMS && !sourceCode_.empty()) { |
| 422 | // The app name should be the samme for all device |
| 423 | StubProgramSource(devices[0]->appProfile()->appFileName()); |
| 424 | } |
| 425 | |
| 426 | if (newDevProg) { |
| 427 | // Clear the program object |
| 428 | clear(); |
| 429 | } |
| 430 | |
| 431 | // Process build options. |
| 432 | std::string cppstr(options ? options : ""); |
| 433 | optionChangable &= adjustOptionsOnIgnoreEnv(cppstr); |
| 434 | |
| 435 | // Build the program programs associated with the given devices. |
| 436 | for (const auto& it : devices) { |
| 437 | option::Options parsedOptions; |
| 438 | constexpr bool LinkOptsOnly = false; |
| 439 | if ((language_ != HIP) && !ParseAllOptions(cppstr, parsedOptions, optionChangable, LinkOptsOnly)) { |
| 440 | programLog_ = parsedOptions.optionsLog(); |
| 441 | LogError("Parsing compile options failed."); |
| 442 | return CL_INVALID_COMPILER_OPTIONS; |
| 443 | } |
| 444 | |
| 445 | device::Program* devProgram = getDeviceProgram(*it); |
| 446 | if (devProgram == NULL) { |
| 447 | const binary_t& bin = binary(*it); |
| 448 | if (sourceCode_.empty() && (std::get<0>(bin) == NULL)) { |
| 449 | retval = false; |
| 450 | continue; |
| 451 | } |
| 452 | retval = |
| 453 | addDeviceProgram(*it, std::get<0>(bin), std::get<1>(bin).first, false, &parsedOptions); |
| 454 | if (retval != CL_SUCCESS) { |
| 455 | return retval; |
| 456 | } |
| 457 | devProgram = getDeviceProgram(*it); |
| 458 | } |
| 459 | |
| 460 | parsedOptions.oVariables->AssumeAlias = true; |
| 461 | |
| 462 | if (language_ == Assembly) { |
| 463 | parsedOptions.oVariables->XLang = "asm"; |
| 464 | } |
no test coverage detected