mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 13:33:02 +08:00
Refactor debugData and debugDataSize in OCL.
This commits moves debugData and debugDataSize to buildInfos vector (per root device). - debug data is now stored per device instead of per cl_program - added creation of debug data (incl. debug zebin) and its returning in clGetProgramInfo (CL_PROGRAM_DEBUG_INFO_INTEL). Related-To: NEO-6463 Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
3e66f21df6
commit
306775f7f1
@@ -145,6 +145,8 @@ cl_int Program::build(
|
||||
this->irBinarySize = compilerOuput.intermediateRepresentation.size;
|
||||
this->isSpirV = compilerOuput.intermediateCodeType == IGC::CodeType::spirV;
|
||||
}
|
||||
this->buildInfos[clDevice->getRootDeviceIndex()].debugData = std::move(compilerOuput.debugData.mem);
|
||||
this->buildInfos[clDevice->getRootDeviceIndex()].debugDataSize = compilerOuput.debugData.size;
|
||||
if (BuildPhase::BinaryCreation == phaseReached[clDevice->getRootDeviceIndex()]) {
|
||||
continue;
|
||||
}
|
||||
@@ -154,8 +156,6 @@ cl_int Program::build(
|
||||
if (retVal != CL_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
this->debugData = std::move(compilerOuput.debugData.mem);
|
||||
this->debugDataSize = compilerOuput.debugData.size;
|
||||
}
|
||||
updateNonUniformFlag();
|
||||
|
||||
|
||||
@@ -164,9 +164,10 @@ cl_int Program::compile(
|
||||
this->irBinary = std::move(compilerOuput.intermediateRepresentation.mem);
|
||||
this->irBinarySize = compilerOuput.intermediateRepresentation.size;
|
||||
this->isSpirV = compilerOuput.intermediateCodeType == IGC::CodeType::spirV;
|
||||
this->debugData = std::move(compilerOuput.debugData.mem);
|
||||
this->debugDataSize = compilerOuput.debugData.size;
|
||||
|
||||
for (const auto &device : deviceVector) {
|
||||
this->buildInfos[device->getRootDeviceIndex()].debugData = std::move(compilerOuput.debugData.mem);
|
||||
this->buildInfos[device->getRootDeviceIndex()].debugDataSize = compilerOuput.debugData.size;
|
||||
}
|
||||
updateNonUniformFlag();
|
||||
} while (false);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "shared/source/helpers/get_info.h"
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/device_binary_format/device_binary_formats.h"
|
||||
#include "shared/source/program/kernel_info.h"
|
||||
|
||||
#include "opencl/source/cl_device/cl_device.h"
|
||||
@@ -33,6 +34,7 @@ cl_int Program::getInfo(cl_program_info paramName, size_t paramValueSize,
|
||||
cl_uint clFalse = CL_FALSE;
|
||||
std::vector<cl_device_id> devicesToExpose;
|
||||
StackVec<size_t, 1> binarySizes;
|
||||
StackVec<size_t, 1> debugDataSizes;
|
||||
uint32_t numDevices = static_cast<uint32_t>(clDevices.size());
|
||||
|
||||
switch (paramName) {
|
||||
@@ -137,23 +139,48 @@ cl_int Program::getInfo(cl_program_info paramName, size_t paramValueSize,
|
||||
break;
|
||||
|
||||
case CL_PROGRAM_DEBUG_INFO_SIZES_INTEL:
|
||||
retSize = srcSize = sizeof(debugDataSize);
|
||||
pSrc = &debugDataSize;
|
||||
for (auto i = 0u; i < clDevices.size(); i++) {
|
||||
auto rootDeviceIndex = clDevices[i]->getRootDeviceIndex();
|
||||
if (nullptr == buildInfos[rootDeviceIndex].debugData) {
|
||||
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
|
||||
continue;
|
||||
}
|
||||
debugDataSizes.push_back(buildInfos[rootDeviceIndex].debugDataSize);
|
||||
}
|
||||
pSrc = debugDataSizes.data();
|
||||
retSize = srcSize = debugDataSizes.size() * sizeof(cl_device_id);
|
||||
break;
|
||||
|
||||
case CL_PROGRAM_DEBUG_INFO_INTEL:
|
||||
pSrc = debugData.get();
|
||||
retSize = numDevices * sizeof(void **);
|
||||
srcSize = debugDataSize;
|
||||
if (paramValue != nullptr) {
|
||||
if (paramValueSize < retSize) {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
break;
|
||||
}
|
||||
paramValueSize = srcSize;
|
||||
paramValue = *(void **)paramValue;
|
||||
case CL_PROGRAM_DEBUG_INFO_INTEL: {
|
||||
auto requiredSize = numDevices * sizeof(void **);
|
||||
if (paramValue == nullptr) {
|
||||
retSize = requiredSize;
|
||||
srcSize = 0u;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
if (paramValueSize < requiredSize) {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
break;
|
||||
}
|
||||
auto outputDebugData = reinterpret_cast<unsigned char **>(paramValue);
|
||||
for (auto i = 0u; i < clDevices.size(); i++) {
|
||||
auto rootDeviceIndex = clDevices[i]->getRootDeviceIndex();
|
||||
if (nullptr == buildInfos[rootDeviceIndex].debugData) {
|
||||
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
|
||||
continue;
|
||||
}
|
||||
auto dbgDataSize = buildInfos[rootDeviceIndex].debugDataSize;
|
||||
memcpy_s(outputDebugData[i], dbgDataSize, buildInfos[rootDeviceIndex].debugData.get(), dbgDataSize);
|
||||
}
|
||||
GetInfo::setParamValueReturnSize(paramValueSizeRet, requiredSize, GetInfoStatus::SUCCESS);
|
||||
return CL_SUCCESS;
|
||||
} break;
|
||||
|
||||
case CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT:
|
||||
case CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT:
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "shared/source/compiler_interface/compiler_interface.h"
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/device_binary_format/device_binary_formats.h"
|
||||
#include "shared/source/device_binary_format/elf/elf.h"
|
||||
#include "shared/source/device_binary_format/elf/elf_encoder.h"
|
||||
#include "shared/source/device_binary_format/elf/ocl_elf.h"
|
||||
@@ -157,8 +158,8 @@ cl_int Program::link(
|
||||
}
|
||||
|
||||
this->replaceDeviceBinary(std::move(compilerOuput.deviceBinary.mem), compilerOuput.deviceBinary.size, rootDeviceIndex);
|
||||
this->debugData = std::move(compilerOuput.debugData.mem);
|
||||
this->debugDataSize = compilerOuput.debugData.size;
|
||||
this->buildInfos[device->getRootDeviceIndex()].debugData = std::move(compilerOuput.debugData.mem);
|
||||
this->buildInfos[device->getRootDeviceIndex()].debugDataSize = compilerOuput.debugData.size;
|
||||
|
||||
retVal = processGenBinary(*device);
|
||||
if (retVal != CL_SUCCESS) {
|
||||
@@ -196,8 +197,10 @@ cl_int Program::link(
|
||||
this->irBinary = std::move(compilerOuput.intermediateRepresentation.mem);
|
||||
this->irBinarySize = compilerOuput.intermediateRepresentation.size;
|
||||
this->isSpirV = (compilerOuput.intermediateCodeType == IGC::CodeType::spirV);
|
||||
this->debugData = std::move(compilerOuput.debugData.mem);
|
||||
this->debugDataSize = compilerOuput.debugData.size;
|
||||
for (const auto &device : deviceVector) {
|
||||
this->buildInfos[device->getRootDeviceIndex()].debugData = std::move(compilerOuput.debugData.mem);
|
||||
this->buildInfos[device->getRootDeviceIndex()].debugDataSize = compilerOuput.debugData.size;
|
||||
}
|
||||
binaryType = CL_PROGRAM_BINARY_TYPE_LIBRARY;
|
||||
}
|
||||
if (retVal != CL_SUCCESS) {
|
||||
|
||||
@@ -241,9 +241,9 @@ cl_int Program::processProgramInfo(ProgramInfo &src, const ClDevice &clDevice) {
|
||||
}
|
||||
|
||||
void Program::processDebugData(uint32_t rootDeviceIndex) {
|
||||
if (debugData != nullptr) {
|
||||
if (this->buildInfos[rootDeviceIndex].debugData != nullptr) {
|
||||
auto &kernelInfoArray = buildInfos[rootDeviceIndex].kernelInfoArray;
|
||||
SProgramDebugDataHeaderIGC *programDebugHeader = reinterpret_cast<SProgramDebugDataHeaderIGC *>(debugData.get());
|
||||
SProgramDebugDataHeaderIGC *programDebugHeader = reinterpret_cast<SProgramDebugDataHeaderIGC *>(this->buildInfos[rootDeviceIndex].debugData.get());
|
||||
|
||||
DEBUG_BREAK_IF(programDebugHeader->NumberOfKernels != kernelInfoArray.size());
|
||||
|
||||
@@ -281,16 +281,19 @@ Debug::Segments Program::getZebinSegments(uint32_t rootDeviceIndex) {
|
||||
}
|
||||
|
||||
void Program::createDebugZebin(uint32_t rootDeviceIndex) {
|
||||
if (debugDataSize != 0) {
|
||||
if (this->buildInfos[rootDeviceIndex].debugDataSize != 0) {
|
||||
return;
|
||||
}
|
||||
auto &debugDataRef = this->buildInfos[rootDeviceIndex].debugData;
|
||||
auto &debugDataSizeRef = this->buildInfos[rootDeviceIndex].debugDataSize;
|
||||
|
||||
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,
|
||||
debugDataSizeRef = debugZebin.size();
|
||||
debugDataRef.reset(new char[debugDataSizeRef]);
|
||||
memcpy_s(debugDataRef.get(), debugDataSizeRef,
|
||||
debugZebin.data(), debugZebin.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -185,8 +185,8 @@ cl_int Program::createProgramFromBinary(
|
||||
this->options = singleDeviceBinary.buildOptions.str();
|
||||
|
||||
if (false == singleDeviceBinary.debugData.empty()) {
|
||||
this->debugData = makeCopy(reinterpret_cast<const char *>(singleDeviceBinary.debugData.begin()), singleDeviceBinary.debugData.size());
|
||||
this->debugDataSize = singleDeviceBinary.debugData.size();
|
||||
this->buildInfos[rootDeviceIndex].debugData = makeCopy(reinterpret_cast<const char *>(singleDeviceBinary.debugData.begin()), singleDeviceBinary.debugData.size());
|
||||
this->buildInfos[rootDeviceIndex].debugDataSize = singleDeviceBinary.debugData.size();
|
||||
}
|
||||
bool forceRebuildBuiltInFromIr = isBuiltIn && DebugManager.flags.RebuildPrecompiledKernels.get();
|
||||
if ((false == singleDeviceBinary.deviceBinary.empty()) && (false == forceRebuildBuiltInFromIr)) {
|
||||
@@ -380,7 +380,7 @@ cl_int Program::packDeviceBinary(ClDevice &clDevice) {
|
||||
singleDeviceBinary.targetDevice.stepping = stepping;
|
||||
singleDeviceBinary.deviceBinary = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(this->buildInfos[rootDeviceIndex].unpackedDeviceBinary.get()), this->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize);
|
||||
singleDeviceBinary.intermediateRepresentation = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(this->irBinary.get()), this->irBinarySize);
|
||||
singleDeviceBinary.debugData = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(this->debugData.get()), this->debugDataSize);
|
||||
singleDeviceBinary.debugData = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(this->buildInfos[rootDeviceIndex].debugData.get()), this->buildInfos[rootDeviceIndex].debugDataSize);
|
||||
|
||||
std::string packWarnings;
|
||||
std::string packErrors;
|
||||
|
||||
@@ -221,12 +221,12 @@ class Program : public BaseObject<_cl_program> {
|
||||
return kernelDebugEnabled;
|
||||
}
|
||||
|
||||
char *getDebugData() {
|
||||
return debugData.get();
|
||||
char *getDebugData(uint32_t rootDeviceIndex) {
|
||||
return buildInfos[rootDeviceIndex].debugData.get();
|
||||
}
|
||||
|
||||
size_t getDebugDataSize() {
|
||||
return debugDataSize;
|
||||
size_t getDebugDataSize(uint32_t rootDeviceIndex) {
|
||||
return buildInfos[rootDeviceIndex].debugDataSize;
|
||||
}
|
||||
|
||||
const Linker::RelocatedSymbolsMap &getSymbols(uint32_t rootDeviceIndex) const {
|
||||
@@ -307,9 +307,6 @@ class Program : public BaseObject<_cl_program> {
|
||||
std::unique_ptr<char[]> irBinary;
|
||||
size_t irBinarySize = 0U;
|
||||
|
||||
std::unique_ptr<char[]> debugData;
|
||||
size_t debugDataSize = 0U;
|
||||
|
||||
CreatedFrom createdFrom = CreatedFrom::UNKNOWN;
|
||||
|
||||
struct DeviceBuildInfo {
|
||||
@@ -345,6 +342,9 @@ class Program : public BaseObject<_cl_program> {
|
||||
std::unique_ptr<char[]> packedDeviceBinary;
|
||||
size_t packedDeviceBinarySize = 0U;
|
||||
ProgramInfo::GlobalSurfaceInfo constStringSectionData;
|
||||
|
||||
std::unique_ptr<char[]> debugData;
|
||||
size_t debugDataSize = 0U;
|
||||
};
|
||||
|
||||
std::vector<BuildInfo> buildInfos;
|
||||
|
||||
Reference in New Issue
Block a user