Refactor source level debugger notification in OCL. [2/2]

Refactor source level debugger notification about debug data in OCL
(build/link path).
- Share common code
- Remove unnecessary function(s)
- Zebin-related ULTs refactor

Related-To: NEO-6644
Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
Kacper Nowak
2022-02-14 12:59:03 +00:00
committed by Compute-Runtime-Automation
parent c30ee611de
commit b62675290f
5 changed files with 51 additions and 77 deletions

View File

@@ -186,26 +186,7 @@ cl_int Program::build(
if (BuildPhase::DebugDataNotification == phaseReached[rootDeviceIndex]) {
continue;
}
auto refBin = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(this->buildInfos[clDevice->getRootDeviceIndex()].unpackedDeviceBinary.get()), this->buildInfos[clDevice->getRootDeviceIndex()].unpackedDeviceBinarySize);
if (NEO::isDeviceBinaryFormat<NEO::DeviceBinaryFormat::Zebin>(refBin)) {
createDebugZebin(clDevice->getRootDeviceIndex());
if (clDevice->getSourceLevelDebugger()) {
NEO::DebugData debugData;
debugData.vIsa = reinterpret_cast<const char *>(this->buildInfos[clDevice->getRootDeviceIndex()].debugData.get());
debugData.vIsaSize = static_cast<uint32_t>(this->buildInfos[clDevice->getRootDeviceIndex()].debugDataSize);
clDevice->getSourceLevelDebugger()->notifyKernelDebugData(&debugData, "debug_zebin", nullptr, 0);
}
} else {
processDebugData(clDevice->getRootDeviceIndex());
if (clDevice->getSourceLevelDebugger()) {
for (auto kernelInfo : buildInfos[rootDeviceIndex].kernelInfoArray) {
clDevice->getSourceLevelDebugger()->notifyKernelDebugData(&kernelInfo->debugData,
kernelInfo->kernelDescriptor.kernelMetadata.kernelName,
kernelInfo->heapInfo.pKernelHeap,
kernelInfo->heapInfo.KernelHeapSize);
}
}
}
notifyDebuggerWithDebugData(clDevice);
phaseReached[rootDeviceIndex] = BuildPhase::DebugDataNotification;
}
}

View File

@@ -13,7 +13,6 @@
#include "shared/source/device_binary_format/elf/ocl_elf.h"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/program/kernel_info.h"
#include "shared/source/source_level_debugger/source_level_debugger.h"
#include "shared/source/utilities/stackvec.h"
#include "opencl/source/cl_device/cl_device.h"
@@ -171,13 +170,7 @@ cl_int Program::link(
if (kernelDebugDataNotified[rootDeviceIndex]) {
continue;
}
createDebugData(rootDeviceIndex);
for (auto kernelInfo : buildInfos[rootDeviceIndex].kernelInfoArray) {
device->getSourceLevelDebugger()->notifyKernelDebugData(&kernelInfo->debugData,
kernelInfo->kernelDescriptor.kernelMetadata.kernelName,
kernelInfo->heapInfo.pKernelHeap,
kernelInfo->heapInfo.KernelHeapSize);
}
notifyDebuggerWithDebugData(device);
kernelDebugDataNotified[device->getRootDeviceIndex()] = true;
}
}

View File

@@ -15,6 +15,7 @@
#include "shared/source/program/kernel_info.h"
#include "shared/source/program/program_info.h"
#include "shared/source/program/program_initialization.h"
#include "shared/source/source_level_debugger/source_level_debugger.h"
#include "opencl/source/cl_device/cl_device.h"
#include "opencl/source/context/context.h"
@@ -297,12 +298,28 @@ void Program::createDebugZebin(uint32_t rootDeviceIndex) {
debugZebin.data(), debugZebin.size());
}
void Program::createDebugData(uint32_t rootDeviceIndex) {
auto refBin = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(buildInfos[rootDeviceIndex].unpackedDeviceBinary.get()), buildInfos[rootDeviceIndex].unpackedDeviceBinarySize);
if (isDeviceBinaryFormat<DeviceBinaryFormat::Zebin>(refBin)) {
void Program::notifyDebuggerWithDebugData(ClDevice *clDevice) {
auto rootDeviceIndex = clDevice->getRootDeviceIndex();
auto &buildInfo = this->buildInfos[rootDeviceIndex];
auto refBin = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(buildInfo.unpackedDeviceBinary.get()), buildInfo.unpackedDeviceBinarySize);
if (NEO::isDeviceBinaryFormat<NEO::DeviceBinaryFormat::Zebin>(refBin)) {
createDebugZebin(rootDeviceIndex);
if (clDevice->getSourceLevelDebugger()) {
NEO::DebugData debugData;
debugData.vIsa = reinterpret_cast<const char *>(buildInfo.debugData.get());
debugData.vIsaSize = static_cast<uint32_t>(buildInfo.debugDataSize);
clDevice->getSourceLevelDebugger()->notifyKernelDebugData(&debugData, "debug_zebin", nullptr, 0);
}
} else {
processDebugData(rootDeviceIndex);
if (clDevice->getSourceLevelDebugger()) {
for (auto &kernelInfo : buildInfo.kernelInfoArray) {
clDevice->getSourceLevelDebugger()->notifyKernelDebugData(&kernelInfo->debugData,
kernelInfo->kernelDescriptor.kernelMetadata.kernelName,
kernelInfo->heapInfo.pKernelHeap,
kernelInfo->heapInfo.KernelHeapSize);
}
}
}
}
} // namespace NEO

View File

@@ -276,7 +276,7 @@ class Program : public BaseObject<_cl_program> {
this->context = pContext;
}
void createDebugData(uint32_t rootDeviceIndex);
void notifyDebuggerWithDebugData(ClDevice *clDevice);
MOCKABLE_VIRTUAL void createDebugZebin(uint32_t rootDeviceIndex);
Debug::Segments getZebinSegments(uint32_t rootDeviceIndex);