2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2025-01-17 18:24:49 +00:00
|
|
|
* Copyright (C) 2018-2025 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-24 13:10:44 +01:00
|
|
|
#include "shared/source/built_ins/sip.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2020-02-24 13:10:44 +01:00
|
|
|
#include "shared/source/built_ins/built_ins.h"
|
2021-04-16 12:52:30 +00:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2022-12-01 19:42:57 +00:00
|
|
|
#include "shared/source/debugger/debugger.h"
|
2024-06-25 03:03:26 +00:00
|
|
|
#include "shared/source/debugger/debugger_l0.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/device/device.h"
|
|
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
2022-12-15 17:32:03 +00:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2021-04-16 12:52:30 +00:00
|
|
|
#include "shared/source/helpers/aligned_memory.h"
|
2024-09-09 14:49:02 +00:00
|
|
|
#include "shared/source/helpers/compiler_product_helper.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/debug_helpers.h"
|
2023-02-01 16:23:01 +00:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2022-08-28 23:20:29 +00:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/string.h"
|
2020-12-02 10:22:27 +00:00
|
|
|
#include "shared/source/memory_manager/allocation_properties.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
2020-12-02 10:22:27 +00:00
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2021-04-16 12:52:30 +00:00
|
|
|
#include "shared/source/utilities/io_functions.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2021-10-14 16:01:14 +00:00
|
|
|
#include "common/StateSaveAreaHeader.h"
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2023-12-11 11:02:15 +00:00
|
|
|
SipClassType SipKernel::classType = SipClassType::init;
|
2021-04-16 12:52:30 +00:00
|
|
|
|
2021-09-22 17:45:29 +02:00
|
|
|
std::vector<char> readFile(const std::string &fileName, size_t &retSize) {
|
|
|
|
|
std::vector<char> retBuf;
|
|
|
|
|
FILE *fileDescriptor = nullptr;
|
|
|
|
|
long int size = 0;
|
|
|
|
|
size_t bytesRead = 0u;
|
|
|
|
|
retSize = 0;
|
|
|
|
|
|
|
|
|
|
fileDescriptor = IoFunctions::fopenPtr(fileName.c_str(), "rb");
|
|
|
|
|
if (fileDescriptor == NULL) {
|
|
|
|
|
return retBuf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IoFunctions::fseekPtr(fileDescriptor, 0, SEEK_END);
|
|
|
|
|
size = IoFunctions::ftellPtr(fileDescriptor);
|
2023-10-04 15:48:07 +00:00
|
|
|
UNRECOVERABLE_IF(size == -1);
|
2021-09-22 17:45:29 +02:00
|
|
|
IoFunctions::rewindPtr(fileDescriptor);
|
|
|
|
|
|
|
|
|
|
retBuf.resize(size);
|
|
|
|
|
|
|
|
|
|
bytesRead = IoFunctions::freadPtr(retBuf.data(), 1, size, fileDescriptor);
|
|
|
|
|
IoFunctions::fclosePtr(fileDescriptor);
|
|
|
|
|
|
|
|
|
|
if (static_cast<long int>(bytesRead) != size || bytesRead == 0u) {
|
|
|
|
|
retBuf.clear();
|
|
|
|
|
} else {
|
|
|
|
|
retSize = bytesRead;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return retBuf;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-13 11:41:48 +02:00
|
|
|
SipKernel::~SipKernel() = default;
|
2018-03-09 11:52:14 +01:00
|
|
|
|
2022-08-28 23:20:29 +00:00
|
|
|
SipKernel::SipKernel(SipKernelType type, GraphicsAllocation *sipAlloc, std::vector<char> ssah) : stateSaveAreaHeader(std::move(ssah)), sipAllocation(sipAlloc), type(type) {
|
2018-03-09 11:52:14 +01:00
|
|
|
}
|
|
|
|
|
|
2023-08-08 15:18:53 +00:00
|
|
|
SipKernel::SipKernel(SipKernelType type, GraphicsAllocation *sipAlloc, std::vector<char> ssah, std::vector<char> binary) : stateSaveAreaHeader(std::move(ssah)), binary(std::move(binary)), sipAllocation(sipAlloc), type(type) {
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-02 10:22:27 +00:00
|
|
|
GraphicsAllocation *SipKernel::getSipAllocation() const {
|
|
|
|
|
return sipAllocation;
|
2018-03-08 15:52:08 +01:00
|
|
|
}
|
2018-04-06 14:25:22 +02:00
|
|
|
|
2021-03-30 19:31:58 -07:00
|
|
|
const std::vector<char> &SipKernel::getStateSaveAreaHeader() const {
|
|
|
|
|
return stateSaveAreaHeader;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-08 15:18:53 +00:00
|
|
|
const std::vector<char> &SipKernel::getBinary() const {
|
|
|
|
|
return binary;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-16 16:08:37 +00:00
|
|
|
size_t SipKernel::getStateSaveAreaSize(Device *device) const {
|
|
|
|
|
auto &hwInfo = device->getHardwareInfo();
|
2022-12-09 15:11:27 +00:00
|
|
|
auto &gfxCoreHelper = device->getGfxCoreHelper();
|
2022-12-08 12:22:35 +00:00
|
|
|
auto maxDbgSurfaceSize = gfxCoreHelper.getSipKernelMaxDbgSurfaceSize(hwInfo);
|
2022-08-28 23:20:29 +00:00
|
|
|
const auto &stateSaveAreaHeader = getStateSaveAreaHeader();
|
2021-10-14 16:01:14 +00:00
|
|
|
if (stateSaveAreaHeader.empty()) {
|
2022-03-16 16:08:37 +00:00
|
|
|
return maxDbgSurfaceSize;
|
2021-10-14 16:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(stateSaveAreaHeader.data(), "tssarea")) {
|
2022-03-16 16:08:37 +00:00
|
|
|
return maxDbgSurfaceSize;
|
2021-10-14 16:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
2024-06-25 03:03:26 +00:00
|
|
|
auto hdr = reinterpret_cast<const NEO::StateSaveAreaHeader *>(stateSaveAreaHeader.data());
|
2021-10-14 16:01:14 +00:00
|
|
|
|
2023-03-01 21:12:39 +00:00
|
|
|
auto numSlices = NEO::GfxCoreHelper::getHighestEnabledSlice(hwInfo);
|
2024-06-25 03:03:26 +00:00
|
|
|
size_t stateSaveAreaSize = 0;
|
2024-08-26 14:24:54 +00:00
|
|
|
if (hdr->versionHeader.version.major == 4) {
|
|
|
|
|
stateSaveAreaSize = static_cast<size_t>(hdr->totalWmtpDataSize);
|
|
|
|
|
} else if (hdr->versionHeader.version.major == 3) {
|
2024-06-25 03:03:26 +00:00
|
|
|
stateSaveAreaSize = numSlices *
|
|
|
|
|
hdr->regHeaderV3.num_subslices_per_slice *
|
|
|
|
|
hdr->regHeaderV3.num_eus_per_subslice *
|
|
|
|
|
hdr->regHeaderV3.num_threads_per_eu *
|
|
|
|
|
hdr->regHeaderV3.state_save_size +
|
|
|
|
|
hdr->versionHeader.size * 8 + hdr->regHeaderV3.state_area_offset;
|
2024-07-09 15:14:12 +00:00
|
|
|
stateSaveAreaSize += hdr->regHeaderV3.fifo_size * sizeof(SIP::fifo_node);
|
2024-06-25 03:03:26 +00:00
|
|
|
|
2024-08-22 12:38:46 +00:00
|
|
|
} else if (hdr->versionHeader.version.major < 3) {
|
2024-06-25 03:03:26 +00:00
|
|
|
stateSaveAreaSize = numSlices *
|
|
|
|
|
hdr->regHeader.num_subslices_per_slice *
|
|
|
|
|
hdr->regHeader.num_eus_per_subslice *
|
|
|
|
|
hdr->regHeader.num_threads_per_eu *
|
|
|
|
|
hdr->regHeader.state_save_size +
|
|
|
|
|
hdr->versionHeader.size * 8 + hdr->regHeader.state_area_offset;
|
|
|
|
|
}
|
2021-10-14 16:01:14 +00:00
|
|
|
return alignUp(stateSaveAreaSize, MemoryConstants::pageSize);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-16 12:52:30 +00:00
|
|
|
SipKernelType SipKernel::getSipKernelType(Device &device) {
|
2023-08-04 09:19:46 +00:00
|
|
|
if (device.getDebugger() != nullptr) {
|
2024-09-09 14:49:02 +00:00
|
|
|
auto &compilerProductHelper = device.getRootDeviceEnvironment().getHelper<CompilerProductHelper>();
|
|
|
|
|
if (compilerProductHelper.isHeaplessModeEnabled()) {
|
|
|
|
|
return SipKernelType::dbgHeapless;
|
|
|
|
|
} else {
|
|
|
|
|
return SipKernelType::dbgBindless;
|
|
|
|
|
}
|
2022-04-13 09:33:20 +00:00
|
|
|
}
|
2023-08-04 09:19:46 +00:00
|
|
|
bool debuggingEnabled = device.getDebugger() != nullptr;
|
2021-08-18 11:05:17 +00:00
|
|
|
return getSipKernelType(device, debuggingEnabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SipKernelType SipKernel::getSipKernelType(Device &device, bool debuggingEnabled) {
|
2022-12-09 15:11:27 +00:00
|
|
|
auto &gfxCoreHelper = device.getGfxCoreHelper();
|
2022-12-08 12:22:35 +00:00
|
|
|
return gfxCoreHelper.getSipKernelType(debuggingEnabled);
|
2018-04-06 14:25:22 +02:00
|
|
|
}
|
2020-01-20 19:10:01 +01:00
|
|
|
|
2023-03-27 12:03:02 +00:00
|
|
|
bool SipKernel::initBuiltinsSipKernel(SipKernelType type, Device &device, OsContext *context) {
|
|
|
|
|
if (context) {
|
|
|
|
|
device.getBuiltIns()->getSipKernel(device, context);
|
|
|
|
|
} else {
|
|
|
|
|
device.getBuiltIns()->getSipKernel(type, device);
|
|
|
|
|
}
|
2021-04-16 12:52:30 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SipKernel::initRawBinaryFromFileKernel(SipKernelType type, Device &device, std::string &fileName) {
|
2021-04-29 10:09:22 +02:00
|
|
|
uint32_t sipIndex = static_cast<uint32_t>(type);
|
|
|
|
|
uint32_t rootDeviceIndex = device.getRootDeviceIndex();
|
|
|
|
|
|
2023-01-26 16:21:09 +00:00
|
|
|
auto &rootDeviceEnvironment = device.getRootDeviceEnvironment();
|
|
|
|
|
|
|
|
|
|
if (rootDeviceEnvironment.sipKernels[sipIndex].get() != nullptr) {
|
2021-04-29 10:09:22 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-16 12:52:30 +00:00
|
|
|
size_t bytesRead = 0u;
|
2021-09-22 17:45:29 +02:00
|
|
|
auto fileData = readFile(fileName, bytesRead);
|
2021-04-16 12:52:30 +00:00
|
|
|
|
2021-09-22 17:45:29 +02:00
|
|
|
if (bytesRead) {
|
|
|
|
|
void *alignedBuffer = alignedMalloc(bytesRead, MemoryConstants::pageSize);
|
|
|
|
|
memcpy_s(alignedBuffer, bytesRead, fileData.data(), bytesRead);
|
2021-04-16 12:52:30 +00:00
|
|
|
|
2023-12-11 14:24:36 +00:00
|
|
|
const auto allocType = AllocationType::kernelIsaInternal;
|
2021-09-22 17:45:29 +02:00
|
|
|
AllocationProperties properties = {rootDeviceIndex, bytesRead, allocType, device.getDeviceBitfield()};
|
|
|
|
|
properties.flags.use32BitFrontWindow = false;
|
2021-04-16 12:52:30 +00:00
|
|
|
|
2021-09-22 17:45:29 +02:00
|
|
|
auto sipAllocation = device.getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
|
|
|
|
if (sipAllocation == nullptr) {
|
|
|
|
|
alignedFree(alignedBuffer);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-04-16 12:52:30 +00:00
|
|
|
|
2022-12-15 13:33:28 +00:00
|
|
|
auto &productHelper = device.getProductHelper();
|
2021-04-16 12:52:30 +00:00
|
|
|
|
2023-01-26 16:21:09 +00:00
|
|
|
MemoryTransferHelper::transferMemoryToAllocation(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, *sipAllocation),
|
2021-09-22 17:45:29 +02:00
|
|
|
device, sipAllocation, 0, alignedBuffer,
|
|
|
|
|
bytesRead);
|
2021-04-16 12:52:30 +00:00
|
|
|
|
|
|
|
|
alignedFree(alignedBuffer);
|
|
|
|
|
|
2021-09-22 17:45:29 +02:00
|
|
|
auto headerFilename = createHeaderFilename(fileName);
|
|
|
|
|
std::vector<char> stateSaveAreaHeader = readStateSaveAreaHeaderFromFile(headerFilename);
|
|
|
|
|
|
|
|
|
|
device.getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->sipKernels[sipIndex] =
|
|
|
|
|
std::make_unique<SipKernel>(type, sipAllocation, std::move(stateSaveAreaHeader));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-04-16 12:52:30 +00:00
|
|
|
|
2021-09-22 17:45:29 +02:00
|
|
|
std::vector<char> SipKernel::readStateSaveAreaHeaderFromFile(const std::string &fileName) {
|
|
|
|
|
std::vector<char> data;
|
|
|
|
|
size_t bytesRead = 0u;
|
|
|
|
|
data = readFile(fileName, bytesRead);
|
|
|
|
|
return data;
|
|
|
|
|
}
|
2021-04-16 12:52:30 +00:00
|
|
|
|
2021-09-22 17:45:29 +02:00
|
|
|
std::string SipKernel::createHeaderFilename(const std::string &fileName) {
|
|
|
|
|
std::string_view coreName(fileName);
|
|
|
|
|
auto extensionPos = coreName.find('.');
|
|
|
|
|
std::string ext = "";
|
2021-04-16 12:52:30 +00:00
|
|
|
|
2021-09-22 17:45:29 +02:00
|
|
|
if (extensionPos != coreName.npos) {
|
|
|
|
|
ext = coreName.substr(extensionPos, coreName.size() - extensionPos);
|
|
|
|
|
coreName.remove_suffix(coreName.size() - extensionPos);
|
|
|
|
|
}
|
2021-04-16 12:52:30 +00:00
|
|
|
|
2021-09-22 17:45:29 +02:00
|
|
|
std::string headerFilename(coreName);
|
|
|
|
|
headerFilename += "_header" + ext;
|
|
|
|
|
return headerFilename;
|
2020-01-20 19:10:01 +01:00
|
|
|
}
|
2021-03-30 19:31:58 -07:00
|
|
|
|
2021-08-29 23:41:42 +00:00
|
|
|
bool SipKernel::initHexadecimalArraySipKernel(SipKernelType type, Device &device) {
|
2021-09-22 21:39:42 +00:00
|
|
|
uint32_t sipIndex = static_cast<uint32_t>(type);
|
|
|
|
|
uint32_t rootDeviceIndex = device.getRootDeviceIndex();
|
|
|
|
|
auto sipKenel = device.getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->sipKernels[sipIndex].get();
|
|
|
|
|
if (sipKenel != nullptr) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-29 23:41:42 +00:00
|
|
|
uint32_t *sipKernelBinary = nullptr;
|
|
|
|
|
size_t kernelBinarySize = 0u;
|
2023-01-26 16:21:09 +00:00
|
|
|
auto &rootDeviceEnvironment = device.getRootDeviceEnvironment();
|
2022-12-09 15:11:27 +00:00
|
|
|
auto &gfxCoreHelper = device.getGfxCoreHelper();
|
2022-05-02 13:54:24 +00:00
|
|
|
|
2024-01-08 16:22:40 +00:00
|
|
|
gfxCoreHelper.setSipKernelData(sipKernelBinary, kernelBinarySize, rootDeviceEnvironment);
|
2023-12-11 14:24:36 +00:00
|
|
|
const auto allocType = AllocationType::kernelIsaInternal;
|
2021-08-29 23:41:42 +00:00
|
|
|
AllocationProperties properties = {rootDeviceIndex, kernelBinarySize, allocType, device.getDeviceBitfield()};
|
|
|
|
|
properties.flags.use32BitFrontWindow = false;
|
|
|
|
|
|
|
|
|
|
auto sipAllocation = device.getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
|
|
|
|
if (sipAllocation == nullptr) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-12-15 13:33:28 +00:00
|
|
|
auto &productHelper = device.getProductHelper();
|
2023-01-26 16:21:09 +00:00
|
|
|
MemoryTransferHelper::transferMemoryToAllocation(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, *sipAllocation),
|
2021-08-29 23:41:42 +00:00
|
|
|
device, sipAllocation, 0, sipKernelBinary,
|
|
|
|
|
kernelBinarySize);
|
|
|
|
|
|
|
|
|
|
std::vector<char> emptyStateSaveAreaHeader;
|
|
|
|
|
device.getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->sipKernels[sipIndex] =
|
|
|
|
|
std::make_unique<SipKernel>(type, sipAllocation, std::move(emptyStateSaveAreaHeader));
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-16 19:42:54 +00:00
|
|
|
void SipKernel::selectSipClassType(std::string &fileName, Device &device) {
|
|
|
|
|
const GfxCoreHelper &gfxCoreHelper = device.getGfxCoreHelper();
|
2021-04-16 12:52:30 +00:00
|
|
|
const std::string unknown("unk");
|
|
|
|
|
if (fileName.compare(unknown) == 0) {
|
2024-01-16 19:42:54 +00:00
|
|
|
bool debuggingEnabled = device.getDebugger() != nullptr;
|
|
|
|
|
if (debuggingEnabled) {
|
|
|
|
|
SipKernel::classType = SipClassType::builtins;
|
|
|
|
|
} else {
|
|
|
|
|
SipKernel::classType = gfxCoreHelper.isSipKernelAsHexadecimalArrayPreferred()
|
|
|
|
|
? SipClassType::hexadecimalHeaderFile
|
|
|
|
|
: SipClassType::builtins;
|
|
|
|
|
}
|
2021-04-16 12:52:30 +00:00
|
|
|
} else {
|
2023-12-11 11:02:15 +00:00
|
|
|
SipKernel::classType = SipClassType::rawBinaryFromFile;
|
2021-04-16 12:52:30 +00:00
|
|
|
}
|
2024-06-14 14:17:00 +00:00
|
|
|
if (debugManager.flags.ForceSipClass.get() != -1) {
|
|
|
|
|
SipKernel::classType = static_cast<SipClassType>(debugManager.flags.ForceSipClass.get());
|
|
|
|
|
}
|
2021-04-16 12:52:30 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-27 12:03:02 +00:00
|
|
|
bool SipKernel::initSipKernelImpl(SipKernelType type, Device &device, OsContext *context) {
|
2023-11-30 08:32:25 +00:00
|
|
|
std::string fileName = debugManager.flags.LoadBinarySipFromFile.get();
|
2024-01-16 19:42:54 +00:00
|
|
|
SipKernel::selectSipClassType(fileName, device);
|
2021-04-16 12:52:30 +00:00
|
|
|
|
2021-08-29 23:41:42 +00:00
|
|
|
switch (SipKernel::classType) {
|
2023-12-11 11:02:15 +00:00
|
|
|
case SipClassType::rawBinaryFromFile:
|
2021-04-16 12:52:30 +00:00
|
|
|
return SipKernel::initRawBinaryFromFileKernel(type, device, fileName);
|
2023-12-11 11:02:15 +00:00
|
|
|
case SipClassType::hexadecimalHeaderFile:
|
2021-08-29 23:41:42 +00:00
|
|
|
return SipKernel::initHexadecimalArraySipKernel(type, device);
|
|
|
|
|
default:
|
2023-03-27 12:03:02 +00:00
|
|
|
return SipKernel::initBuiltinsSipKernel(type, device, context);
|
2021-04-16 12:52:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const SipKernel &SipKernel::getSipKernelImpl(Device &device) {
|
|
|
|
|
auto sipType = SipKernel::getSipKernelType(device);
|
|
|
|
|
|
2021-08-29 23:41:42 +00:00
|
|
|
switch (SipKernel::classType) {
|
2023-12-11 11:02:15 +00:00
|
|
|
case SipClassType::rawBinaryFromFile:
|
|
|
|
|
case SipClassType::hexadecimalHeaderFile:
|
2021-04-16 12:52:30 +00:00
|
|
|
return *device.getRootDeviceEnvironment().sipKernels[static_cast<uint32_t>(sipType)].get();
|
2021-08-29 23:41:42 +00:00
|
|
|
default:
|
|
|
|
|
return device.getBuiltIns()->getSipKernel(sipType, device);
|
2021-04-16 12:52:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-01 20:53:41 +00:00
|
|
|
const SipKernel &SipKernel::getDebugSipKernel(Device &device) {
|
|
|
|
|
SipKernelType debugSipType;
|
|
|
|
|
auto &compilerProductHelper = device.getRootDeviceEnvironment().getHelper<CompilerProductHelper>();
|
|
|
|
|
if (compilerProductHelper.isHeaplessModeEnabled()) {
|
|
|
|
|
debugSipType = SipKernelType::dbgHeapless;
|
|
|
|
|
} else {
|
|
|
|
|
debugSipType = SipKernelType::dbgBindless;
|
|
|
|
|
}
|
2023-03-27 12:03:02 +00:00
|
|
|
SipKernel::initSipKernelImpl(debugSipType, device, nullptr);
|
2021-10-18 15:59:47 +00:00
|
|
|
|
|
|
|
|
switch (SipKernel::classType) {
|
2023-12-11 11:02:15 +00:00
|
|
|
case SipClassType::rawBinaryFromFile:
|
2021-10-18 15:59:47 +00:00
|
|
|
return *device.getRootDeviceEnvironment().sipKernels[static_cast<uint32_t>(debugSipType)].get();
|
|
|
|
|
default:
|
|
|
|
|
return device.getBuiltIns()->getSipKernel(debugSipType, device);
|
|
|
|
|
}
|
2021-08-18 11:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
2024-10-01 20:53:41 +00:00
|
|
|
const SipKernel &SipKernel::getDebugSipKernel(Device &device, OsContext *context) {
|
|
|
|
|
SipKernelType debugSipType;
|
|
|
|
|
auto &compilerProductHelper = device.getRootDeviceEnvironment().getHelper<CompilerProductHelper>();
|
|
|
|
|
if (compilerProductHelper.isHeaplessModeEnabled()) {
|
|
|
|
|
debugSipType = SipKernelType::dbgHeapless;
|
|
|
|
|
} else {
|
|
|
|
|
debugSipType = SipKernelType::dbgBindless;
|
|
|
|
|
}
|
2023-03-27 12:03:02 +00:00
|
|
|
SipKernel::initSipKernelImpl(debugSipType, device, context);
|
|
|
|
|
|
|
|
|
|
switch (SipKernel::classType) {
|
2023-12-11 11:02:15 +00:00
|
|
|
case SipClassType::rawBinaryFromFile:
|
2023-03-27 12:03:02 +00:00
|
|
|
return *device.getRootDeviceEnvironment().sipKernels[static_cast<uint32_t>(debugSipType)].get();
|
|
|
|
|
default:
|
|
|
|
|
return device.getBuiltIns()->getSipKernel(device, context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-08 15:18:53 +00:00
|
|
|
void SipKernel::parseBinaryForContextId() {
|
|
|
|
|
const int pattern = 0xCAFEBEAD;
|
|
|
|
|
auto memory = reinterpret_cast<const int *>(binary.data());
|
|
|
|
|
const auto sizeInDwords = binary.size() / sizeof(int);
|
|
|
|
|
for (size_t i = 1; i < sizeInDwords; i++) {
|
|
|
|
|
auto currentDword = memory + i;
|
|
|
|
|
if (*currentDword == pattern) {
|
|
|
|
|
for (size_t j = 1; (j < 16) && (i + j < sizeInDwords); j++) {
|
|
|
|
|
|
|
|
|
|
if (*(currentDword + j) == pattern) {
|
|
|
|
|
contextIdOffsets[0] = i;
|
|
|
|
|
contextIdOffsets[1] = i + j;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|