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

Method createKernels

rocclr/device/pal/palprogram.cpp:394–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

392}
393
394bool Program::createKernels(void* binary, size_t binSize, bool useUniformWorkGroupSize,
395 bool internalKernel) {
396 // Skip metadata look-up and kernel creation for assembly and internal kernel.
397 // @note: Runtime compiles only the second level trap handler from assembly
398 if ((owner()->language() != amd::Program::Assembly) || !internal_) {
399 // Find the size of global variables from the binary
400 if (!FindGlobalVarSize(binary, binSize)) {
401 buildLog_ += "Error: Cannot Find Global Var Sizes\n";
402 return false;
403 }
404
405 for (const auto& kernelMeta : kernelMetadataMap_) {
406 auto kernelName = kernelMeta.first;
407 auto kernel = new pal::Kernel(kernelName, this, internalKernel);
408 if (kernel == nullptr) {
409 return false;
410 }
411 if (!kernel->init()) {
412 buildLog_ += "[ROC][Kernel] Could not get Code Prop Meta Data \n";
413 return false;
414 }
415 addKernel(kernel);
416
417 if (codeObjectVer() < 5) {
418 kernel->setUniformWorkGroupSize(useUniformWorkGroupSize);
419 }
420 }
421 }
422 executable_ = loader_->CreateExecutable(HSA_PROFILE_FULL, nullptr);
423 if (executable_ == nullptr) {
424 LogError("Error: Executable for AMD HSA Code Object isn't created.");
425 return false;
426 }
427
428 hsa_code_object_t code_object;
429 code_object.handle = reinterpret_cast<uint64_t>(binary);
430
431 hsa_agent_t agent = {amd::Device::toHandle(&(device()))};
432 auto uri = GetUriFromMemoryAddress(binary, binSize);
433 hsa_status_t status = executable_->LoadCodeObject(agent, code_object, nullptr, uri);
434 if (status != HSA_STATUS_SUCCESS) {
435 LogError("Error: AMD HSA Code Object loading failed.");
436 return false;
437 }
438
439 if (isInternal() && (owner()->language() == amd::Program::Assembly)) {
440 // Don't register trap handler with the debugger, since user shouldn't see this kernel
441 status = executable_->Freeze(nullptr);
442 trapHandler_ = true;
443 } else {
444 status = loader_->FreezeExecutable(executable_, nullptr);
445 }
446 if (status != HSA_STATUS_SUCCESS) {
447 LogError("Error: Freezing the executable failed.");
448 return false;
449 }
450 return true;
451}

Callers

nothing calls this directly

Calls 4

GetUriFromMemoryAddressFunction · 0.85
languageMethod · 0.80
initMethod · 0.45

Tested by

no test coverage detected