mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Create debug zebin in OCL
This commit adds debug zebin creation in OCL. - Added returning debug zebin in build/linking paths in OCL if corresponding device binary format was detected. - Refactored getZebinSegments() method - added common ctor for both L0/OCL paths Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
59683ec491
commit
fc224202d6
@@ -186,7 +186,7 @@ cl_int Program::build(
|
||||
if (BuildPhase::DebugDataNotification == phaseReached[rootDeviceIndex]) {
|
||||
continue;
|
||||
}
|
||||
processDebugData(rootDeviceIndex);
|
||||
createDebugData(clDevice->getRootDeviceIndex());
|
||||
if (clDevice->getSourceLevelDebugger()) {
|
||||
for (auto kernelInfo : buildInfos[rootDeviceIndex].kernelInfoArray) {
|
||||
clDevice->getSourceLevelDebugger()->notifyKernelDebugData(&kernelInfo->debugData,
|
||||
|
||||
@@ -170,7 +170,7 @@ cl_int Program::link(
|
||||
if (kernelDebugDataNotified[rootDeviceIndex]) {
|
||||
continue;
|
||||
}
|
||||
processDebugData(rootDeviceIndex);
|
||||
createDebugData(rootDeviceIndex);
|
||||
for (auto kernelInfo : buildInfos[rootDeviceIndex].kernelInfoArray) {
|
||||
device->getSourceLevelDebugger()->notifyKernelDebugData(&kernelInfo->debugData,
|
||||
kernelInfo->kernelDescriptor.kernelMetadata.kernelName,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -61,6 +61,7 @@ cl_int Program::linkBinary(Device *pDevice, const void *constantsInitData, const
|
||||
}
|
||||
auto rootDeviceIndex = pDevice->getRootDeviceIndex();
|
||||
auto &kernelInfoArray = buildInfos[rootDeviceIndex].kernelInfoArray;
|
||||
buildInfos[rootDeviceIndex].constStringSectionData = stringsInfo;
|
||||
Linker linker(*linkerInput);
|
||||
Linker::SegmentInfo globals;
|
||||
Linker::SegmentInfo constants;
|
||||
@@ -276,4 +277,36 @@ void Program::processDebugData(uint32_t rootDeviceIndex) {
|
||||
}
|
||||
}
|
||||
|
||||
Debug::Segments Program::getZebinSegments(uint32_t rootDeviceIndex) {
|
||||
ArrayRef<const uint8_t> strings = {reinterpret_cast<const uint8_t *>(buildInfos[rootDeviceIndex].constStringSectionData.initData),
|
||||
buildInfos[rootDeviceIndex].constStringSectionData.size};
|
||||
std::vector<std::pair<std::string_view, NEO::GraphicsAllocation *>> kernels;
|
||||
for (const auto &kernelInfo : buildInfos[rootDeviceIndex].kernelInfoArray)
|
||||
kernels.push_back({kernelInfo->kernelDescriptor.kernelMetadata.kernelName, kernelInfo->getGraphicsAllocation()});
|
||||
|
||||
return Debug::Segments(getGlobalSurface(rootDeviceIndex), getConstantSurface(rootDeviceIndex), strings, kernels);
|
||||
}
|
||||
|
||||
void Program::createDebugZebin(uint32_t rootDeviceIndex) {
|
||||
if (debugDataSize != 0) {
|
||||
return;
|
||||
}
|
||||
auto refBin = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(buildInfos[rootDeviceIndex].unpackedDeviceBinary.get()), buildInfos[rootDeviceIndex].unpackedDeviceBinarySize);
|
||||
auto segments = getZebinSegments(rootDeviceIndex);
|
||||
auto debugZebin = Debug::createDebugZebin(refBin, segments);
|
||||
|
||||
debugDataSize = debugZebin.size();
|
||||
debugData.reset(new char[debugDataSize]);
|
||||
memcpy_s(debugData.get(), debugDataSize,
|
||||
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)) {
|
||||
createDebugZebin(rootDeviceIndex);
|
||||
} else {
|
||||
processDebugData(rootDeviceIndex);
|
||||
}
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
#include "shared/source/compiler_interface/compiler_interface.h"
|
||||
#include "shared/source/compiler_interface/linker.h"
|
||||
#include "shared/source/device_binary_format/debug_zebin.h"
|
||||
#include "shared/source/device_binary_format/elf/elf_encoder.h"
|
||||
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
||||
#include "shared/source/program/program_info.h"
|
||||
@@ -173,7 +174,7 @@ class Program : public BaseObject<_cl_program> {
|
||||
|
||||
cl_int getSource(std::string &binary) const;
|
||||
|
||||
void processDebugData(uint32_t rootDeviceIndex);
|
||||
MOCKABLE_VIRTUAL void processDebugData(uint32_t rootDeviceIndex);
|
||||
|
||||
void updateBuildLog(uint32_t rootDeviceIndex, const char *pErrorString, const size_t errorStringSize);
|
||||
|
||||
@@ -282,6 +283,10 @@ class Program : public BaseObject<_cl_program> {
|
||||
this->context = pContext;
|
||||
}
|
||||
|
||||
void createDebugData(uint32_t rootDeviceIndex);
|
||||
MOCKABLE_VIRTUAL void createDebugZebin(uint32_t rootDeviceIndex);
|
||||
Debug::Segments getZebinSegments(uint32_t rootDeviceIndex);
|
||||
|
||||
protected:
|
||||
MOCKABLE_VIRTUAL cl_int createProgramFromBinary(const void *pBinary, size_t binarySize, ClDevice &clDevice);
|
||||
|
||||
@@ -350,6 +355,7 @@ class Program : public BaseObject<_cl_program> {
|
||||
|
||||
std::unique_ptr<char[]> packedDeviceBinary;
|
||||
size_t packedDeviceBinarySize = 0U;
|
||||
ProgramInfo::GlobalSurfaceInfo constStringSectionData;
|
||||
};
|
||||
|
||||
std::vector<BuildInfo> buildInfos;
|
||||
|
||||
Reference in New Issue
Block a user