refactor: Remove SourceLevelDebugger

Removed:
- SourceLevelDebugger (with tests)
- DebuggerLibrary
- DebuggerLibraryRestore
- debuggerSupported field from hwInfo.capabilityTable
- HasSourceLevelDebuggerSupport matcher
- ExperimentalEnableSourceLevelDebugger debug var
- EnableMockSourceLevelDebugger debug var
- DebuggerOptDisable debug var
- lib_names.h.in file
- third_party/source_level_debugger/igfx_debug_interchange_types.h

Related-To: NEO-7213
Signed-off-by: Fabian Zwolinski <fabian.zwolinski@intel.com>
This commit is contained in:
Fabian Zwolinski
2023-08-04 09:19:46 +00:00
committed by Compute-Runtime-Automation
parent 7330974116
commit 6fca8ee195
171 changed files with 203 additions and 4933 deletions

View File

@@ -18,7 +18,6 @@
#include "shared/source/helpers/string.h"
#include "shared/source/os_interface/driver_info.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/source_level_debugger/source_level_debugger.h"
#include "opencl/source/gtpin/gtpin_gfx_core_helper.h"
#include "opencl/source/helpers/cl_gfx_core_helper.h"
@@ -57,22 +56,12 @@ ClDevice::ClDevice(Device &device, ClDevice &rootClDevice, Platform *platform) :
subDevices.push_back(std::move(pClSubDevice));
}
if (getSharedDeviceInfo().debuggerActive && getSourceLevelDebugger()) {
auto osInterface = device.getRootDeviceEnvironment().osInterface.get();
getSourceLevelDebugger()->notifyNewDevice(osInterface ? osInterface->getDriverModel()->getDeviceHandle() : 0);
}
}
ClDevice::ClDevice(Device &device, Platform *platformId) : ClDevice(device, *this, platformId) {
}
ClDevice::~ClDevice() {
if (getSharedDeviceInfo().debuggerActive && getSourceLevelDebugger()) {
getSourceLevelDebugger()->notifyDeviceDestruction();
}
for (auto &subDevice : subDevices) {
subDevice.reset();
}
@@ -155,9 +144,7 @@ double ClDevice::getPlatformHostTimerResolution() const { return device.getPlatf
GFXCORE_FAMILY ClDevice::getRenderCoreFamily() const { return device.getRenderCoreFamily(); }
PerformanceCounters *ClDevice::getPerformanceCounters() { return device.getPerformanceCounters(); }
PreemptionMode ClDevice::getPreemptionMode() const { return device.getPreemptionMode(); }
bool ClDevice::isDebuggerActive() const { return device.isDebuggerActive(); }
Debugger *ClDevice::getDebugger() { return device.getDebugger(); }
SourceLevelDebugger *ClDevice::getSourceLevelDebugger() { return device.getSourceLevelDebugger(); }
ExecutionEnvironment *ClDevice::getExecutionEnvironment() const { return device.getExecutionEnvironment(); }
const RootDeviceEnvironment &ClDevice::getRootDeviceEnvironment() const { return device.getRootDeviceEnvironment(); }
bool ClDevice::isFullRangeSvm() const { return device.isFullRangeSvm(); }

View File

@@ -34,7 +34,6 @@ class GmmClientContext;
class MemoryManager;
class PerformanceCounters;
class Platform;
class SourceLevelDebugger;
struct DeviceInfo;
struct EngineControl;
struct HardwareInfo;
@@ -83,9 +82,7 @@ class ClDevice : public BaseObject<_cl_device_id> {
GFXCORE_FAMILY getRenderCoreFamily() const;
PerformanceCounters *getPerformanceCounters();
PreemptionMode getPreemptionMode() const;
bool isDebuggerActive() const;
Debugger *getDebugger();
SourceLevelDebugger *getSourceLevelDebugger();
ExecutionEnvironment *getExecutionEnvironment() const;
const RootDeviceEnvironment &getRootDeviceEnvironment() const;
bool isFullRangeSvm() const;

View File

@@ -519,12 +519,6 @@ void CommandQueueHw<GfxFamily>::processDispatchForKernels(const MultiDispatchInf
device->getDevice().syncBufferHandler->prepareForEnqueue(workGroupsCount, *multiDispatchInfo.peekMainKernel());
}
if (commandType == CL_COMMAND_NDRANGE_KERNEL) {
if (multiDispatchInfo.peekMainKernel()->isKernelDebugEnabled()) {
setupDebugSurface(multiDispatchInfo.peekMainKernel());
}
}
if (event && this->isProfilingEnabled()) {
// Get allocation for timestamps
hwTimeStamps = event->getHwTimeStampNode();

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2018-2022 Intel Corporation
# Copyright (C) 2018-2023 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@@ -18,7 +18,6 @@ set(RUNTIME_SRCS_DLL_BASE
${NEO_SHARED_DIRECTORY}/dll/create_tbx_sockets.cpp
${NEO_SHARED_DIRECTORY}/dll/device_dll.cpp
${NEO_SHARED_DIRECTORY}/dll/direct_submission_controller_enabled.cpp
${NEO_SHARED_DIRECTORY}/dll/source_level_debugger_dll.cpp
${NEO_SHARED_DIRECTORY}/dll/get_devices.cpp
${NEO_SHARED_DIRECTORY}/built_ins/sip_init.cpp
${NEO_SHARED_DIRECTORY}/dll/create_command_stream.cpp

View File

@@ -282,9 +282,6 @@ cl_int Kernel::initialize() {
program->getContextPtr()->setResolvesRequiredInKernels(true);
}
if (program->isKernelDebugEnabled() && isValidOffset(kernelDescriptor.payloadMappings.implicitArgs.systemThreadSurfaceAddress.bindful)) {
debugEnabled = true;
}
auto numArgs = explicitArgs.size();
slmSizes.resize(numArgs);

View File

@@ -352,7 +352,6 @@ class Kernel : public ReferenceTrackedObject<Kernel> {
uint64_t getKernelStartAddress(const bool localIdsGenerationByRuntime, const bool kernelUsesLocalIds, const bool isCssUsed, const bool returnFullAddress) const;
bool isKernelDebugEnabled() const { return debugEnabled; }
void setAdditionalKernelExecInfo(uint32_t additionalKernelExecInfo);
uint32_t getAdditionalKernelExecInfo() const;
MOCKABLE_VIRTUAL bool requiresWaDisableRccRhwoOptimization() const;
@@ -538,7 +537,6 @@ class Kernel : public ReferenceTrackedObject<Kernel> {
bool systolicPipelineSelectMode = false;
bool svmAllocationsRequireCacheFlush = false;
bool isUnifiedMemorySyncRequired = true;
bool debugEnabled = false;
bool singleSubdevicePreferredInCurrentEnqueue = false;
bool kernelHasIndirectAccess = true;
bool anyKernelArgumentUsingSystemMemory = false;

View File

@@ -32,7 +32,7 @@ void BufferHw<GfxFamily>::setArgStateful(void *memory, bool forceNonAuxMode, boo
auto rootDeviceIndex = device.getRootDeviceIndex();
auto graphicsAllocation = multiGraphicsAllocation.getGraphicsAllocation(rootDeviceIndex);
const auto isReadOnly = isValueSet(getFlags(), CL_MEM_READ_ONLY) || isReadOnlyArgument;
auto isDebuggerActive = device.isDebuggerActive() || device.getDebugger() != nullptr;
auto isDebuggerActive = device.getDebugger() != nullptr;
NEO::EncodeSurfaceStateArgs args;
args.outMemory = memory;

View File

@@ -19,7 +19,6 @@
#include "shared/source/helpers/hw_info.h"
#include "shared/source/os_interface/debug_env_reader.h"
#include "shared/source/pin/pin.h"
#include "shared/source/source_level_debugger/source_level_debugger.h"
#include "opencl/source/api/api.h"
#include "opencl/source/cl_device/cl_device.h"
@@ -151,7 +150,7 @@ bool Platform::initialize(std::vector<std::unique_ptr<Device>> devices) {
rootDeviceEnvironment->initDebuggerL0(&pClDevice->getDevice());
}
if (pClDevice->getPreemptionMode() == PreemptionMode::MidThread || pClDevice->isDebuggerActive()) {
if (pClDevice->getPreemptionMode() == PreemptionMode::MidThread) {
bool ret = SipKernel::initSipKernel(SipKernel::getSipKernelType(*pDevice), *pDevice);
UNRECOVERABLE_IF(!ret);
}

View File

@@ -15,7 +15,6 @@
#include "shared/source/helpers/addressing_mode_helper.h"
#include "shared/source/helpers/compiler_options_parser.h"
#include "shared/source/program/kernel_info.h"
#include "shared/source/source_level_debugger/source_level_debugger.h"
#include "shared/source/utilities/logger.h"
#include "opencl/source/cl_device/cl_device.h"
@@ -90,20 +89,6 @@ cl_int Program::build(
break;
}
if (isKernelDebugEnabled()) {
std::string filename;
for (const auto &clDevice : deviceVector) {
if (BuildPhase::SourceCodeNotification == phaseReached[clDevice->getRootDeviceIndex()]) {
continue;
}
appendKernelDebugOptions(*clDevice, internalOptions);
notifyDebuggerWithSourceCode(*clDevice, filename);
prependFilePathToOptions(filename);
phaseReached[clDevice->getRootDeviceIndex()] = BuildPhase::SourceCodeNotification;
}
}
std::string extensions = requiresOpenClCFeatures(options) ? defaultClDevice->peekCompilerExtensionsWithFeatures()
: defaultClDevice->peekCompilerExtensions();
@@ -179,7 +164,7 @@ cl_int Program::build(
break;
}
if (isKernelDebugEnabled() || gtpinIsGTPinInitialized()) {
if (gtpinIsGTPinInitialized()) {
debugNotify(deviceVector, phaseReached);
}
notifyModuleCreate();
@@ -200,20 +185,9 @@ cl_int Program::build(
bool Program::appendKernelDebugOptions(ClDevice &clDevice, std::string &internalOptions) {
CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::debugKernelEnable);
CompilerOptions::concatenateAppend(options, CompilerOptions::generateDebugInfo);
auto debugger = clDevice.getSourceLevelDebugger();
if (debugger && (NEO::SourceLevelDebugger::shouldAppendOptDisable(*debugger))) {
CompilerOptions::concatenateAppend(options, CompilerOptions::optDisable);
}
return true;
}
void Program::notifyDebuggerWithSourceCode(ClDevice &clDevice, std::string &filename) {
if (clDevice.getSourceLevelDebugger()) {
clDevice.getSourceLevelDebugger()->notifySourceCode(sourceCode.c_str(), sourceCode.size(), filename);
}
}
cl_int Program::build(const ClDeviceVector &deviceVector, const char *buildOptions,
std::unordered_map<std::string, BuiltinDispatchInfoBuilder *> &builtinsMap) {
auto ret = this->build(deviceVector, buildOptions);
@@ -255,7 +229,13 @@ void Program::debugNotify(const ClDeviceVector &deviceVector, std::unordered_map
if (BuildPhase::DebugDataNotification == phasesReached[rootDeviceIndex]) {
continue;
}
notifyDebuggerWithDebugData(clDevice);
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)) {
processDebugData(rootDeviceIndex);
}
phasesReached[rootDeviceIndex] = BuildPhase::DebugDataNotification;
}
}

View File

@@ -10,13 +10,13 @@
#include "shared/source/compiler_interface/compiler_warnings/compiler_warnings.h"
#include "shared/source/compiler_interface/external_functions.h"
#include "shared/source/compiler_interface/linker.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/device/device.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"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/helpers/compiler_options_parser.h"
#include "shared/source/source_level_debugger/source_level_debugger.h"
#include "opencl/source/cl_device/cl_device.h"
#include "opencl/source/helpers/cl_validators.h"
@@ -40,7 +40,7 @@ cl_int Program::compile(
UNRECOVERABLE_IF(defaultClDevice == nullptr);
auto &defaultDevice = defaultClDevice->getDevice();
auto internalOptions = getInternalOptions();
std::unordered_map<uint32_t, bool> sourceLevelDebuggerNotified;
do {
if (numInputHeaders == 0) {
if ((headerIncludeNames != nullptr) || (inputHeaders != nullptr)) {
@@ -64,7 +64,6 @@ cl_int Program::compile(
break;
}
for (const auto &device : deviceVector) {
sourceLevelDebuggerNotified[device->getRootDeviceIndex()] = false;
deviceBuildInfos[device].buildStatus = CL_BUILD_IN_PROGRESS;
}
@@ -124,21 +123,7 @@ cl_int Program::compile(
appendAdditionalExtensions(extensions, options, internalOptions);
CompilerOptions::concatenateAppend(internalOptions, extensions);
if (isKernelDebugEnabled()) {
for (const auto &device : deviceVector) {
if (sourceLevelDebuggerNotified[device->getRootDeviceIndex()]) {
continue;
}
std::string filename;
appendKernelDebugOptions(*device, internalOptions);
notifyDebuggerWithSourceCode(*device, filename);
prependFilePathToOptions(filename);
sourceLevelDebuggerNotified[device->getRootDeviceIndex()] = true;
}
}
if (!this->getIsBuiltIn() && DebugManager.flags.InjectInternalBuildOptions.get() != "unk") {
if (!this->getIsBuiltIn() && NEO::DebugManager.flags.InjectInternalBuildOptions.get() != "unk") {
NEO::CompilerOptions::concatenateAppend(internalOptions, NEO::DebugManager.flags.InjectInternalBuildOptions.get());
}

View File

@@ -34,10 +34,9 @@ cl_int Program::link(
auto defaultClDevice = deviceVector[0];
UNRECOVERABLE_IF(defaultClDevice == nullptr);
auto &defaultDevice = defaultClDevice->getDevice();
std::unordered_map<uint32_t, bool> kernelDebugDataNotified;
std::unordered_map<uint32_t, bool> debugOptionsAppended;
auto internalOptions = getInternalOptions();
cl_program_binary_type binaryType = CL_PROGRAM_BINARY_TYPE_NONE;
do {
if ((numInputPrograms == 0) || (inputPrograms == nullptr)) {
retVal = CL_INVALID_VALUE;
@@ -50,8 +49,6 @@ cl_int Program::link(
}
for (const auto &device : deviceVector) {
kernelDebugDataNotified[device->getRootDeviceIndex()] = false;
debugOptionsAppended[device->getRootDeviceIndex()] = false;
deviceBuildInfos[device].buildStatus = CL_BUILD_IN_PROGRESS;
}
@@ -65,17 +62,6 @@ cl_int Program::link(
}
}
if (isKernelDebugEnabled()) {
for (auto &device : deviceVector) {
if (debugOptionsAppended[device->getRootDeviceIndex()]) {
continue;
}
appendKernelDebugOptions(*device, internalOptions);
debugOptionsAppended[device->getRootDeviceIndex()] = true;
}
}
isCreateLibrary = CompilerOptions::contains(options, CompilerOptions::createLibrary);
NEO::Elf::ElfEncoder<> elfEncoder(true, false, 1U);
@@ -161,14 +147,6 @@ cl_int Program::link(
break;
}
binaryType = CL_PROGRAM_BINARY_TYPE_EXECUTABLE;
if (isKernelDebugEnabled()) {
if (kernelDebugDataNotified[rootDeviceIndex]) {
continue;
}
notifyDebuggerWithDebugData(device);
kernelDebugDataNotified[device->getRootDeviceIndex()] = true;
}
}
} else {

View File

@@ -22,7 +22,6 @@
#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 "shared/source/utilities/time_measure_wrapper.h"
#include "opencl/source/cl_device/cl_device.h"
@@ -349,31 +348,6 @@ void Program::createDebugZebin(uint32_t rootDeviceIndex) {
debugZebin.data(), debugZebin.size());
}
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);
}
}
}
}
void Program::callPopulateZebinExtendedArgsMetadataOnce(uint32_t rootDeviceIndex) {
auto &buildInfo = this->buildInfos[rootDeviceIndex];
auto extractAndDecodeMetadata = [&]() {

View File

@@ -57,8 +57,8 @@ Program::Program(Context *context, bool isBuiltIn, const ClDeviceVector &clDevic
buildInfos.resize(maxRootDeviceIndex + 1);
debuggerInfos.resize(maxRootDeviceIndex + 1);
kernelDebugEnabled = clDevices[0]->isDebuggerActive();
}
std::string Program::getInternalOptions() const {
auto pClDevice = clDevices[0];
auto force32BitAddressess = pClDevice->getSharedDeviceInfo().force32BitAddressess;
@@ -104,7 +104,7 @@ std::string Program::getInternalOptions() const {
}
CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::preserveVec3Type);
auto isDebuggerActive = pClDevice->getDevice().isDebuggerActive() || pClDevice->getDevice().getDebugger() != nullptr;
auto isDebuggerActive = pClDevice->getDevice().getDebugger() != nullptr;
CompilerOptions::concatenateAppend(internalOptions, compilerProductHelper.getCachingPolicyOptions(isDebuggerActive));
return internalOptions;
}

View File

@@ -211,14 +211,6 @@ class Program : public BaseObject<_cl_program> {
return programOptionVersion;
}
void enableKernelDebug() {
kernelDebugEnabled = true;
}
bool isKernelDebugEnabled() {
return kernelDebugEnabled;
}
char *getDebugData(uint32_t rootDeviceIndex) {
return buildInfos[rootDeviceIndex].debugData.get();
}
@@ -275,7 +267,6 @@ class Program : public BaseObject<_cl_program> {
}
MOCKABLE_VIRTUAL void debugNotify(const ClDeviceVector &deviceVector, std::unordered_map<uint32_t, BuildPhase> &phasesReached);
void notifyDebuggerWithDebugData(ClDevice *clDevice);
MOCKABLE_VIRTUAL void createDebugZebin(uint32_t rootDeviceIndex);
Zebin::Debug::Segments getZebinSegments(uint32_t rootDeviceIndex);
MOCKABLE_VIRTUAL void callPopulateZebinExtendedArgsMetadataOnce(uint32_t rootDeviceIndex);
@@ -298,7 +289,6 @@ class Program : public BaseObject<_cl_program> {
MOCKABLE_VIRTUAL bool isOptionValueValid(ConstStringRef option, ConstStringRef value);
MOCKABLE_VIRTUAL bool appendKernelDebugOptions(ClDevice &clDevice, std::string &internalOptions);
void notifyDebuggerWithSourceCode(ClDevice &clDevice, std::string &filename);
void prependFilePathToOptions(const std::string &filename);
void setBuildStatus(cl_build_status status);
@@ -378,7 +368,6 @@ class Program : public BaseObject<_cl_program> {
ClDeviceVector clDevicesInProgram;
bool isBuiltIn = false;
bool kernelDebugEnabled = false;
bool isGeneratedByIgc = true;
uint32_t maxRootDeviceIndex = std::numeric_limits<uint32_t>::max();

View File

@@ -14,7 +14,6 @@
#include "shared/test/common/mocks/mock_csr.h"
#include "shared/test/common/mocks/mock_direct_submission_hw.h"
#include "shared/test/common/mocks/mock_os_library.h"
#include "shared/test/common/mocks/mock_source_level_debugger.h"
#include "shared/test/common/mocks/mock_timestamp_container.h"
#include "shared/test/common/utilities/base_object_utils.h"
@@ -28,22 +27,6 @@
using namespace NEO;
HWTEST_F(CommandQueueHwTest, WhenConstructingTwoCommandQueuesThenOnlyOneDebugSurfaceIsAllocated) {
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(new MockActiveSourceLevelDebugger(new MockOsLibrary));
auto device = std::make_unique<MockClDevice>(MockDevice::create<MockDeviceWithDebuggerActive>(executionEnvironment, 0u));
auto sipType = SipKernel::getSipKernelType(device->getDevice());
SipKernel::initSipKernel(sipType, device->getDevice());
MockCommandQueueHw<FamilyType> mockCmdQueueHw1(context, device.get(), nullptr);
auto dbgSurface = mockCmdQueueHw1.getGpgpuCommandStreamReceiver().getDebugSurfaceAllocation();
EXPECT_NE(dbgSurface, nullptr);
MockCommandQueueHw<FamilyType> mockCmdQueueHw2(context, device.get(), nullptr);
EXPECT_EQ(dbgSurface, mockCmdQueueHw1.getGpgpuCommandStreamReceiver().getDebugSurfaceAllocation());
}
HWTEST_F(CommandQueueHwTest, givenNoTimestampPacketsWhenWaitForTimestampsThenNoWaitAndTagIsNotUpdated) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableTimestampPacket.set(0);
@@ -111,55 +94,6 @@ HWTEST_F(CommandQueueHwTest, givenEnableTimestampWaitForQueuesWhenGpuHangDetecte
EXPECT_EQ(WaitStatus::GpuHang, status);
}
HWTEST_F(CommandQueueHwTest, WhenDebugSurfaceIsAllocatedThenBufferIsZeroed) {
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(new MockActiveSourceLevelDebugger(new MockOsLibrary));
auto device = std::make_unique<MockClDevice>(MockDevice::create<MockDeviceWithDebuggerActive>(executionEnvironment, 0u));
auto sipType = SipKernel::getSipKernelType(device->getDevice());
SipKernel::initSipKernel(sipType, device->getDevice());
MockCommandQueueHw<FamilyType> mockCmdQueueHw1(context, device.get(), nullptr);
auto dbgSurface = mockCmdQueueHw1.getGpgpuCommandStreamReceiver().getDebugSurfaceAllocation();
EXPECT_NE(dbgSurface, nullptr);
auto mem = dbgSurface->getUnderlyingBuffer();
ASSERT_NE(nullptr, mem);
auto &stateSaveAreaHeader = SipKernel::getSipKernel(device->getDevice(), nullptr).getStateSaveAreaHeader();
mem = ptrOffset(mem, stateSaveAreaHeader.size());
auto size = dbgSurface->getUnderlyingBufferSize() - stateSaveAreaHeader.size();
EXPECT_TRUE(memoryZeroed(mem, size));
}
HWTEST_F(CommandQueueHwTest, WhenConstructingCommandQueueDebugOnButIgcDoesNotReturnSSAHDoNotCopyIt) {
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(new MockActiveSourceLevelDebugger(new MockOsLibrary));
MockGraphicsAllocation sipAlloc1;
auto mockSip1 = std::make_unique<MockSipKernel>(SipKernelType::DbgCsrLocal, &sipAlloc1);
mockSip1->mockStateSaveAreaHeader.clear();
MockGraphicsAllocation sipAlloc2;
auto mockSip2 = std::make_unique<MockSipKernel>(SipKernelType::DbgCsr, &sipAlloc2);
mockSip2->mockStateSaveAreaHeader.clear();
auto mockBuiltIns = new MockBuiltins();
mockBuiltIns->overrideSipKernel(std::move(mockSip1));
mockBuiltIns->overrideSipKernel(std::move(mockSip2));
executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltIns);
auto device = std::make_unique<MockClDevice>(MockDevice::create<MockDeviceWithDebuggerActive>(executionEnvironment, 0u));
MockCommandQueueHw<FamilyType> mockCmdQueueHw1(context, device.get(), nullptr);
auto dbgSurface = mockCmdQueueHw1.getGpgpuCommandStreamReceiver().getDebugSurfaceAllocation();
EXPECT_NE(dbgSurface, nullptr);
auto &stateSaveAreaHeader = SipKernel::getSipKernel(device->getDevice(), nullptr).getStateSaveAreaHeader();
EXPECT_EQ(static_cast<size_t>(0), stateSaveAreaHeader.size());
}
HWTEST_F(CommandQueueHwTest, givenMultiDispatchInfoWhenAskingForAuxTranslationThenCheckMemObjectsCountAndDebugFlag) {
DebugManagerStateRestore restore;
MockBuffer buffer;

View File

@@ -1483,10 +1483,9 @@ TEST(CommandQueue, givenEnqueueAcquireSharedObjectsCallWhenAcquireFailsThenCorre
buffer->setSharingHandler(nullptr);
}
HWTEST_F(CommandQueueCommandStreamTest, givenDebugKernelWhenSetupDebugSurfaceIsCalledThenSurfaceStateIsCorrectlySet) {
HWTEST_F(CommandQueueCommandStreamTest, WhenSetupDebugSurfaceIsCalledThenSurfaceStateIsCorrectlySet) {
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockProgram program(toClDeviceVector(*pClDevice));
program.enableKernelDebug();
std::unique_ptr<MockDebugKernel> kernel(MockKernel::create<MockDebugKernel>(*pDevice, &program));
MockCommandQueue cmdQ(context.get(), pClDevice, 0, false);
@@ -1505,10 +1504,9 @@ HWTEST_F(CommandQueueCommandStreamTest, givenDebugKernelWhenSetupDebugSurfaceIsC
EXPECT_EQ(debugSurface->getGpuAddress(), surfaceState->getSurfaceBaseAddress());
}
HWTEST_F(CommandQueueCommandStreamTest, givenCsrWithDebugSurfaceAllocatedWhenSetupDebugSurfaceIsCalledThenDebugSurfaceIsReused) {
HWTEST_F(CommandQueueCommandStreamTest, WhenSetupDebugSurfaceIsCalledThenDebugSurfaceIsReused) {
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockProgram program(toClDeviceVector(*pClDevice));
program.enableKernelDebug();
std::unique_ptr<MockDebugKernel> kernel(MockKernel::create<MockDebugKernel>(*pDevice, &program));
MockCommandQueue cmdQ(context.get(), pClDevice, 0, false);

View File

@@ -1515,7 +1515,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterDispatchWalkerBasicTestDynamicPartition
size_t gws[] = {128, 1, 1};
size_t lws[] = {8, 1, 1};
auto &commandStreamReceiver = cmdQ->getUltCommandStreamReceiver();
if (device->getPreemptionMode() == PreemptionMode::MidThread || device->isDebuggerActive()) {
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
commandStreamReceiver.createPreemptionAllocation();
}
EXPECT_EQ(1u, commandStreamReceiver.activePartitions);
@@ -1551,7 +1551,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterDispatchWalkerBasicTestStaticPartition,
size_t gws[] = {128, 1, 1};
size_t lws[] = {8, 1, 1};
auto &commandStreamReceiver = cmdQ->getUltCommandStreamReceiver();
if (device->getPreemptionMode() == PreemptionMode::MidThread || device->isDebuggerActive()) {
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
commandStreamReceiver.createPreemptionAllocation();
}
EXPECT_EQ(2u, commandStreamReceiver.activePartitions);
@@ -1577,7 +1577,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterDispatchWalkerBasicTestStaticPartition,
size_t gws[] = {129, 1, 1};
size_t lws[] = {8, 1, 1};
auto &commandStreamReceiver = cmdQ->getUltCommandStreamReceiver();
if (device->getPreemptionMode() == PreemptionMode::MidThread || device->isDebuggerActive()) {
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
commandStreamReceiver.createPreemptionAllocation();
}
EXPECT_EQ(2u, commandStreamReceiver.activePartitions);
@@ -1929,7 +1929,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterDispatchWalkerTestMultiTileDevice, give
size_t gws[] = {2, 1, 1};
size_t lws[] = {1, 1, 1};
auto &commandStreamReceiver = cmdQ->getUltCommandStreamReceiver();
if (device->getPreemptionMode() == PreemptionMode::MidThread || device->isDebuggerActive()) {
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
commandStreamReceiver.createPreemptionAllocation();
}
KernelWithSingleSubdevicePreferences subdeviceKernel(kernel->mockProgram, kernel->kernelInfo, *device);
@@ -1953,7 +1953,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterDispatchWalkerTestMultiTileDevice, give
size_t gws[] = {2, 1, 1};
size_t lws[] = {1, 1, 1};
auto &commandStreamReceiver = cmdQ->getUltCommandStreamReceiver();
if (device->getPreemptionMode() == PreemptionMode::MidThread || device->isDebuggerActive()) {
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
commandStreamReceiver.createPreemptionAllocation();
}
KernelWithSingleSubdevicePreferences subdeviceKernel(kernel->mockProgram, kernel->kernelInfo, *device);

View File

@@ -8,7 +8,6 @@
#include "shared/source/built_ins/sip.h"
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/os_interface/os_context.h"
#include "shared/source/source_level_debugger/source_level_debugger.h"
#include "shared/test/common/helpers/kernel_binary_helper.h"
#include "shared/test/common/helpers/kernel_filename_helper.h"
#include "shared/test/common/helpers/unit_test_helper.h"
@@ -29,108 +28,6 @@ using namespace NEO;
typedef EnqueueHandlerTest EnqueueDebugKernelSimpleTest;
class EnqueueDebugKernelFixture {
public:
void setUp() {
clDevice = context.getDevice(0);
device = &clDevice->getDevice();
device->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->debugger.reset(new SourceLevelDebugger(nullptr));
auto sipType = SipKernel::getSipKernelType(*device);
SipKernel::initSipKernel(sipType, *device);
if (device->getHardwareInfo().platform.eRenderCoreFamily >= IGFX_GEN9_CORE) {
const_cast<DeviceInfo &>(device->getDeviceInfo()).debuggerActive = true;
program = std::make_unique<MockDebugProgram>(context.getDevices());
cl_int retVal = program->build(program->getDevices(), nullptr);
ASSERT_EQ(CL_SUCCESS, retVal);
multiDeviceKernel = MultiDeviceKernel::create(
static_cast<NEO::Program *>(program.get()),
MockKernel::toKernelInfoContainer(*program->getKernelInfo("kernel", 0), device->getRootDeviceIndex()),
retVal);
debugKernel = multiDeviceKernel->getKernel(device->getRootDeviceIndex());
ASSERT_EQ(CL_SUCCESS, retVal);
ASSERT_NE(nullptr, debugKernel);
}
}
void tearDown() {
if (multiDeviceKernel != nullptr) {
multiDeviceKernel->release();
}
program.reset();
}
std::unique_ptr<char[]> ssh = nullptr;
std::unique_ptr<MockDebugProgram> program = nullptr;
NEO::ClDevice *clDevice = nullptr;
NEO::Device *device = nullptr;
Kernel *debugKernel = nullptr;
MultiDeviceKernel *multiDeviceKernel = nullptr;
MockContext context;
MockBuffer bufferSrc;
MockBuffer bufferDst;
};
using EnqueueDebugKernelTest = Test<EnqueueDebugKernelFixture>;
HWTEST_F(EnqueueDebugKernelTest, givenDebugKernelWhenEnqueuedThenSSHAndBtiAreCorrectlySet) {
if (device->isDebuggerActive()) {
using BINDING_TABLE_STATE = typename FamilyType::BINDING_TABLE_STATE;
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
std::unique_ptr<MockCommandQueueHw<FamilyType>> mockCmdQ(new MockCommandQueueHw<FamilyType>(&context, clDevice, 0));
size_t gws[] = {1, 1, 1};
auto &ssh = mockCmdQ->getIndirectHeap(IndirectHeap::Type::SURFACE_STATE, 4096u);
void *surfaceStates = ssh.getSpace(0);
mockCmdQ->enqueueKernel(debugKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
auto *dstBtiTableBase = reinterpret_cast<BINDING_TABLE_STATE *>(ptrOffset(surfaceStates, debugKernel->getBindingTableOffset()));
uint32_t surfaceStateOffset = dstBtiTableBase[0].getSurfaceStatePointer();
auto debugSurfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(ssh.getCpuBase(), surfaceStateOffset));
auto &commandStreamReceiver = mockCmdQ->getGpgpuCommandStreamReceiver();
auto debugSurface = commandStreamReceiver.getDebugSurfaceAllocation();
EXPECT_EQ(1u, debugSurface->getTaskCount(commandStreamReceiver.getOsContext().getContextId()));
EXPECT_EQ(debugSurface->getGpuAddress(), debugSurfaceState->getSurfaceBaseAddress());
}
}
HWTEST_F(EnqueueDebugKernelTest, givenDebugKernelWhenEnqueuedThenSurfaceStateForDebugSurfaceIsSetAtBindlessOffsetZero) {
if (device->isDebuggerActive()) {
using BINDING_TABLE_STATE = typename FamilyType::BINDING_TABLE_STATE;
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
std::unique_ptr<MockCommandQueueHw<FamilyType>> mockCmdQ(new MockCommandQueueHw<FamilyType>(&context, clDevice, 0));
size_t gws[] = {1, 1, 1};
auto &ssh = mockCmdQ->getIndirectHeap(IndirectHeap::Type::SURFACE_STATE, 4096u);
mockCmdQ->enqueueKernel(debugKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
auto debugSurfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ssh.getCpuBase());
auto &commandStreamReceiver = mockCmdQ->getGpgpuCommandStreamReceiver();
auto debugSurface = commandStreamReceiver.getDebugSurfaceAllocation();
SURFACE_STATE_BUFFER_LENGTH length;
length.length = static_cast<uint32_t>(debugSurface->getUnderlyingBufferSize() - 1);
EXPECT_EQ(length.surfaceState.depth + 1u, debugSurfaceState->getDepth());
EXPECT_EQ(length.surfaceState.width + 1u, debugSurfaceState->getWidth());
EXPECT_EQ(length.surfaceState.height + 1u, debugSurfaceState->getHeight());
EXPECT_EQ(debugSurface->getGpuAddress(), debugSurfaceState->getSurfaceBaseAddress());
EXPECT_EQ(RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER, debugSurfaceState->getSurfaceType());
EXPECT_EQ(UnitTestHelper<FamilyType>::getCoherencyTypeSupported(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT), debugSurfaceState->getCoherencyType());
}
}
template <typename GfxFamily>
class MockCommandQueueHwSetupDebugSurface : public CommandQueueHw<GfxFamily> {
typedef CommandQueueHw<GfxFamily> BaseClass;
@@ -154,42 +51,6 @@ class MockCommandQueueHwSetupDebugSurface : public CommandQueueHw<GfxFamily> {
bool setupDebugSurfaceResult = true;
};
HWTEST_F(EnqueueDebugKernelSimpleTest, givenKernelFromProgramWithDebugEnabledWhenEnqueuedThenDebugSurfaceIsSetup) {
MockProgram program(context, false, toClDeviceVector(*pClDevice));
program.enableKernelDebug();
std::unique_ptr<MockDebugKernel> kernel(MockKernel::create<MockDebugKernel>(*pDevice, &program));
kernel->initialize();
std::unique_ptr<MockCommandQueueHwSetupDebugSurface<FamilyType>> mockCmdQ(new MockCommandQueueHwSetupDebugSurface<FamilyType>(context, pClDevice, 0));
auto hwInfo = *NEO::defaultHwInfo.get();
auto &gfxCoreHelper = pClDevice->getGfxCoreHelper();
mockCmdQ->getGpgpuCommandStreamReceiver().allocateDebugSurface(gfxCoreHelper.getSipKernelMaxDbgSurfaceSize(hwInfo));
mockCmdQ->setupDebugSurfaceParamsPassed.clear();
EXPECT_TRUE(isValidOffset(kernel->getKernelInfo().kernelDescriptor.payloadMappings.implicitArgs.systemThreadSurfaceAddress.bindful));
size_t gws[] = {1, 1, 1};
mockCmdQ->enqueueKernel(kernel.get(), 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(1u, mockCmdQ->setupDebugSurfaceCalled);
EXPECT_EQ(kernel.get(), mockCmdQ->setupDebugSurfaceParamsPassed[0].kernel);
}
HWTEST_F(EnqueueDebugKernelSimpleTest, givenKernelWithoutSystemThreadSurfaceWhenEnqueuedThenDebugSurfaceIsNotSetup) {
MockProgram program(context, false, toClDeviceVector(*pClDevice));
program.enableKernelDebug();
std::unique_ptr<MockKernel> kernel(MockKernel::create<MockKernel>(*pDevice, &program));
kernel->initialize();
EXPECT_FALSE(isValidOffset(kernel->getKernelInfo().kernelDescriptor.payloadMappings.implicitArgs.systemThreadSurfaceAddress.bindful));
std::unique_ptr<MockCommandQueueHwSetupDebugSurface<FamilyType>> mockCmdQ(new MockCommandQueueHwSetupDebugSurface<FamilyType>(context, pClDevice, 0));
size_t gws[] = {1, 1, 1};
mockCmdQ->enqueueKernel(kernel.get(), 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(0u, mockCmdQ->setupDebugSurfaceCalled);
}
HWTEST_F(EnqueueDebugKernelSimpleTest, givenKernelFromProgramWithoutDebugEnabledWhenEnqueuedThenDebugSurfaceIsNotSetup) {
MockProgram program(context, false, toClDeviceVector(*pClDevice));
std::unique_ptr<MockDebugKernel> kernel(MockKernel::create<MockDebugKernel>(*pDevice, &program));
@@ -201,16 +62,3 @@ HWTEST_F(EnqueueDebugKernelSimpleTest, givenKernelFromProgramWithoutDebugEnabled
EXPECT_EQ(nullptr, mockCmdQ->getGpgpuCommandStreamReceiver().getDebugSurfaceAllocation());
EXPECT_EQ(0u, mockCmdQ->setupDebugSurfaceCalled);
}
using ActiveDebuggerTest = EnqueueDebugKernelTest;
HWTEST_F(ActiveDebuggerTest, givenKernelFromProgramWithoutDebugEnabledAndActiveDebuggerWhenEnqueuedThenDebugSurfaceIsSetup) {
MockProgram program(&context, false, toClDeviceVector(*clDevice));
std::unique_ptr<MockDebugKernel> kernel(MockKernel::create<MockDebugKernel>(*device, &program));
std::unique_ptr<CommandQueueHw<FamilyType>> cmdQ(new CommandQueueHw<FamilyType>(&context, clDevice, nullptr, false));
size_t gws[] = {1, 1, 1};
cmdQ->enqueueKernel(kernel.get(), 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
EXPECT_NE(nullptr, cmdQ->getGpgpuCommandStreamReceiver().getDebugSurfaceAllocation());
}

View File

@@ -871,7 +871,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenTotalRes
auto mockCsr = std::make_unique<MockCsrHw2<FamilyType>>(*executionEnvironment, 0, pDevice->getDeviceBitfield());
mockCsr->setupContext(*pDevice->getDefaultEngine().osContext);
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread || pDevice->isDebuggerActive()) {
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread) {
mockCsr->createPreemptionAllocation();
}

View File

@@ -129,92 +129,6 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterTests, gi
EXPECT_TRUE(UnitTestHelper<FamilyType>::getPipeControlHdcPipelineFlush(*pipeControlCmd));
}
HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterTests, givenProgramExtendedPipeControlPriorToNonPipelinedStateCommandEnabledAndStateSipWhenItIsRequiredThenThereIsPipeControlPriorToIt) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ProgramExtendedPipeControlPriorToNonPipelinedStateCommand.set(true);
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
using STATE_SIP = typename FamilyType::STATE_SIP;
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
pDevice->executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(new MockDebugger);
auto sipType = SipKernel::getSipKernelType(*pDevice);
SipKernel::initSipKernel(sipType, *pDevice);
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
configureCSRtoNonDirtyState<FamilyType>(false);
commandStreamReceiver.isStateSipSent = false;
flushTask(commandStreamReceiver);
parseCommands<FamilyType>(commandStreamReceiver.getCS(0));
auto requiredCmdSize = PreemptionHelper::getRequiredStateSipCmdSize<FamilyType>(*pDevice, false);
auto cmdSize = sizeof(STATE_SIP) + sizeof(PIPE_CONTROL);
EXPECT_EQ(cmdSize, requiredCmdSize);
auto pipeControlIterator = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
auto pipeControlCmd = genCmdCast<PIPE_CONTROL *>(*pipeControlIterator);
EXPECT_TRUE(UnitTestHelper<FamilyType>::getPipeControlHdcPipelineFlush(*pipeControlCmd));
EXPECT_TRUE(pipeControlCmd->getAmfsFlushEnable());
EXPECT_TRUE(pipeControlCmd->getCommandStreamerStallEnable());
EXPECT_TRUE(pipeControlCmd->getInstructionCacheInvalidateEnable());
EXPECT_TRUE(pipeControlCmd->getTextureCacheInvalidationEnable());
EXPECT_TRUE(pipeControlCmd->getConstantCacheInvalidationEnable());
EXPECT_TRUE(pipeControlCmd->getStateCacheInvalidationEnable());
auto sipIterator = find<STATE_SIP *>(cmdList.begin(), cmdList.end());
auto sipCmd = genCmdCast<STATE_SIP *>(*sipIterator);
auto sipAllocation = SipKernel::getSipKernel(*pDevice, nullptr).getSipAllocation();
EXPECT_EQ(sipAllocation->getGpuAddressToPatch(), sipCmd->getSystemInstructionPointer());
}
HWTEST2_F(CommandStreamReceiverFlushTaskXeHPAndLaterTests, givenProgramPipeControlPriorToNonPipelinedStateCommandAndStateSipWhenItIsRequiredThenThereIsPipeControlPriorToIt, IsXeHpgCore) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
using STATE_SIP = typename FamilyType::STATE_SIP;
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
pDevice->executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(new MockDebugger);
auto sipType = SipKernel::getSipKernelType(*pDevice);
SipKernel::initSipKernel(sipType, *pDevice);
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
configureCSRtoNonDirtyState<FamilyType>(false);
commandStreamReceiver.isStateSipSent = false;
flushTask(commandStreamReceiver);
parseCommands<FamilyType>(commandStreamReceiver.getCS(0));
auto requiredCmdSize = PreemptionHelper::getRequiredStateSipCmdSize<FamilyType>(*pDevice, false);
auto cmdSize = sizeof(STATE_SIP) + sizeof(PIPE_CONTROL);
EXPECT_EQ(cmdSize, requiredCmdSize);
// first PC prior SBA
auto pipeControlIterator = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
pipeControlIterator = find<PIPE_CONTROL *>(++pipeControlIterator, cmdList.end());
auto pipeControlCmd = genCmdCast<PIPE_CONTROL *>(*pipeControlIterator);
EXPECT_TRUE(UnitTestHelper<FamilyType>::getPipeControlHdcPipelineFlush(*pipeControlCmd));
EXPECT_TRUE(pipeControlCmd->getUnTypedDataPortCacheFlush());
EXPECT_FALSE(pipeControlCmd->getAmfsFlushEnable());
EXPECT_FALSE(pipeControlCmd->getInstructionCacheInvalidateEnable());
EXPECT_FALSE(pipeControlCmd->getTextureCacheInvalidationEnable());
EXPECT_FALSE(pipeControlCmd->getConstantCacheInvalidationEnable());
EXPECT_FALSE(pipeControlCmd->getStateCacheInvalidationEnable());
auto sipIterator = find<STATE_SIP *>(cmdList.begin(), cmdList.end());
auto sipCmd = genCmdCast<STATE_SIP *>(*sipIterator);
auto sipAllocation = SipKernel::getSipKernel(*pDevice, nullptr).getSipAllocation();
EXPECT_EQ(sipAllocation->getGpuAddressToPatch(), sipCmd->getSystemInstructionPointer());
}
HWTEST2_F(CommandStreamReceiverFlushTaskXeHPAndLaterTests, givenProgramExtendedPipeControlPriorToNonPipelinedStateCommandEnabledAndStateSipWhenA0SteppingIsActivatedThenOnlyGlobalSipIsProgrammed, IsXEHP) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ProgramExtendedPipeControlPriorToNonPipelinedStateCommand.set(true);
@@ -912,7 +826,7 @@ struct CommandStreamReceiverFlushTaskXeHPAndLaterMultiTileTests : public Command
HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTileTests,
givenMultipleStaticActivePartitionsWhenFlushingTaskThenExpectTagUpdatePipeControlWithPartitionFlagOnAndActivePartitionConfig) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread || pDevice->isDebuggerActive()) {
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread) {
commandStreamReceiver.createPreemptionAllocation();
}
EXPECT_EQ(1u, commandStreamReceiver.activePartitionsConfig);
@@ -935,7 +849,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTile
DebugManager.flags.UpdateTaskCountFromWait.set(3);
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread || pDevice->isDebuggerActive()) {
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread) {
commandStreamReceiver.createPreemptionAllocation();
}
EXPECT_EQ(1u, commandStreamReceiver.activePartitionsConfig);
@@ -953,7 +867,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTile
HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTileTests,
givenSingleStaticActivePartitionWhenFlushingTaskThenExpectTagUpdatePipeControlWithoutPartitionFlagOnAndNoActivePartitionConfig) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread || pDevice->isDebuggerActive()) {
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread) {
commandStreamReceiver.createPreemptionAllocation();
}
commandStreamReceiver.activePartitions = 1;
@@ -976,7 +890,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTile
DebugManager.flags.UpdateTaskCountFromWait.set(3);
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread || pDevice->isDebuggerActive()) {
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread) {
commandStreamReceiver.createPreemptionAllocation();
}
EXPECT_EQ(1u, commandStreamReceiver.activePartitionsConfig);
@@ -1007,7 +921,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTile
HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTileTests,
givenMultipleDynamicActivePartitionsWhenFlushingTaskTwiceThenExpectTagUpdatePipeControlWithoutPartitionFlagAndPartitionRegisters) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread || pDevice->isDebuggerActive()) {
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread) {
commandStreamReceiver.createPreemptionAllocation();
}
@@ -1030,7 +944,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTile
DebugManager.flags.UpdateTaskCountFromWait.set(1);
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread || pDevice->isDebuggerActive()) {
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread) {
commandStreamReceiver.createPreemptionAllocation();
}
commandStreamReceiver.activePartitions = 2;
@@ -1045,7 +959,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTile
HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterMultiTileTests,
givenMultipleStaticActivePartitionsAndDirectSubmissionActiveWhenFlushingTaskThenExpectTagUpdatePipeControlWithPartitionFlagOnAndNoActivePartitionConfig) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread || pDevice->isDebuggerActive()) {
if (pDevice->getPreemptionMode() == PreemptionMode::MidThread) {
commandStreamReceiver.createPreemptionAllocation();
}

View File

@@ -24,7 +24,6 @@
#include "shared/test/common/mocks/mock_direct_submission_hw.h"
#include "shared/test/common/mocks/mock_memory_manager.h"
#include "shared/test/common/mocks/mock_os_context.h"
#include "shared/test/common/mocks/mock_source_level_debugger.h"
#include "shared/test/common/mocks/mock_timestamp_container.h"
#include "shared/test/common/mocks/ult_device_factory.h"
#include "shared/test/common/test_macros/test.h"
@@ -131,25 +130,6 @@ HWTEST_F(UltCommandStreamReceiverTest, whenGetCmdSizeForPerDssBackedBufferIsCall
}
}
HWTEST_F(UltCommandStreamReceiverTest, givenSentStateSipFlagSetAndSourceLevelDebuggerIsActiveWhenGetRequiredStateSipCmdSizeIsCalledThenStateSipCmdSizeIsNotIncluded) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags();
commandStreamReceiver.isStateSipSent = true;
auto sizeWithoutSourceKernelDebugging = commandStreamReceiver.getRequiredCmdStreamSize(dispatchFlags, *pDevice);
auto debugger = new MockSourceLevelDebugger();
debugger->setActive(true);
debugger->sbaTrackingSize = 24;
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(debugger);
commandStreamReceiver.isStateSipSent = true;
auto sizeWithSourceKernelDebugging = commandStreamReceiver.getRequiredCmdStreamSize(dispatchFlags, *pDevice);
EXPECT_EQ(0u, sizeWithSourceKernelDebugging - sizeWithoutSourceKernelDebugging - PreambleHelper<FamilyType>::getKernelDebuggingCommandsSize(true) - debugger->sbaTrackingSize);
}
HWTEST_F(UltCommandStreamReceiverTest, givenPreambleSentAndThreadArbitrationPolicyChangedWhenEstimatingFlushTaskSizeThenResultDependsOnPolicyProgrammingCmdSize) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
commandStreamReceiver.isPreambleSent = true;

View File

@@ -1451,14 +1451,6 @@ TEST_F(DeviceGetCapsTest, givenUnifiedMemorySharedSystemFlagWhenDeviceIsCreatedT
EXPECT_TRUE(device->areSharedSystemAllocationsAllowed());
}
TEST_F(DeviceGetCapsTest, givenDeviceWithNullSourceLevelDebuggerWhenCapsAreInitializedThenSourceLevelDebuggerActiveIsSetToFalse) {
std::unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
const auto &caps = device->getDeviceInfo();
EXPECT_EQ(nullptr, device->getDebugger());
EXPECT_FALSE(caps.debuggerActive);
}
TEST_F(DeviceGetCapsTest, givenOcl21DeviceWhenCheckingPipesSupportThenPipesAreSupported) {
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
@@ -1587,19 +1579,6 @@ TEST(Device_UseCaps, givenOverrideSlmSizeWhenWhenInitializeDeviceThenSlmSizeInDe
EXPECT_EQ(newSlmSize, static_cast<uint32_t>(deviceInfoWithForceSlmFlag.localMemSize / KB));
}
typedef GfxCoreHelperTest DeviceCapsWithModifiedHwInfoTest;
TEST_F(DeviceCapsWithModifiedHwInfoTest, givenPlatformWithSourceLevelDebuggerNotSupportedWhenDeviceIsCreatedThenSourceLevelDebuggerActiveIsSetToFalse) {
hardwareInfo.capabilityTable.debuggerSupported = false;
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hardwareInfo));
const auto &caps = device->getDeviceInfo();
EXPECT_EQ(nullptr, device->getDebugger());
EXPECT_FALSE(caps.debuggerActive);
}
TEST_F(DeviceGetCapsTest, givenClDeviceWhenInitializingCapsThenUseGetQueueFamilyCapabilitiesMethod) {
struct ClDeviceWithCustomQueueCaps : MockClDevice {
using MockClDevice::MockClDevice;

View File

@@ -15,10 +15,6 @@ using namespace NEO;
using EhlTest = Test<DeviceFixture>;
EHLTEST_F(EhlTest, givenEhlThenDebuggerIsNotSupported) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.debuggerSupported);
}
EHLTEST_F(EhlTest, givenEhlWhenSlmSizeIsRequiredThenReturnCorrectValue) {
EXPECT_EQ(64u, pDevice->getHardwareInfo().capabilityTable.slmSize);
}

View File

@@ -16,10 +16,6 @@ using namespace NEO;
using IcllpTest = Test<ClDeviceFixture>;
ICLLPTEST_F(IcllpTest, givenIcllpThenDebuggerIsNotSupported) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.debuggerSupported);
}
ICLLPTEST_F(IcllpTest, givenIcllpWhenSlmSizeIsRequiredThenReturnCorrectValue) {
EXPECT_EQ(64u, pDevice->getHardwareInfo().capabilityTable.slmSize);
}

View File

@@ -16,10 +16,6 @@ using namespace NEO;
using LkfTest = Test<ClDeviceFixture>;
LKFTEST_F(LkfTest, givenLkfThenDebuggerIsNotSupported) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.debuggerSupported);
}
LKFTEST_F(LkfTest, givenLkfWhenSlmSizeIsRequiredThenReturnCorrectValue) {
EXPECT_EQ(64u, pDevice->getHardwareInfo().capabilityTable.slmSize);
}

View File

@@ -17,10 +17,6 @@ using namespace NEO;
typedef Test<ClDeviceFixture> BxtDeviceCaps;
BXTTEST_F(BxtDeviceCaps, GivenBxtThenDebuggerIsNotSupported) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.debuggerSupported);
}
BXTTEST_F(BxtDeviceCaps, WhenCheckingProfilingTimerResolutionThenCorrectResolutionIsReturned) {
const auto &caps = pDevice->getDeviceInfo();
EXPECT_EQ(52u, caps.outProfilingTimerResolution);

View File

@@ -16,10 +16,6 @@ using namespace NEO;
typedef Test<ClDeviceFixture> BxtDeviceCapsWindows;
BXTTEST_F(BxtDeviceCapsWindows, GivenBxtWindowsThenDebuggerIsNotSupported) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.debuggerSupported);
}
BXTTEST_F(BxtDeviceCapsWindows, GivenWhenGettingKmdNotifyPropertiesThenItIsDisabled) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.kmdNotifyProperties.enableKmdNotify);
EXPECT_EQ(0, pDevice->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds);

View File

@@ -16,10 +16,6 @@ using namespace NEO;
typedef Test<ClDeviceFixture> CflDeviceCaps;
CFLTEST_F(CflDeviceCaps, GivenCFLThenDebuggerIsNotSupported) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.debuggerSupported);
}
CFLTEST_F(CflDeviceCaps, GivenCFLWhenCheckftr64KBpagesThenTrue) {
EXPECT_TRUE(pDevice->getHardwareInfo().capabilityTable.ftr64KBpages);
}

View File

@@ -16,10 +16,6 @@ using namespace NEO;
typedef Test<ClDeviceFixture> CflDeviceCapsWindows;
CFLTEST_F(CflDeviceCapsWindows, GivenCflWindowsThenDebuggerIsNotSupported) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.debuggerSupported);
}
CFLTEST_F(CflDeviceCapsWindows, GivenWhenGettingKmdNotifyPropertiesThenItIsDisabled) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.kmdNotifyProperties.enableKmdNotify);
EXPECT_EQ(0, pDevice->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
* Copyright (C) 2018-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -39,7 +39,7 @@ GEN9TEST_F(UltCommandStreamReceiverTest, whenPreambleIsProgrammedThenStateSipCmd
commandStreamReceiver.isPreambleSent = false;
pDevice->setPreemptionMode(PreemptionMode::Disabled);
pDevice->setDebuggerActive(true);
pDevice->executionEnvironment->rootDeviceEnvironments[0]->initDebuggerL0(pDevice);
uint32_t newL3Config;
auto cmdSizePreamble = commandStreamReceiver.getRequiredCmdSizeForPreamble(*pDevice);
@@ -53,7 +53,6 @@ GEN9TEST_F(UltCommandStreamReceiverTest, whenPreambleIsProgrammedThenStateSipCmd
this->parseCommands<FamilyType>(preambleStream);
auto itorStateSip = find<STATE_SIP *>(this->cmdList.begin(), this->cmdList.end());
EXPECT_EQ(this->cmdList.end(), itorStateSip);
pDevice->setDebuggerActive(false);
}
GEN9TEST_F(CommandStreamReceiverHwTestGen9, GivenKernelWithSlmWhenPreviousNOSLML3WasSentThenProgramL3WithSLML3Config) {

View File

@@ -16,10 +16,6 @@ using namespace NEO;
using GlkDeviceCaps = Test<DeviceFixture>;
GLKTEST_F(GlkDeviceCaps, givenGlkThenDebuggerIsNotSupported) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.debuggerSupported);
}
GLKTEST_F(GlkDeviceCaps, WhenCheckingProfilingTimerResolutionThenCorrectResolutionIsReturned) {
const auto &caps = pDevice->getDeviceInfo();
EXPECT_EQ(52u, caps.outProfilingTimerResolution);

View File

@@ -16,10 +16,6 @@ using namespace NEO;
typedef Test<ClDeviceFixture> GlkDeviceCapsWindows;
GLKTEST_F(GlkDeviceCapsWindows, GivenGlkWindowsThenDebuggerIsNotSupported) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.debuggerSupported);
}
GLKTEST_F(GlkDeviceCapsWindows, WhenCheckingKmdNotifyPropertiesThenKmdNotifyIsEnabledCorrectly) {
EXPECT_TRUE(pDevice->getHardwareInfo().capabilityTable.kmdNotifyProperties.enableKmdNotify);
EXPECT_EQ(30000, pDevice->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds);

View File

@@ -14,10 +14,6 @@ using namespace NEO;
typedef Test<ClDeviceFixture> KblDeviceCaps;
KBLTEST_F(KblDeviceCaps, GivenKBLThenDebuggerIsNotSupported) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.debuggerSupported);
}
KBLTEST_F(KblDeviceCaps, GivenKBLWhenCheckftr64KBpagesThenTrue) {
EXPECT_TRUE(pDevice->getHardwareInfo().capabilityTable.ftr64KBpages);
}

View File

@@ -14,10 +14,6 @@ using namespace NEO;
typedef Test<ClDeviceFixture> KblDeviceCapsWindows;
KBLTEST_F(KblDeviceCapsWindows, givenKblWindowsThenDebuggerIsNotSupported) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.debuggerSupported);
}
KBLTEST_F(KblDeviceCapsWindows, GivenWhenGettingKmdNotifyPropertiesThenItIsDisabled) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.kmdNotifyProperties.enableKmdNotify);
EXPECT_EQ(0, pDevice->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds);

View File

@@ -17,10 +17,6 @@ using namespace NEO;
typedef Test<ClDeviceFixture> SklDeviceCaps;
SKLTEST_F(SklDeviceCaps, givenSklThenDebuggerIsNotSupported) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.debuggerSupported);
}
SKLTEST_F(SklDeviceCaps, WhenCheckingProfilingTimerResolutionThenCorrectResolutionIsReturned) {
const auto &caps = pDevice->getDeviceInfo();
EXPECT_EQ(83u, caps.outProfilingTimerResolution);

View File

@@ -16,10 +16,6 @@ using namespace NEO;
typedef Test<ClDeviceFixture> SklDeviceCapsWindows;
SKLTEST_F(SklDeviceCapsWindows, GivenSklWindowsThenDebuggerIsNotSupported) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.debuggerSupported);
}
SKLTEST_F(SklDeviceCapsWindows, GivenWhenGettingKmdNotifyPropertiesThenItIsDisabled) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.kmdNotifyProperties.enableKmdNotify);
EXPECT_EQ(0, pDevice->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds);

View File

@@ -81,12 +81,11 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, PreemptionWatermarkXeHPAndLater, givenPreambleThenP
ASSERT_EQ(nullptr, cmd);
MockDevice mockDevice;
mockDevice.setDebuggerActive(false);
size_t expectedSize = PreemptionHelper::getRequiredPreambleSize<FamilyType>(mockDevice);
EXPECT_EQ(expectedSize, PreambleHelper<FamilyType>::getAdditionalCommandsSize(mockDevice));
mockDevice.setDebuggerActive(true);
expectedSize += PreambleHelper<FamilyType>::getKernelDebuggingCommandsSize(mockDevice.isDebuggerActive());
mockDevice.executionEnvironment->rootDeviceEnvironments[0]->initDebuggerL0(&mockDevice);
expectedSize += PreambleHelper<FamilyType>::getKernelDebuggingCommandsSize(mockDevice.getDebugger() != nullptr);
EXPECT_EQ(expectedSize, PreambleHelper<FamilyType>::getAdditionalCommandsSize(mockDevice));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
* Copyright (C) 2018-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -19,36 +19,14 @@ using namespace NEO;
TEST(DebugKernelTest, givenKernelCompiledForDebuggingWhenGetPerThreadSystemThreadSurfaceSizeIsCalledThenCorrectValueIsReturned) {
auto device = std::make_unique<MockClDevice>(new MockDevice);
MockProgram program(toClDeviceVector(*device));
program.enableKernelDebug();
std::unique_ptr<MockDebugKernel> kernel(MockKernel::create<MockDebugKernel>(device->getDevice(), &program));
EXPECT_EQ(MockDebugKernel::perThreadSystemThreadSurfaceSize, kernel->getPerThreadSystemThreadSurfaceSize());
}
TEST(DebugKernelTest, givenKernelCompiledForDebuggingWhenQueryingIsKernelDebugEnabledThenTrueIsReturned) {
auto device = std::make_unique<MockClDevice>(new MockDevice);
MockProgram program(toClDeviceVector(*device));
program.enableKernelDebug();
std::unique_ptr<MockKernel> kernel(MockKernel::create<MockDebugKernel>(device->getDevice(), &program));
kernel->initialize();
EXPECT_TRUE(kernel->isKernelDebugEnabled());
}
TEST(DebugKernelTest, givenKernelWithoutDebugFlagWhenQueryingIsKernelDebugEnabledThenFalseIsReturned) {
auto device = std::make_unique<MockClDevice>(new MockDevice);
MockProgram program(toClDeviceVector(*device));
program.enableKernelDebug();
std::unique_ptr<MockKernel> kernel(MockKernel::create<MockKernel>(device->getDevice(), &program));
kernel->initialize();
EXPECT_FALSE(kernel->isKernelDebugEnabled());
}
TEST(DebugKernelTest, givenKernelWithoutDebugFlagWhenGetPerThreadSystemThreadSurfaceSizeIsCalledThenZeroIsReturned) {
auto device = std::make_unique<MockClDevice>(new MockDevice);
MockProgram program(toClDeviceVector(*device));
program.enableKernelDebug();
std::unique_ptr<MockKernel> kernel(MockKernel::create<MockKernel>(device->getDevice(), &program));
EXPECT_EQ(0u, kernel->getPerThreadSystemThreadSurfaceSize());

View File

@@ -58,7 +58,6 @@ class MockClDevice : public ClDevice {
CommandStreamReceiver &getGpgpuCommandStreamReceiver() const { return device.getGpgpuCommandStreamReceiver(); }
void resetCommandStreamReceiver(CommandStreamReceiver *newCsr) { device.resetCommandStreamReceiver(newCsr); }
void resetCommandStreamReceiver(CommandStreamReceiver *newCsr, uint32_t engineIndex) { device.resetCommandStreamReceiver(newCsr, engineIndex); }
void setSourceLevelDebuggerActive(bool active) { device.setDebuggerActive(active); }
template <typename T>
static T *createWithExecutionEnvironment(const HardwareInfo *pHwInfo, ExecutionEnvironment *executionEnvironment, uint32_t rootDeviceIndex) {
return MockDevice::createWithExecutionEnvironment<T>(pHwInfo, executionEnvironment, rootDeviceIndex);
@@ -77,10 +76,6 @@ class MockClDevice : public ClDevice {
bool areOcl21FeaturesSupported() const;
void setDebuggerActive(bool active) {
sharedDeviceInfo.debuggerActive = active;
}
MockDevice &device;
DeviceInfo &sharedDeviceInfo;
ExecutionEnvironment *&executionEnvironment;
@@ -94,7 +89,6 @@ class MockDeviceWithDebuggerActive : public MockDevice {
MockDeviceWithDebuggerActive(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex) : MockDevice(executionEnvironment, deviceIndex) {}
void initializeCaps() override {
MockDevice::initializeCaps();
this->setDebuggerActive(true);
}
};

View File

@@ -164,20 +164,6 @@ MockUnrestrictiveContext::MockUnrestrictiveContext() : MockContext(nullptr, null
initializeWithDevices(ClDeviceVector{deviceIds, 3}, true);
}
MockUnrestrictiveDebuggingSupportedContext::MockUnrestrictiveDebuggingSupportedContext() : MockContext(nullptr, nullptr) {
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo;
hwInfo.capabilityTable.debuggerSupported = true;
auto executionEnvironment = MockDevice::prepareExecutionEnvironment(&hwInfo, 0u);
ultClDeviceFactory = std::make_unique<UltClDeviceFactory>(1, 2, static_cast<ClExecutionEnvironment *>(executionEnvironment));
pRootDevice = ultClDeviceFactory->rootDevices[0];
pSubDevice0 = ultClDeviceFactory->subDevices[0];
pSubDevice1 = ultClDeviceFactory->subDevices[1];
cl_device_id deviceIds[] = {pRootDevice, pSubDevice0, pSubDevice1};
initializeWithDevices(ClDeviceVector{deviceIds, 3}, true);
}
MockUnrestrictiveContextMultiGPU::MockUnrestrictiveContextMultiGPU() : MockContext(nullptr, nullptr) {
pRootDevice0 = ultClDeviceFactory.rootDevices[0];
pSubDevice00 = ultClDeviceFactory.subDevices[0];

View File

@@ -91,15 +91,6 @@ struct MockUnrestrictiveContext : MockContext {
ClDevice *pSubDevice1 = nullptr;
};
struct MockUnrestrictiveDebuggingSupportedContext : MockContext {
MockUnrestrictiveDebuggingSupportedContext();
std::unique_ptr<UltClDeviceFactory> ultClDeviceFactory;
MockClDevice *pRootDevice;
ClDevice *pSubDevice0 = nullptr;
ClDevice *pSubDevice1 = nullptr;
};
struct MockUnrestrictiveContextMultiGPU : MockContext {
MockUnrestrictiveContextMultiGPU();

View File

@@ -23,7 +23,6 @@
MockDebugProgram::MockDebugProgram(const NEO::ClDeviceVector &deviceVector) : NEO::Program(nullptr, false, deviceVector) {
createdFrom = CreatedFrom::SOURCE;
sourceCode = "__kernel void kernel(){}";
kernelDebugEnabled = true;
prepareMockCompilerInterface(deviceVector[0]->getDevice());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 Intel Corporation
* Copyright (C) 2022-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -24,7 +24,6 @@ class MockDebugProgram : public NEO::Program {
using Base::buildInfos;
using Base::irBinary;
using Base::irBinarySize;
using Base::kernelDebugEnabled;
MockDebugProgram(const NEO::ClDeviceVector &deviceVector);

View File

@@ -63,7 +63,6 @@ class MockProgram : public Program {
using Program::isBuiltIn;
using Program::isCreatedFromBinary;
using Program::isSpirV;
using Program::kernelDebugEnabled;
using Program::linkBinary;
using Program::notifyModuleCreate;
using Program::notifyModuleDestroy;

View File

@@ -21,7 +21,6 @@
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_sip.h"
#include "shared/test/common/mocks/mock_source_level_debugger.h"
#include "opencl/source/cl_device/cl_device.h"
#include "opencl/source/sharings/sharing_factory.h"
@@ -165,43 +164,6 @@ TEST_F(PlatformTest, givenDisabledPreemptionAndNoSourceLevelDebuggerWhenInitiali
EXPECT_FALSE(MockSipData::called);
}
TEST_F(PlatformTest, givenDisabledPreemptionInactiveSourceLevelDebuggerWhenInitializingPlatformThenDoNotCallGetSipKernel) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
auto builtIns = new MockBuiltins();
auto executionEnvironment = pPlatform->peekExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(builtIns);
auto sourceLevelDebugger = new MockSourceLevelDebugger();
sourceLevelDebugger->setActive(false);
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(sourceLevelDebugger);
EXPECT_EQ(SipKernelType::COUNT, MockSipData::calledType);
EXPECT_FALSE(MockSipData::called);
pPlatform->initializeWithNewDevices();
EXPECT_EQ(SipKernelType::COUNT, MockSipData::calledType);
EXPECT_FALSE(MockSipData::called);
}
TEST_F(PlatformTest, givenDisabledPreemptionActiveSourceLevelDebuggerWhenInitializingPlatformThenCallGetSipKernel) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
auto builtIns = new MockBuiltins();
auto executionEnvironment = pPlatform->peekExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(builtIns);
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(new MockActiveSourceLevelDebugger());
EXPECT_EQ(SipKernelType::COUNT, MockSipData::calledType);
EXPECT_FALSE(MockSipData::called);
pPlatform->initializeWithNewDevices();
EXPECT_TRUE(MockSipData::called);
EXPECT_LE(SipKernelType::DbgCsr, MockSipData::calledType);
EXPECT_GE(SipKernelType::DbgCsrLocal, MockSipData::calledType);
}
TEST(PlatformTestSimple, givenCsrHwTypeWhenPlatformIsInitializedThenInitAubCenterIsNotCalled) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.SetCommandStreamReceiver.set(0);

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2018-2022 Intel Corporation
# Copyright (C) 2018-2023 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@@ -20,7 +20,6 @@ set(IGDRCL_SRCS_tests_program
${CMAKE_CURRENT_SOURCE_DIR}/program_spec_constants_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/program_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/program_tests.h
${CMAKE_CURRENT_SOURCE_DIR}/program_with_kernel_debug_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/program_with_source.h
${CMAKE_CURRENT_SOURCE_DIR}/program_with_zebin.h
${CMAKE_CURRENT_SOURCE_DIR}/program_with_zebin.cpp

View File

@@ -753,39 +753,6 @@ TEST_F(ProgramImplicitArgsTest, givenImplicitRelocationAndStackCallsThenKernelRe
program.getKernelInfoArray(rootDeviceIndex).clear();
}
HWTEST2_F(ProgramImplicitArgsTest, givenImplicitRelocationAndEnabledDebuggerThenKernelRequiresImplicitArgs, HasSourceLevelDebuggerSupport) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableMockSourceLevelDebugger.set(1);
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo;
hwInfo.capabilityTable.debuggerSupported = true;
auto executionEnvironment = MockDevice::prepareExecutionEnvironment(&hwInfo, 0u);
auto device = std::make_unique<MockClDevice>(MockDevice::createWithExecutionEnvironment<MockDevice>(&hwInfo, executionEnvironment, 0u));
EXPECT_NE(nullptr, device->getDebugger());
auto rootDeviceIndex = device->getRootDeviceIndex();
MockProgram program{nullptr, false, toClDeviceVector(*device)};
KernelInfo kernelInfo = {};
kernelInfo.kernelDescriptor.kernelMetadata.kernelName = "onlyKernel";
kernelInfo.kernelDescriptor.kernelAttributes.flags.useStackCalls = false;
uint8_t kernelHeapData[64] = {};
kernelInfo.heapInfo.pKernelHeap = kernelHeapData;
kernelInfo.heapInfo.kernelHeapSize = 64;
MockGraphicsAllocation kernelIsa(kernelHeapData, 64);
kernelInfo.kernelAllocation = &kernelIsa;
program.getKernelInfoArray(rootDeviceIndex).push_back(&kernelInfo);
auto linkerInput = std::make_unique<WhiteBox<LinkerInput>>();
linkerInput->textRelocations.push_back({{implicitArgsRelocationSymbolName, 0x8, LinkerInput::RelocationInfo::Type::AddressLow, SegmentType::Instructions}});
linkerInput->traits.requiresPatchingOfInstructionSegments = true;
program.setLinkerInput(rootDeviceIndex, std::move(linkerInput));
auto ret = program.linkBinary(&device->getDevice(), nullptr, 0, nullptr, 0, {}, program.externalFunctions);
EXPECT_EQ(CL_SUCCESS, ret);
EXPECT_TRUE(kernelInfo.kernelDescriptor.kernelAttributes.flags.requiresImplicitArgs);
program.getKernelInfoArray(rootDeviceIndex).clear();
}
TEST_F(ProgramImplicitArgsTest, givenImplicitRelocationAndNoStackCallsAndDisabledDebuggerThenKernelDoesntRequireImplicitArgs) {
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
EXPECT_EQ(nullptr, device->getDebugger());

View File

@@ -1,408 +0,0 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/compiler_interface/compiler_options.h"
#include "shared/source/device_binary_format/patchtokens_decoder.h"
#include "shared/test/common/device_binary_format/elf/elf_tests_data.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/gtest_helpers.h"
#include "shared/test/common/helpers/kernel_filename_helper.h"
#include "shared/test/common/mocks/mock_compiler_interface.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/mocks/mock_modules_zebin.h"
#include "shared/test/common/mocks/mock_source_level_debugger.h"
#include "shared/test/common/test_macros/hw_test.h"
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "opencl/test/unit_test/mocks/mock_debug_program.h"
#include "opencl/test/unit_test/mocks/mock_program.h"
#include "opencl/test/unit_test/program/program_tests.h"
#include "program_debug_data.h"
using namespace NEO;
TEST_F(ProgramTests, givenDeafultProgramObjectWhenKernelDebugEnabledIsQueriedThenFalseIsReturned) {
MockProgram program(pContext, false, toClDeviceVector(*pClDevice));
EXPECT_FALSE(program.isKernelDebugEnabled());
}
TEST_F(ProgramTests, givenProgramObjectWhenEnableKernelDebugIsCalledThenProgramHasKernelDebugEnabled) {
MockProgram program(pContext, false, toClDeviceVector(*pClDevice));
program.enableKernelDebug();
EXPECT_TRUE(program.isKernelDebugEnabled());
}
class ZebinFallbackToPatchtokensLegacyDebugger : public ProgramTests {
public:
void SetUp() override {
ProgramTests::SetUp();
device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr, mockRootDeviceIndex));
const auto &hwInfo = device->getHardwareInfo();
zebin.elfHeader->machine = hwInfo.platform.eProductFamily;
}
void TearDown() override {
ProgramTests::TearDown();
}
ZebinTestData::ValidEmptyProgram<> zebin;
std::unique_ptr<MockClDevice> device;
};
HWTEST_F(ZebinFallbackToPatchtokensLegacyDebugger, WhenCreatingProgramFromNonBuiltinZeBinaryWithSpirvDataIncludedAndLegacyDebuggerAttachedThenSuccessIsReturnedAndRebuildFromPTIsRequired) {
if (sizeof(void *) != 8U) {
GTEST_SKIP();
}
const uint8_t mockSpvData[0x10]{0};
zebin.appendSection(Zebin::Elf::SHT_ZEBIN_SPIRV, Zebin::Elf::SectionNames::spv, mockSpvData);
std::unique_ptr<MockProgram> program;
device->executionEnvironment->rootDeviceEnvironments[mockRootDeviceIndex]->debugger.reset(new MockActiveSourceLevelDebugger);
ASSERT_NE(nullptr, device->getSourceLevelDebugger());
program = std::make_unique<MockProgram>(toClDeviceVector(*device));
auto retVal = program->createProgramFromBinary(zebin.storage.data(), zebin.storage.size(), *device.get());
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_FALSE(program->isCreatedFromBinary);
EXPECT_TRUE(program->requiresRebuild);
EXPECT_FALSE(CompilerOptions::contains(program->options, CompilerOptions::enableZebin));
}
HWTEST_F(ZebinFallbackToPatchtokensLegacyDebugger, WhenCreatingProgramFromNonBuiltinZeBinaryWithoutSpirvDataIncludedAndLegacyDebuggerAttachedThenErrorIsReturned) {
if (sizeof(void *) != 8U) {
GTEST_SKIP();
}
std::unique_ptr<MockProgram> program;
device->executionEnvironment->rootDeviceEnvironments[mockRootDeviceIndex]->debugger.reset(new MockActiveSourceLevelDebugger);
ASSERT_NE(nullptr, device->getSourceLevelDebugger());
program = std::make_unique<MockProgram>(toClDeviceVector(*device));
ASSERT_EQ(0u, program->irBinarySize);
auto retVal = program->createProgramFromBinary(zebin.storage.data(), zebin.storage.size(), *device.get());
EXPECT_EQ(CL_INVALID_BINARY, retVal);
}
class ProgramWithKernelDebuggingFixture {
public:
void setUp() {
pDevice = static_cast<MockDevice *>(&mockContext.getDevice(0)->getDevice());
std::string filename;
std::string kernelOption(CompilerOptions::debugKernelEnable);
KernelFilenameHelper::getKernelFilenameFromInternalOption(kernelOption, filename);
program = std::make_unique<MockDebugProgram>(mockContext.getDevices());
}
void tearDown() {}
MockUnrestrictiveDebuggingSupportedContext mockContext;
std::unique_ptr<MockDebugProgram> program = nullptr;
MockDevice *pDevice = nullptr;
};
using ProgramWithKernelDebuggingTest = Test<ProgramWithKernelDebuggingFixture>;
HWTEST2_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsCompiledThenInternalOptionsIncludeDebugFlag, HasSourceLevelDebuggerSupport) {
cl_int retVal = program->compile(program->getDevices(), nullptr,
0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(CompilerOptions::contains(program->compilerInterface->buildInternalOptions, CompilerOptions::debugKernelEnable));
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsCompiledThenInternalOptionsIncludeDashGFlag, HasSourceLevelDebuggerSupport) {
cl_int retVal = program->compile(program->getDevices(), nullptr,
0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(hasSubstr(program->getOptions(), "-g"));
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugAndOptDisabledWhenProgramIsCompiledThenOptionsIncludeClOptDisableFlag, HasSourceLevelDebuggerSupport) {
MockActiveSourceLevelDebugger *sourceLevelDebugger = new MockActiveSourceLevelDebugger;
sourceLevelDebugger->isOptDisabled = true;
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
cl_int retVal = program->compile(program->getDevices(), nullptr,
0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(hasSubstr(program->getOptions(), CompilerOptions::optDisable.data()));
}
HWTEST2_F(ProgramWithKernelDebuggingTest, GivenDebugVarDebuggerOptDisableZeroWhenOptDisableIsTrueFromDebuggerThenOptDisableIsNotAdded, HasSourceLevelDebuggerSupport) {
DebugManagerStateRestore dgbRestorer;
NEO::DebugManager.flags.DebuggerOptDisable.set(0);
MockActiveSourceLevelDebugger *sourceLevelDebugger = new MockActiveSourceLevelDebugger;
sourceLevelDebugger->isOptDisabled = true;
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
cl_int retVal = program->compile(program->getDevices(), nullptr,
0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_FALSE(hasSubstr(program->getOptions(), CompilerOptions::optDisable.data()));
}
HWTEST2_F(ProgramWithKernelDebuggingTest, GivenDebugVarDebuggerOptDisableOneWhenOptDisableIsFalseFromDebuggerThenOptDisableIsAdded, HasSourceLevelDebuggerSupport) {
DebugManagerStateRestore dgbRestorer;
NEO::DebugManager.flags.DebuggerOptDisable.set(1);
MockActiveSourceLevelDebugger *sourceLevelDebugger = new MockActiveSourceLevelDebugger;
sourceLevelDebugger->isOptDisabled = false;
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
cl_int retVal = program->compile(program->getDevices(), nullptr,
0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(hasSubstr(program->getOptions(), CompilerOptions::optDisable.data()));
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsCompiledThenOptionsStartsWithDashSFilename, HasSourceLevelDebuggerSupport) {
MockActiveSourceLevelDebugger *sourceLevelDebugger = new MockActiveSourceLevelDebugger;
sourceLevelDebugger->sourceCodeFilename = "debugFileName";
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
cl_int retVal = program->compile(program->getDevices(), nullptr,
0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(startsWith(program->getOptions(), "-s \"debugFileName\""));
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsCompiledWithCmCOptionThenDashSFilenameIsNotPrepended, HasSourceLevelDebuggerSupport) {
MockActiveSourceLevelDebugger *sourceLevelDebugger = new MockActiveSourceLevelDebugger;
sourceLevelDebugger->sourceCodeFilename = "debugFileName";
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
char options[] = "-cmc -cl-opt-disable";
cl_int retVal = program->compile(program->getDevices(), options,
0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_FALSE(startsWith(program->getOptions(), "-s debugFileName"));
EXPECT_TRUE(hasSubstr(program->getOptions(), CompilerOptions::optDisable.data()));
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsBuiltThenInternalOptionsIncludeDebugFlag, HasSourceLevelDebuggerSupport) {
cl_int retVal = program->build(program->getDevices(), nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(CompilerOptions::contains(program->compilerInterface->buildInternalOptions, CompilerOptions::debugKernelEnable));
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsBuiltThenOptionsIncludeDashGFlag, HasSourceLevelDebuggerSupport) {
cl_int retVal = program->build(program->getDevices(), nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(hasSubstr(program->getOptions(), "-g"));
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugAndOptDisabledWhenProgramIsBuiltThenOptionsIncludeClOptDisableFlag, HasSourceLevelDebuggerSupport) {
MockActiveSourceLevelDebugger *sourceLevelDebugger = new MockActiveSourceLevelDebugger;
sourceLevelDebugger->isOptDisabled = true;
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
cl_int retVal = program->build(program->getDevices(), nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(hasSubstr(program->getOptions(), CompilerOptions::optDisable.data()));
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsBuiltThenOptionsStartsWithDashSFilename, HasSourceLevelDebuggerSupport) {
MockActiveSourceLevelDebugger *sourceLevelDebugger = new MockActiveSourceLevelDebugger;
sourceLevelDebugger->sourceCodeFilename = "debugFileName";
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
cl_int retVal = program->build(program->getDevices(), nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(startsWith(program->getOptions(), "-s \"debugFileName\""));
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsBuiltWithCmCOptionThenDashSFilenameIsNotPrepended, HasSourceLevelDebuggerSupport) {
MockActiveSourceLevelDebugger *sourceLevelDebugger = new MockActiveSourceLevelDebugger;
sourceLevelDebugger->sourceCodeFilename = "debugFileName";
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
char options[] = "-cmc -cl-opt-disable";
cl_int retVal = program->build(program->getDevices(), options);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_FALSE(startsWith(program->getOptions(), "-s debugFileName"));
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsLinkedThenKernelDebugOptionsAreAppended, HasSourceLevelDebuggerSupport) {
MockActiveSourceLevelDebugger *sourceLevelDebugger = new MockActiveSourceLevelDebugger;
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
program->compilerInterface->output.debugData.size = 0;
program->compilerInterface->output.debugData.mem = nullptr;
cl_int retVal = program->compile(program->getDevices(), nullptr, 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
cl_program clProgramToLink = program.get();
auto &devices = program->getDevices();
auto newProgram = std::unique_ptr<MockProgramAppendKernelDebugOptions>(new MockProgramAppendKernelDebugOptions(&mockContext, false, mockContext.getDevices()));
newProgram->enableKernelDebug();
retVal = newProgram->link(devices, nullptr, 1, &clProgramToLink);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(static_cast<unsigned int>(mockContext.getRootDeviceIndices().size()), newProgram->appendKernelDebugOptionsCalled);
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsBuiltThenDebuggerIsNotifiedWithKernelDebugData, HasSourceLevelDebuggerSupport) {
const size_t rootDeviceIndicesSize = mockContext.getRootDeviceIndices().size();
std::vector<MockSourceLevelDebugger *> sourceLevelDebugger(rootDeviceIndicesSize, nullptr);
size_t i = 0;
for (auto &rootDeviceIndex : mockContext.getRootDeviceIndices()) {
sourceLevelDebugger[i] = new MockSourceLevelDebugger(nullptr);
sourceLevelDebugger[i]->setActive(true);
pDevice->executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->debugger.reset(sourceLevelDebugger[i]);
i++;
}
cl_int retVal = program->build(program->getDevices(), nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
for (auto &el : sourceLevelDebugger) {
EXPECT_EQ(1u, el->isOptimizationDisabledCalled);
EXPECT_EQ(false, el->isOptimizationDisabledResult);
EXPECT_EQ(1u, el->notifySourceCodeCalled);
EXPECT_EQ(false, el->notifySourceCodeResult);
EXPECT_EQ(1u, el->notifyKernelDebugDataCalled);
}
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsLinkedThenDebuggerIsNotifiedWithKernelDebugData, HasSourceLevelDebuggerSupport) {
const size_t rootDeviceIndicesSize = mockContext.getRootDeviceIndices().size();
std::vector<MockSourceLevelDebugger *> sourceLevelDebugger(rootDeviceIndicesSize, nullptr);
size_t i = 0;
for (auto &rootDeviceIndex : mockContext.getRootDeviceIndices()) {
sourceLevelDebugger[i] = new MockSourceLevelDebugger(nullptr);
sourceLevelDebugger[i]->setActive(true);
pDevice->executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->debugger.reset(sourceLevelDebugger[i]);
i++;
}
cl_int retVal = program->compile(program->getDevices(), nullptr,
0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
cl_program clprogram = program.get();
retVal = program->link(program->getDevices(), nullptr,
1, &clprogram);
EXPECT_EQ(CL_SUCCESS, retVal);
for (auto &el : sourceLevelDebugger) {
EXPECT_EQ(2u, el->isOptimizationDisabledCalled);
EXPECT_EQ(false, el->isOptimizationDisabledResult);
EXPECT_EQ(1u, el->notifySourceCodeCalled);
EXPECT_EQ(false, el->notifySourceCodeResult);
EXPECT_EQ(1u, el->notifyKernelDebugDataCalled);
}
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenGtpinInitializedWhenCreatingProgramFromBinaryThenDebugDataIsAvailable, HasSourceLevelDebuggerSupport) {
bool gtpinInitializedBackup = NEO::isGTPinInitialized;
NEO::isGTPinInitialized = true;
auto retVal = program->build(program->getDevices(), CompilerOptions::debugKernelEnable.data());
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(program->wasDebuggerNotified);
NEO::isGTPinInitialized = gtpinInitializedBackup;
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenGtpinNotInitializedWhenCreatingProgramFromBinaryThenDebugDataINullptr, HasSourceLevelDebuggerSupport) {
bool gtpinInitializedBackup = NEO::isGTPinInitialized;
NEO::isGTPinInitialized = false;
program->kernelDebugEnabled = false;
auto retVal = program->build(program->getDevices(), CompilerOptions::debugKernelEnable.data());
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_FALSE(program->wasDebuggerNotified);
NEO::isGTPinInitialized = gtpinInitializedBackup;
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenKernelDebugEnabledWhenProgramIsBuiltThenDebugDataIsStored, HasSourceLevelDebuggerSupport) {
auto retVal = program->build(program->getDevices(), nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
auto debugData = program->getDebugData(pDevice->getRootDeviceIndex());
EXPECT_NE(nullptr, debugData);
EXPECT_NE(0u, program->getDebugDataSize(pDevice->getRootDeviceIndex()));
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenProgramWithKernelDebugEnabledWhenProcessDebugDataIsCalledThenKernelInfosAreFilledWithDebugData, HasSourceLevelDebuggerSupport) {
iOpenCL::SProgramDebugDataHeaderIGC debugDataHeader{};
debugDataHeader.NumberOfKernels = 1u;
char mockKernelName[] = "CopyBuffer";
constexpr size_t mockKernelDebugDataSize = 0x10;
PatchTokenBinary::SKernelDebugDataHeaderIGC mockKernelDebugHeader{};
mockKernelDebugHeader.KernelNameSize = sizeof(mockKernelName);
mockKernelDebugHeader.SizeVisaDbgInBytes = mockKernelDebugDataSize;
char mockKerneDebugData[mockKernelDebugDataSize];
memset(mockKerneDebugData, '\x01', mockKernelDebugDataSize);
KernelInfo *mockKernelInfo = new KernelInfo{};
mockKernelInfo->kernelDescriptor.kernelMetadata.kernelName = "CopyBuffer";
program->addKernelInfo(mockKernelInfo, pDevice->getRootDeviceIndex());
constexpr size_t mockDebugDataSize = sizeof(iOpenCL::SProgramDebugDataHeaderIGC) + sizeof(PatchTokenBinary::KernelFromPatchtokens) + sizeof(mockKernelName) + mockKernelDebugDataSize;
char *mockDebugData = new char[mockDebugDataSize];
auto dataPtr = mockDebugData;
memcpy_s(dataPtr, mockDebugDataSize, &debugDataHeader, sizeof(iOpenCL::SProgramDebugDataHeaderIGC));
dataPtr = ptrOffset(dataPtr, sizeof(iOpenCL::SProgramDebugDataHeaderIGC));
memcpy_s(dataPtr, mockDebugDataSize, &mockKernelDebugHeader, sizeof(PatchTokenBinary::SKernelDebugDataHeaderIGC));
dataPtr = ptrOffset(dataPtr, sizeof(PatchTokenBinary::SKernelDebugDataHeaderIGC));
memcpy_s(dataPtr, mockDebugDataSize, &mockKernelName, sizeof(mockKernelName));
dataPtr = ptrOffset(dataPtr, sizeof(mockKernelName));
memcpy_s(dataPtr, mockDebugDataSize, mockKerneDebugData, mockKernelDebugDataSize);
program->buildInfos[pDevice->getRootDeviceIndex()].debugData.reset(mockDebugData);
program->processDebugData(pDevice->getRootDeviceIndex());
auto receivedKernelInfo = program->getKernelInfo("CopyBuffer", pDevice->getRootDeviceIndex());
EXPECT_NE(0u, receivedKernelInfo->debugData.vIsaSize);
EXPECT_NE(nullptr, receivedKernelInfo->debugData.vIsa);
}
HWTEST2_F(ProgramWithKernelDebuggingTest, givenProgramWithNonZebinaryFormatAndKernelDebugEnabledWhenProgramIsBuiltThenProcessDebugDataIsCalledAndDebuggerNotified, HasSourceLevelDebuggerSupport) {
MockSourceLevelDebugger *sourceLevelDebugger = new MockSourceLevelDebugger;
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
program->enableKernelDebug();
auto mockElf = std::make_unique<MockElfBinaryPatchtokens<>>(pDevice->getHardwareInfo());
auto mockElfSize = mockElf->storage.size();
auto mockElfData = mockElf->storage.data();
program->buildInfos[pDevice->getRootDeviceIndex()].unpackedDeviceBinarySize = mockElfSize;
program->buildInfos[pDevice->getRootDeviceIndex()].unpackedDeviceBinary.reset(new char[mockElfSize]);
memcpy_s(program->buildInfos[pDevice->getRootDeviceIndex()].unpackedDeviceBinary.get(), program->buildInfos[pDevice->getRootDeviceIndex()].unpackedDeviceBinarySize,
mockElfData, mockElfSize);
KernelInfo *mockKernelInfo = new KernelInfo{};
mockKernelInfo->kernelDescriptor.kernelMetadata.kernelName = "CopyBuffer";
program->addKernelInfo(mockKernelInfo, pDevice->getRootDeviceIndex());
auto counter = 0u;
for (const auto &device : program->getDevices()) {
program->notifyDebuggerWithDebugData(device);
EXPECT_FALSE(program->wasCreateDebugZebinCalled);
EXPECT_TRUE(program->wasProcessDebugDataCalled);
EXPECT_EQ(++counter, sourceLevelDebugger->notifyKernelDebugDataCalled);
}
}

View File

@@ -7,7 +7,6 @@
#include "shared/source/device_binary_format/zebin/debug_zebin.h"
#include "shared/test/common/mocks/mock_modules_zebin.h"
#include "shared/test/common/mocks/mock_source_level_debugger.h"
#include "shared/test/common/test_macros/test.h"
#include "opencl/test/unit_test/mocks/mock_buffer.h"
@@ -118,41 +117,3 @@ TEST_F(ProgramWithZebinFixture, givenEmptyDebugDataAndZebinBinaryFormatThenCreat
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(numDevices * sizeof(debugData), retData);
}
TEST_F(ProgramWithZebinFixture, givenZebinFormatAndDebuggerNotAvailableWhenNotifyingDebuggerThenCreateDebugZebinIsCalled) {
pClDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(nullptr);
addEmptyZebin(program.get());
populateProgramWithSegments(program.get());
auto &buildInfo = program->buildInfos[rootDeviceIndex];
buildInfo.debugDataSize = 0u;
buildInfo.debugData.reset(nullptr);
for (auto &device : program->getDevices()) {
program->notifyDebuggerWithDebugData(device);
}
EXPECT_TRUE(program->wasCreateDebugZebinCalled);
EXPECT_FALSE(program->wasProcessDebugDataCalled);
EXPECT_NE(nullptr, program->buildInfos[rootDeviceIndex].debugData);
EXPECT_GT(program->buildInfos[rootDeviceIndex].debugDataSize, 0u);
}
TEST_F(ProgramWithZebinFixture, givenZebinFormatAndDebuggerAvailableWhenNotifyingDebuggerThenCreateDebugZebinIsCalledAndDebuggerNotified) {
MockSourceLevelDebugger *sourceLevelDebugger = new MockSourceLevelDebugger;
sourceLevelDebugger->setActive(true);
pClDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(sourceLevelDebugger);
addEmptyZebin(program.get());
populateProgramWithSegments(program.get());
auto &buildInfo = program->buildInfos[rootDeviceIndex];
buildInfo.debugDataSize = 0u;
buildInfo.debugData.reset(nullptr);
for (auto &device : program->getDevices()) {
program->notifyDebuggerWithDebugData(device);
}
EXPECT_TRUE(program->wasCreateDebugZebinCalled);
EXPECT_FALSE(program->wasProcessDebugDataCalled);
EXPECT_NE(nullptr, program->buildInfos[rootDeviceIndex].debugData);
EXPECT_GT(program->buildInfos[rootDeviceIndex].debugDataSize, 0u);
EXPECT_EQ(1u, sourceLevelDebugger->notifyKernelDebugDataCalled);
}

View File

@@ -1,18 +0,0 @@
#
# Copyright (C) 2018-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(IGDRCL_SRCS_tests_source_level_debugger
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/source_level_debugger_device_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source_level_debugger_csr_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source_level_debugger_csr_tests.h
${CMAKE_CURRENT_SOURCE_DIR}/source_level_debugger_tests.cpp
)
get_property(NEO_CORE_TESTS_SOURCE_LEVEL_DEBUGGER GLOBAL PROPERTY NEO_CORE_TESTS_SOURCE_LEVEL_DEBUGGER)
list(APPEND IGDRCL_SRCS_tests_source_level_debugger ${NEO_CORE_TESTS_SOURCE_LEVEL_DEBUGGER})
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_source_level_debugger})

View File

@@ -1,179 +0,0 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "opencl/test/unit_test/source_level_debugger/source_level_debugger_csr_tests.h"
#include "shared/source/source_level_debugger/source_level_debugger.h"
#include "shared/test/common/cmd_parse/hw_parse.h"
#include "shared/test/common/helpers/dispatch_flags_helper.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/mocks/mock_os_library.h"
#include "shared/test/common/test_macros/hw_test.h"
#include "opencl/source/command_queue/command_queue_hw.h"
#include <memory>
HWTEST_F(CommandStreamReceiverWithActiveDebuggerTest, givenCsrWithActiveDebuggerAndDisabledPreemptionWhenFlushTaskIsCalledThenSipKernelIsMadeResident) {
auto mockCsr = createCSR<FamilyType>();
auto sipType = SipKernel::getSipKernelType(device->getDevice());
SipKernel::initSipKernel(sipType, device->getDevice());
CommandQueueHw<FamilyType> commandQueue(nullptr, device.get(), 0, false);
auto &commandStream = commandQueue.getCS(4096u);
DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags();
void *buffer = alignedMalloc(MemoryConstants::pageSize, MemoryConstants::pageSize64k);
std::unique_ptr<MockGraphicsAllocation> allocation(new MockGraphicsAllocation(buffer, MemoryConstants::pageSize));
std::unique_ptr<IndirectHeap> heap(new IndirectHeap(allocation.get()));
auto &baseDevice = device->getDevice();
mockCsr->flushTask(commandStream,
0,
heap.get(),
heap.get(),
heap.get(),
0,
dispatchFlags,
baseDevice);
auto sipAllocation = SipKernel::getSipKernel(baseDevice, nullptr).getSipAllocation();
bool found = false;
for (auto allocation : mockCsr->copyOfAllocations) {
if (allocation == sipAllocation) {
found = true;
break;
}
}
EXPECT_TRUE(found);
alignedFree(buffer);
}
HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverWithActiveDebuggerTest, givenCsrWithActiveDebuggerAndDisabledPreemptionWhenFlushTaskIsCalledThenStateSipCmdIsProgrammed) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
using STATE_SIP = typename FamilyType::STATE_SIP;
auto mockCsr = createCSR<FamilyType>();
if (device->getHardwareInfo().capabilityTable.defaultPreemptionMode == PreemptionMode::MidThread) {
CommandQueueHw<FamilyType> commandQueue(nullptr, device.get(), 0, false);
auto &commandStream = commandQueue.getCS(4096u);
auto &preambleStream = mockCsr->getCS(0);
DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags();
void *buffer = alignedMalloc(MemoryConstants::pageSize, MemoryConstants::pageSize64k);
std::unique_ptr<MockGraphicsAllocation> allocation(new MockGraphicsAllocation(buffer, MemoryConstants::pageSize));
std::unique_ptr<IndirectHeap> heap(new IndirectHeap(allocation.get()));
auto &baseDevice = device->getDevice();
mockCsr->flushTask(commandStream,
0,
heap.get(),
heap.get(),
heap.get(),
0,
dispatchFlags,
baseDevice);
auto sipAllocation = SipKernel::getSipKernel(baseDevice, nullptr).getSipAllocation();
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(preambleStream);
auto itorStateBaseAddr = find<STATE_BASE_ADDRESS *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
auto itorStateSip = find<STATE_SIP *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
ASSERT_NE(hwParser.cmdList.end(), itorStateBaseAddr);
ASSERT_NE(hwParser.cmdList.end(), itorStateSip);
STATE_BASE_ADDRESS *sba = (STATE_BASE_ADDRESS *)*itorStateBaseAddr;
STATE_SIP *stateSipCmd = (STATE_SIP *)*itorStateSip;
EXPECT_LT(reinterpret_cast<void *>(sba), reinterpret_cast<void *>(stateSipCmd));
auto sipAddress = stateSipCmd->getSystemInstructionPointer();
EXPECT_EQ(sipAllocation->getGpuAddressToPatch(), sipAddress);
alignedFree(buffer);
}
}
HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverWithActiveDebuggerTest, givenCsrWithActiveDebuggerAndWhenFlushTaskIsCalledThenAlwaysProgramStateBaseAddressAndSip) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
using STATE_SIP = typename FamilyType::STATE_SIP;
auto mockCsr = createCSR<FamilyType>();
if (device->getHardwareInfo().capabilityTable.defaultPreemptionMode == PreemptionMode::MidThread) {
mockCsr->overrideDispatchPolicy(DispatchMode::ImmediateDispatch);
CommandQueueHw<FamilyType> commandQueue(nullptr, device.get(), 0, false);
auto &commandStream = commandQueue.getCS(4096u);
auto &preambleStream = mockCsr->getCS(0);
DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags();
void *buffer = alignedMalloc(MemoryConstants::pageSize, MemoryConstants::pageSize64k);
std::unique_ptr<MockGraphicsAllocation> allocation(new MockGraphicsAllocation(buffer, MemoryConstants::pageSize));
std::unique_ptr<IndirectHeap> heap(new IndirectHeap(allocation.get()));
auto &baseDevice = device->getDevice();
mockCsr->flushTask(commandStream,
0,
heap.get(),
heap.get(),
heap.get(),
0,
dispatchFlags,
baseDevice);
mockCsr->flushBatchedSubmissions();
mockCsr->flushTask(commandStream,
0,
heap.get(),
heap.get(),
heap.get(),
0,
dispatchFlags,
baseDevice);
auto sipAllocation = SipKernel::getSipKernel(baseDevice, nullptr).getSipAllocation();
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(preambleStream);
auto itorStateBaseAddr = find<STATE_BASE_ADDRESS *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
auto itorStateSip = find<STATE_SIP *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
ASSERT_NE(hwParser.cmdList.end(), itorStateBaseAddr);
ASSERT_NE(hwParser.cmdList.end(), itorStateSip);
STATE_BASE_ADDRESS *sba = reinterpret_cast<STATE_BASE_ADDRESS *>(*itorStateBaseAddr);
STATE_SIP *stateSipCmd = reinterpret_cast<STATE_SIP *>(*itorStateSip);
EXPECT_LT(reinterpret_cast<void *>(sba), reinterpret_cast<void *>(stateSipCmd));
auto sipAddress = stateSipCmd->getSystemInstructionPointer();
EXPECT_EQ(sipAllocation->getGpuAddressToPatch(), sipAddress);
auto itorStateBaseAddr2 = find<STATE_BASE_ADDRESS *>(std::next(itorStateBaseAddr), hwParser.cmdList.end());
auto itorStateSip2 = find<STATE_SIP *>(std::next(itorStateSip), hwParser.cmdList.end());
ASSERT_NE(hwParser.cmdList.end(), itorStateBaseAddr2);
EXPECT_EQ(hwParser.cmdList.end(), itorStateSip2);
alignedFree(buffer);
}
}

View File

@@ -1,53 +0,0 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/test/common/helpers/execution_environment_helper.h"
#include "shared/test/common/mocks/mock_builtins.h"
#include "shared/test/common/mocks/mock_csr.h"
#include "shared/test/common/mocks/mock_memory_manager.h"
#include "shared/test/common/mocks/mock_os_library.h"
#include "shared/test/common/mocks/mock_sip.h"
#include "shared/test/common/mocks/mock_source_level_debugger.h"
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
#include "gtest/gtest.h"
#include <memory>
class CommandStreamReceiverWithActiveDebuggerTest : public ::testing::Test {
protected:
template <typename FamilyType>
auto createCSR() {
hwInfo = nullptr;
EnvironmentWithCsrWrapper environment;
environment.setCsrType<MockCsrHw2<FamilyType>>();
executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1);
hwInfo->capabilityTable = defaultHwInfo->capabilityTable;
hwInfo->capabilityTable.debuggerSupported = true;
auto mockMemoryManager = new MockMemoryManager(*executionEnvironment);
executionEnvironment->memoryManager.reset(mockMemoryManager);
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(new MockActiveSourceLevelDebugger(new MockOsLibrary));
device = std::make_unique<MockClDevice>(Device::create<MockDevice>(executionEnvironment, 0));
device->setSourceLevelDebuggerActive(true);
return static_cast<MockCsrHw2<FamilyType> *>(device->getDefaultEngine().commandStreamReceiver);
}
void TearDown() override {
device->setSourceLevelDebuggerActive(false);
}
std::unique_ptr<MockClDevice> device;
ExecutionEnvironment *executionEnvironment = nullptr;
HardwareInfo *hwInfo = nullptr;
};

View File

@@ -1,39 +0,0 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/source_level_debugger/source_level_debugger.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_os_library.h"
#include "shared/test/common/mocks/mock_source_level_debugger.h"
#include "shared/test/common/test_macros/test.h"
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
#include "opencl/test/unit_test/mocks/mock_platform.h"
using PreambleTest = ::testing::Test;
using namespace NEO;
TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsDestructedThenSourceLevelDebuggerIsNotified) {
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
auto mock = new MockSourceLevelDebugger(new MockOsLibrary);
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(mock);
{
auto device = std::make_unique<MockClDevice>(MockDevice::create<MockDeviceWithDebuggerActive>(executionEnvironment, 0u));
EXPECT_EQ(0u, mock->notifyDeviceDestructionCalled);
}
EXPECT_EQ(1u, mock->notifyDeviceDestructionCalled);
}
TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsCreatedThenPreemptionIsDisabled) {
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(new MockActiveSourceLevelDebugger(new MockOsLibrary));
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDeviceWithDebuggerActive>(executionEnvironment, 0u));
EXPECT_EQ(PreemptionMode::Disabled, device->getPreemptionMode());
}

View File

@@ -1,901 +0,0 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_container/cmdcontainer.h"
#include "shared/source/device/device.h"
#include "shared/source/helpers/file_io.h"
#include "shared/source/indirect_heap/heap_size.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/program/kernel_info.h"
#include "shared/source/source_level_debugger/source_level_debugger.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/debugger_library_restore.h"
#include "shared/test/common/helpers/execution_environment_helper.h"
#include "shared/test/common/helpers/ult_hw_config.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_gmm_helper.h"
#include "shared/test/common/mocks/mock_source_level_debugger.h"
#include "shared/test/common/test_macros/hw_test.h"
#include "opencl/source/platform/platform.h"
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
#include "opencl/test/unit_test/mocks/mock_platform.h"
#include <memory>
#include <string>
using namespace NEO;
using std::string;
using std::unique_ptr;
class SourceLevelDebuggerSupportedFixture : public ::testing::Test {
public:
void SetUp() override {
hwInfo.capabilityTable.debuggerSupported = true;
}
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo;
};
TEST(SourceLevelDebugger, whenSourceLevelDebuggerIsCreatedThenLegacyModeIsTrue) {
DebuggerLibraryRestore restore;
DebuggerLibrary::setLibraryAvailable(true);
MockSourceLevelDebugger debugger;
EXPECT_TRUE(debugger.isLegacy());
}
HWTEST2_F(SourceLevelDebuggerSupportedFixture, givenPlatformWhenItIsCreatedThenSourceLevelDebuggerIsCreatedInExecutionEnvironment, HasSourceLevelDebuggerSupport) {
DebuggerLibraryRestore restore;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
auto executionEnvironment = MockDevice::prepareExecutionEnvironment(&hwInfo, 0u);
MockPlatform platform(*executionEnvironment);
platform.initializeWithNewDevices();
EXPECT_NE(nullptr, executionEnvironment->rootDeviceEnvironments[0]->debugger);
}
HWTEST2_F(SourceLevelDebuggerSupportedFixture, givenPlatformWhenSourceLevelDebuggerIsCreatedThenRuntimeCapabilityHasFusedEusDisabled, HasSourceLevelDebuggerSupport) {
DebuggerLibraryRestore restore;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
auto executionEnvironment = MockDevice::prepareExecutionEnvironment(&hwInfo, 0u);
MockPlatform platform(*executionEnvironment);
platform.initializeWithNewDevices();
ASSERT_NE(nullptr, executionEnvironment->rootDeviceEnvironments[0]->debugger);
EXPECT_FALSE(executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->capabilityTable.fusedEuEnabled);
}
HWTEST2_F(SourceLevelDebuggerSupportedFixture, givenPlatformWhenInitializingSourceLevelDebuggerFailsThenRuntimeCapabilityFusedEusAreNotModified, HasSourceLevelDebuggerSupport) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
interceptor.initRetVal = -1;
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
auto executionEnvironment = MockDevice::prepareExecutionEnvironment(&hwInfo, 0u);
MockPlatform platform(*executionEnvironment);
platform.initializeWithNewDevices();
bool defaultValue = hwInfo.capabilityTable.fusedEuEnabled;
ASSERT_NE(nullptr, executionEnvironment->rootDeviceEnvironments[0]->debugger);
EXPECT_EQ(defaultValue, executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->capabilityTable.fusedEuEnabled);
}
TEST(SourceLevelDebugger, givenNoKernelDebuggerLibraryWhenSourceLevelDebuggerIsCreatedThenLibraryIsNotLoaded) {
DebuggerLibraryRestore restore;
DebuggerLibrary::setLibraryAvailable(false);
MockSourceLevelDebugger debugger;
EXPECT_EQ(nullptr, debugger.debuggerLibrary.get());
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryAvailableWhenSourceLevelDebuggerIsConstructedThenLibraryIsLoaded) {
DebuggerLibraryRestore restore;
DebuggerLibrary::setLibraryAvailable(true);
MockSourceLevelDebugger debugger;
EXPECT_NE(nullptr, debugger.debuggerLibrary.get());
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryAvailableWhenIsDebuggerActiveIsCalledThenFalseIsReturned) {
DebuggerLibraryRestore restore;
DebuggerLibrary::setLibraryAvailable(true);
MockSourceLevelDebugger debugger;
bool active = debugger.isDebuggerActive();
EXPECT_FALSE(active);
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenIsDebuggerActiveIsCalledThenTrueIsReturned) {
DebuggerLibraryRestore restore;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
MockSourceLevelDebugger debugger;
bool active = debugger.isDebuggerActive();
EXPECT_TRUE(active);
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryNotAvailableWhenIsDebuggerActiveIsCalledThenFalseIsReturned) {
DebuggerLibraryRestore restore;
DebuggerLibrary::setLibraryAvailable(false);
MockSourceLevelDebugger debugger;
bool active = debugger.isDebuggerActive();
EXPECT_FALSE(active);
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenNotifySourceCodeIsCalledThenDebuggerLibraryFunctionIsCalled) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
GfxDbgSourceCode argOut;
char fileName[] = "filename";
argOut.sourceName = fileName;
argOut.sourceNameMaxLen = sizeof(fileName);
interceptor.sourceCodeArgOut = &argOut;
const char source[] = "sourceCode";
string file;
debugger.callBaseNotifySourceCode = true;
debugger.notifySourceCode(source, sizeof(source), file);
EXPECT_TRUE(interceptor.sourceCodeCalled);
EXPECT_EQ(reinterpret_cast<GfxDeviceHandle>(static_cast<uint64_t>(MockSourceLevelDebugger::mockDeviceHandle)), interceptor.sourceCodeArgIn.hDevice);
EXPECT_EQ(source, interceptor.sourceCodeArgIn.sourceCode);
EXPECT_EQ(sizeof(source), interceptor.sourceCodeArgIn.sourceCodeSize);
EXPECT_NE(nullptr, interceptor.sourceCodeArgIn.sourceName);
EXPECT_NE(0u, interceptor.sourceCodeArgIn.sourceNameMaxLen);
EXPECT_STREQ(fileName, file.c_str());
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryNotActiveWhenNotifySourceCodeIsCalledThenDebuggerLibraryFunctionIsNotCalled) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(false);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
debugger.setActive(false);
const char source[] = "sourceCode";
string file;
debugger.callBaseNotifySourceCode = true;
debugger.notifySourceCode(source, sizeof(source), file);
EXPECT_FALSE(interceptor.sourceCodeCalled);
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenNotifyNewDeviceIsCalledThenDebuggerLibraryFunctionIsCalled) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
debugger.callBaseNotifyNewDevice = true;
debugger.notifyNewDevice(4);
EXPECT_TRUE(interceptor.newDeviceCalled);
EXPECT_EQ(reinterpret_cast<GfxDeviceHandle>(static_cast<uint64_t>(4u)), interceptor.newDeviceArgIn.dh);
EXPECT_EQ(4u, debugger.deviceHandle);
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryNotActiveWhenNotifyNewDeviceIsCalledThenDebuggerLibraryFunctionIsNotCalled) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(false);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
debugger.callBaseNotifyNewDevice = true;
debugger.setActive(false);
debugger.notifyNewDevice(4);
EXPECT_FALSE(interceptor.newDeviceCalled);
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenIsOptimizationDisabledIsCalledThenDebuggerLibraryFunctionIsCalled) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
debugger.callBaseIsOptimizationDisabled = true;
bool isOptDisabled = debugger.isOptimizationDisabled();
EXPECT_FALSE(isOptDisabled);
EXPECT_TRUE(interceptor.optionCalled);
EXPECT_EQ(GfxDbgOptionNames::DBG_OPTION_IS_OPTIMIZATION_DISABLED, interceptor.optionArgIn.optionName);
EXPECT_NE(nullptr, interceptor.optionArgIn.value);
EXPECT_LT(0u, interceptor.optionArgIn.valueLen);
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryNotActiveWhenIsOptimizationDisabledIsCalledThenDebuggerLibraryFunctionIsNotCalled) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
debugger.setActive(false);
debugger.callBaseIsOptimizationDisabled = true;
bool isOptDisabled = debugger.isOptimizationDisabled();
EXPECT_FALSE(isOptDisabled);
EXPECT_FALSE(interceptor.optionCalled);
}
TEST(SourceLevelDebugger, givenActiveDebuggerWhenGetDebuggerOptionReturnsZeroThenIsOptimizationDisabledReturnsFalse) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
char value = '1';
GfxDbgOption optionArgOut;
interceptor.optionArgOut = &optionArgOut;
interceptor.optionArgOut->value = &value;
interceptor.optionArgOut->valueLen = sizeof(value);
interceptor.optionRetVal = 0;
MockSourceLevelDebugger debugger;
debugger.callBaseIsOptimizationDisabled = true;
bool isOptDisabled = debugger.isOptimizationDisabled();
EXPECT_FALSE(isOptDisabled);
}
TEST(SourceLevelDebugger, givenActiveDebuggerAndOptDisabledWhenGetDebuggerOptionReturnsNonZeroAndOneInValueThenIsOptimizationDisabledReturnsTrue) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
char value[2] = {'1', 0};
GfxDbgOption optionArgOut;
interceptor.optionArgOut = &optionArgOut;
interceptor.optionArgOut->value = value;
interceptor.optionArgOut->valueLen = sizeof(value);
interceptor.optionRetVal = 1;
MockSourceLevelDebugger debugger;
debugger.callBaseIsOptimizationDisabled = true;
bool isOptDisabled = debugger.isOptimizationDisabled();
EXPECT_TRUE(isOptDisabled);
}
TEST(SourceLevelDebugger, givenActiveDebuggerAndOptDisabledWhenGetDebuggerOptionReturnsNonZeroAndZeroInValueThenIsOptimizationDisabledReturnsFalse) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
char value = '0';
GfxDbgOption optionArgOut;
interceptor.optionArgOut = &optionArgOut;
interceptor.optionArgOut->value = &value;
interceptor.optionArgOut->valueLen = sizeof(value);
interceptor.optionRetVal = 1;
MockSourceLevelDebugger debugger;
debugger.callBaseIsOptimizationDisabled = true;
bool isOptDisabled = debugger.isOptimizationDisabled();
EXPECT_FALSE(isOptDisabled);
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenNotifyKernelDebugDataIsCalledThenDebuggerLibraryFunctionIsCalled) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
char isa[8];
char dbgIsa[10];
char visa[12];
KernelInfo info;
info.debugData.genIsa = dbgIsa;
info.debugData.vIsa = visa;
info.debugData.genIsaSize = sizeof(dbgIsa);
info.debugData.vIsaSize = sizeof(visa);
info.kernelDescriptor.kernelMetadata.kernelName = "debugKernel";
info.heapInfo.kernelHeapSize = sizeof(isa);
info.heapInfo.pKernelHeap = isa;
debugger.callBaseNotifyKernelDebugData = true;
debugger.notifyKernelDebugData(&info.debugData, info.kernelDescriptor.kernelMetadata.kernelName, info.heapInfo.pKernelHeap, info.heapInfo.kernelHeapSize);
EXPECT_TRUE(interceptor.kernelDebugDataCalled);
EXPECT_EQ(static_cast<uint32_t>(IGFXDBG_CURRENT_VERSION), interceptor.kernelDebugDataArgIn.version);
EXPECT_EQ(reinterpret_cast<GfxDeviceHandle>(static_cast<uint64_t>(MockSourceLevelDebugger::mockDeviceHandle)), interceptor.kernelDebugDataArgIn.hDevice);
EXPECT_EQ(reinterpret_cast<GenRtProgramHandle>(0), interceptor.kernelDebugDataArgIn.hProgram);
EXPECT_EQ(dbgIsa, interceptor.kernelDebugDataArgIn.dbgGenIsaBuffer);
EXPECT_EQ(sizeof(dbgIsa), interceptor.kernelDebugDataArgIn.dbgGenIsaSize);
EXPECT_EQ(visa, interceptor.kernelDebugDataArgIn.dbgVisaBuffer);
EXPECT_EQ(sizeof(visa), interceptor.kernelDebugDataArgIn.dbgVisaSize);
EXPECT_EQ(info.heapInfo.kernelHeapSize, interceptor.kernelDebugDataArgIn.KernelBinSize);
EXPECT_EQ(isa, interceptor.kernelDebugDataArgIn.kernelBinBuffer);
EXPECT_STREQ(info.kernelDescriptor.kernelMetadata.kernelName.c_str(), interceptor.kernelDebugDataArgIn.kernelName);
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenNullptrDebugDataIsPassedToNotifyThenDebuggerNotifiedWithNullPointersAndZeroSizes) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
char isa[8];
KernelInfo info;
info.kernelDescriptor.kernelMetadata.kernelName = "debugKernel";
info.heapInfo.kernelHeapSize = sizeof(isa);
info.heapInfo.pKernelHeap = isa;
debugger.callBaseNotifyKernelDebugData = true;
debugger.notifyKernelDebugData(nullptr, info.kernelDescriptor.kernelMetadata.kernelName, info.heapInfo.pKernelHeap, info.heapInfo.kernelHeapSize);
EXPECT_TRUE(interceptor.kernelDebugDataCalled);
EXPECT_EQ(static_cast<uint32_t>(IGFXDBG_CURRENT_VERSION), interceptor.kernelDebugDataArgIn.version);
EXPECT_EQ(reinterpret_cast<GfxDeviceHandle>(static_cast<uint64_t>(MockSourceLevelDebugger::mockDeviceHandle)), interceptor.kernelDebugDataArgIn.hDevice);
EXPECT_EQ(reinterpret_cast<GenRtProgramHandle>(0), interceptor.kernelDebugDataArgIn.hProgram);
EXPECT_EQ(nullptr, interceptor.kernelDebugDataArgIn.dbgGenIsaBuffer);
EXPECT_EQ(0u, interceptor.kernelDebugDataArgIn.dbgGenIsaSize);
EXPECT_EQ(nullptr, interceptor.kernelDebugDataArgIn.dbgVisaBuffer);
EXPECT_EQ(0u, interceptor.kernelDebugDataArgIn.dbgVisaSize);
EXPECT_EQ(info.heapInfo.kernelHeapSize, interceptor.kernelDebugDataArgIn.KernelBinSize);
EXPECT_EQ(isa, interceptor.kernelDebugDataArgIn.kernelBinBuffer);
EXPECT_STREQ(info.kernelDescriptor.kernelMetadata.kernelName.c_str(), interceptor.kernelDebugDataArgIn.kernelName);
}
TEST(SourceLevelDebugger, givenNoVisaWhenNotifyKernelDebugDataIsCalledThenDebuggerLibraryFunctionIsCalledWithIsa) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
char isa[8];
char dbgIsa[10];
KernelInfo info;
info.debugData.genIsa = dbgIsa;
info.debugData.vIsa = nullptr;
info.debugData.genIsaSize = sizeof(dbgIsa);
info.debugData.vIsaSize = 0;
info.kernelDescriptor.kernelMetadata.kernelName = "debugKernel";
info.heapInfo.kernelHeapSize = sizeof(isa);
info.heapInfo.pKernelHeap = isa;
debugger.callBaseNotifyKernelDebugData = true;
debugger.notifyKernelDebugData(&info.debugData, info.kernelDescriptor.kernelMetadata.kernelName, info.heapInfo.pKernelHeap, info.heapInfo.kernelHeapSize);
EXPECT_TRUE(interceptor.kernelDebugDataCalled);
EXPECT_EQ(isa, interceptor.kernelDebugDataArgIn.kernelBinBuffer);
}
TEST(SourceLevelDebugger, givenNoGenIsaWhenNotifyKernelDebugDataIsCalledThenDebuggerLibraryFunctionIsCalledWithIsa) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
char isa[8];
char visa[12];
KernelInfo info;
info.debugData.genIsa = nullptr;
info.debugData.vIsa = visa;
info.debugData.genIsaSize = 0;
info.debugData.vIsaSize = sizeof(visa);
info.kernelDescriptor.kernelMetadata.kernelName = "debugKernel";
info.heapInfo.kernelHeapSize = sizeof(isa);
info.heapInfo.pKernelHeap = isa;
debugger.callBaseNotifyKernelDebugData = true;
debugger.notifyKernelDebugData(&info.debugData, info.kernelDescriptor.kernelMetadata.kernelName, isa, sizeof(isa));
EXPECT_TRUE(interceptor.kernelDebugDataCalled);
EXPECT_EQ(isa, interceptor.kernelDebugDataArgIn.kernelBinBuffer);
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryNotActiveWhenNotifyKernelDebugDataIsCalledThenDebuggerLibraryFunctionIsNotCalled) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(false);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
debugger.setActive(false);
KernelInfo info;
debugger.callBaseNotifyKernelDebugData = true;
debugger.notifyKernelDebugData(&info.debugData, info.kernelDescriptor.kernelMetadata.kernelName, nullptr, 0);
EXPECT_FALSE(interceptor.kernelDebugDataCalled);
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenInitializeIsCalledWithLocalMemoryUsageFalseThenDebuggerFunctionIsCalledWithCorrectArg) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
debugger.callBaseInitialize = true;
debugger.initialize(false);
EXPECT_TRUE(interceptor.initCalled);
EXPECT_FALSE(interceptor.targetCapsArgIn.supportsLocalMemory);
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenInitializeReturnsErrorThenIsActiveIsSetToFalse) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
interceptor.initRetVal = IgfxdbgRetVal::IGFXDBG_FAILURE;
debugger.callBaseInitialize = true;
debugger.initialize(false);
EXPECT_TRUE(interceptor.initCalled);
EXPECT_FALSE(debugger.isDebuggerActive());
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenInitializeIsCalledWithLocalMemoryUsageTrueThenDebuggerFunctionIsCalledWithCorrectArg) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
debugger.callBaseInitialize = true;
debugger.initialize(true);
EXPECT_TRUE(interceptor.initCalled);
EXPECT_TRUE(interceptor.targetCapsArgIn.supportsLocalMemory);
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryNotActiveWhenInitializeIsCalledThenDebuggerFunctionIsNotCalled) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(false);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
debugger.callBaseInitialize = true;
debugger.initialize(false);
EXPECT_FALSE(interceptor.initCalled);
}
HWTEST2_F(SourceLevelDebuggerSupportedFixture, givenKernelDebuggerLibraryActiveWhenDeviceIsConstructedThenDebuggerIsInitialized, HasSourceLevelDebuggerSupport) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
auto executionEnvironment = MockDevice::prepareExecutionEnvironment(&hwInfo, 0u);
auto device = std::make_unique<MockClDevice>(MockDevice::createWithExecutionEnvironment<MockDevice>(&hwInfo, executionEnvironment, 0u));
EXPECT_TRUE(interceptor.initCalled);
}
HWTEST2_F(SourceLevelDebuggerSupportedFixture, givenKernelDebuggerLibraryActiveWhenDeviceImplIsCreatedThenDebuggerIsNotified, HasSourceLevelDebuggerSupport) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
auto executionEnvironment = MockDevice::prepareExecutionEnvironment(&hwInfo, 0u);
unique_ptr<MockDevice> device(MockDevice::createWithExecutionEnvironment<MockDevice>(&hwInfo, executionEnvironment, 0u));
unique_ptr<MockClDevice> pClDevice(new MockClDevice{device.get()});
EXPECT_TRUE(interceptor.newDeviceCalled);
uint32_t deviceHandleExpected = device->getGpgpuCommandStreamReceiver().getOSInterface() != nullptr ? device->getGpgpuCommandStreamReceiver().getOSInterface()->getDriverModel()->getDeviceHandle() : 0;
EXPECT_EQ(reinterpret_cast<GfxDeviceHandle>(static_cast<uint64_t>(deviceHandleExpected)), interceptor.newDeviceArgIn.dh);
pClDevice.reset();
device.release();
}
HWTEST2_F(SourceLevelDebuggerSupportedFixture, givenKernelDebuggerLibraryActiveWhenDeviceImplIsCreatedWithOsCsrThenDebuggerIsNotifiedWithCorrectDeviceHandle, HasSourceLevelDebuggerSupport) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
VariableBackup<UltHwConfig> backup(&ultHwConfig);
ultHwConfig.useHwCsr = true;
HardwareInfo *hwInfo = nullptr;
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1);
hwInfo->capabilityTable.debuggerSupported = true;
hwInfo->capabilityTable.instrumentationEnabled = true;
unique_ptr<MockDevice> device(Device::create<MockDevice>(executionEnvironment, 0));
unique_ptr<MockClDevice> pClDevice(new MockClDevice{device.get()});
ASSERT_NE(nullptr, device->getGpgpuCommandStreamReceiver().getOSInterface());
EXPECT_TRUE(interceptor.newDeviceCalled);
uint32_t deviceHandleExpected = device->getGpgpuCommandStreamReceiver().getOSInterface()->getDriverModel()->getDeviceHandle();
EXPECT_EQ(reinterpret_cast<GfxDeviceHandle>(static_cast<uint64_t>(deviceHandleExpected)), interceptor.newDeviceArgIn.dh);
device.release();
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryNotActiveWhenDeviceIsCreatedThenDebuggerIsNotCreatedInitializedAndNotNotified) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(false);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
EXPECT_EQ(nullptr, device->getDebugger());
EXPECT_FALSE(interceptor.initCalled);
EXPECT_FALSE(interceptor.newDeviceCalled);
}
TEST(SourceLevelDebugger, givenDefaultStateWhenDeviceIsCreatedThenLoadDebuggerLibraryIsNotCalled) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(false);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
EXPECT_FALSE(interceptor.loadCalled);
}
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryNotActiveWhenGettingSourceLevelDebuggerThenNullptrIsReturned) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(false);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
EXPECT_EQ(nullptr, device->getSourceLevelDebugger());
}
TEST(SourceLevelDebugger, givenDeviceWithDebuggerActiveSetWhenSourceLevelDebuggerIsNotCreatedThenNotificationsAreNotCalled) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(false);
DebuggerLibrary::setDebuggerActive(false);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDeviceWithDebuggerActive>(nullptr));
EXPECT_TRUE(device->isDebuggerActive());
EXPECT_EQ(nullptr, device->getDebugger());
EXPECT_FALSE(interceptor.newDeviceCalled);
EXPECT_FALSE(interceptor.deviceDestructionCalled);
}
HWTEST2_F(SourceLevelDebuggerSupportedFixture, givenTwoRootDevicesWhenSecondIsCreatedThenCreatingNewSourceLevelDebugger, HasSourceLevelDebuggerSupport) {
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(2);
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {
executionEnvironment->rootDeviceEnvironments[i]->setHwInfoAndInitHelpers(&hwInfo);
executionEnvironment->rootDeviceEnvironments[i]->initGmm();
}
auto device1 = std::make_unique<MockClDevice>(Device::create<MockDevice>(executionEnvironment, 0u));
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
EXPECT_TRUE(interceptor.initCalled);
interceptor.initCalled = false;
auto device2 = std::make_unique<MockClDevice>(Device::create<MockDevice>(executionEnvironment, 1u));
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
EXPECT_TRUE(interceptor.initCalled);
}
HWTEST2_F(SourceLevelDebuggerSupportedFixture, givenMultipleRootDevicesWhenCreatedThenUseDedicatedSourceLevelDebugger, HasSourceLevelDebuggerSupport) {
DebuggerLibraryRestore restore;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(2);
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {
executionEnvironment->rootDeviceEnvironments[i]->setHwInfoAndInitHelpers(&hwInfo);
executionEnvironment->rootDeviceEnvironments[i]->initGmm();
}
auto device1 = std::make_unique<MockClDevice>(Device::create<MockDevice>(executionEnvironment, 0u));
auto sourceLevelDebugger = device1->getDebugger();
auto device2 = std::make_unique<MockClDevice>(Device::create<MockDevice>(executionEnvironment, 1u));
EXPECT_NE(sourceLevelDebugger, device2->getDebugger());
}
TEST(SourceLevelDebugger, whenCaptureSBACalledThenNoCommandsAreAddedToStream) {
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
auto device = std::unique_ptr<Device>(Device::create<MockDevice>(executionEnvironment, 0u));
MockSourceLevelDebugger debugger;
CommandContainer container;
container.initialize(device.get(), nullptr, HeapSize::defaultHeapSize, true, false);
NEO::Debugger::SbaAddresses sbaAddresses = {};
debugger.captureStateBaseAddress(*container.getCommandStream(), sbaAddresses, false);
EXPECT_EQ(0u, container.getCommandStream()->getUsed());
}
TEST(SourceLevelDebugger, whenGetSbaTrackingCommandsSizeQueriedThenZeroIsReturned) {
auto debugger = std::make_unique<SourceLevelDebugger>(new DebuggerLibrary);
auto size = debugger->getSbaTrackingCommandsSize(3);
EXPECT_EQ(0u, size);
}
HWTEST2_F(SourceLevelDebuggerSupportedFixture, givenEnableMockSourceLevelDebuggerWhenInitializingExecEnvThenActiveDebuggerWithEmptyInterfaceIsCreated, HasSourceLevelDebuggerSupport) {
DebugManagerStateRestore stateRestore;
DebuggerLibraryRestore restore;
DebuggerLibrary::setLibraryAvailable(false);
DebugManager.flags.EnableMockSourceLevelDebugger.set(1);
auto executionEnvironment = MockDevice::prepareExecutionEnvironment(&hwInfo, 0u);
MockPlatform platform(*executionEnvironment);
platform.initializeWithNewDevices();
auto debugger = static_cast<SourceLevelDebugger *>(executionEnvironment->rootDeviceEnvironments[0]->debugger.get());
ASSERT_NE(nullptr, debugger);
EXPECT_TRUE(debugger->isDebuggerActive());
EXPECT_FALSE(debugger->initialize(false));
debugger->notifyNewDevice(4);
EXPECT_TRUE(debugger->isOptimizationDisabled());
const char source[] = "sourceCode";
string file;
debugger->notifySourceCode(source, sizeof(source), file);
char isa[8];
char dbgIsa[10];
char visa[12];
KernelInfo info;
info.debugData.genIsa = dbgIsa;
info.debugData.vIsa = visa;
info.debugData.genIsaSize = sizeof(dbgIsa);
info.debugData.vIsaSize = sizeof(visa);
info.kernelDescriptor.kernelMetadata.kernelName = "debugKernel";
info.heapInfo.kernelHeapSize = sizeof(isa);
info.heapInfo.pKernelHeap = isa;
debugger->notifyKernelDebugData(&info.debugData, info.kernelDescriptor.kernelMetadata.kernelName, info.heapInfo.pKernelHeap, info.heapInfo.kernelHeapSize);
debugger->notifyKernelDebugData(nullptr, info.kernelDescriptor.kernelMetadata.kernelName, info.heapInfo.pKernelHeap, info.heapInfo.kernelHeapSize);
debugger->notifyKernelDebugData(nullptr, info.kernelDescriptor.kernelMetadata.kernelName, nullptr, 0);
EXPECT_TRUE(debugger->notifyDeviceDestruction());
}
HWTEST2_F(SourceLevelDebuggerSupportedFixture, givenMode1InEnableMockSourceLevelDebuggerWhenDebuggerCreatedThenIsOptimizationDisabledReturnsTrue, HasSourceLevelDebuggerSupport) {
DebugManagerStateRestore stateRestore;
DebuggerLibraryRestore restore;
DebuggerLibrary::setLibraryAvailable(false);
DebugManager.flags.EnableMockSourceLevelDebugger.set(1);
auto sld = std::unique_ptr<SourceLevelDebugger>(SourceLevelDebugger::create());
EXPECT_TRUE(sld->isOptimizationDisabled());
}
HWTEST2_F(SourceLevelDebuggerSupportedFixture, givenMode2InEnableMockSourceLevelDebuggerWhenDebuggerCreatedThenIsOptimizationDisabledReturnsFalse, HasSourceLevelDebuggerSupport) {
DebugManagerStateRestore stateRestore;
DebuggerLibraryRestore restore;
DebuggerLibrary::setLibraryAvailable(false);
DebugManager.flags.EnableMockSourceLevelDebugger.set(2);
auto sld = std::unique_ptr<SourceLevelDebugger>(SourceLevelDebugger::create());
EXPECT_FALSE(sld->isOptimizationDisabled());
}
TEST(SourceLevelDebugger, givenDebugVarDumpElfWhenNotifyKernelDebugDataIsCalledThenElfFileIsCreated) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.DebuggerLogBitmask.set(NEO::DebugVariables::DEBUGGER_LOG_BITMASK::DUMP_ELF);
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
char isa[8];
char dbgIsa[10];
char visa[12];
KernelInfo info;
info.debugData.genIsa = dbgIsa;
info.debugData.vIsa = visa;
info.debugData.genIsaSize = sizeof(dbgIsa);
info.debugData.vIsaSize = sizeof(visa);
info.kernelDescriptor.kernelMetadata.kernelName = "debugKernel";
info.heapInfo.kernelHeapSize = sizeof(isa);
info.heapInfo.pKernelHeap = isa;
std::string fileName = info.kernelDescriptor.kernelMetadata.kernelName + ".elf";
EXPECT_FALSE(fileExists(fileName));
debugger.callBaseNotifyKernelDebugData = true;
debugger.notifyKernelDebugData(&info.debugData, info.kernelDescriptor.kernelMetadata.kernelName, info.heapInfo.pKernelHeap, info.heapInfo.kernelHeapSize);
EXPECT_TRUE(fileExists(fileName));
std::remove(fileName.c_str());
}
TEST(SourceLevelDebugger, givenDebugVarDumpElfWhenElfFileExistsWhileNotifyingDebugDataThenSuffixIsAppendedToFileName) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.DebuggerLogBitmask.set(NEO::DebugVariables::DEBUGGER_LOG_BITMASK::DUMP_ELF);
DebuggerLibraryRestore restore;
DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
MockSourceLevelDebugger debugger;
char isa[8];
char dbgIsa[10];
char visa[12];
KernelInfo info;
info.debugData.genIsa = dbgIsa;
info.debugData.vIsa = visa;
info.debugData.genIsaSize = sizeof(dbgIsa);
info.debugData.vIsaSize = sizeof(visa);
info.kernelDescriptor.kernelMetadata.kernelName = "debugKernel";
info.heapInfo.kernelHeapSize = sizeof(isa);
info.heapInfo.pKernelHeap = isa;
std::string fileName = info.kernelDescriptor.kernelMetadata.kernelName + ".elf";
char data[4];
writeDataToFile(fileName.c_str(), data, 4);
EXPECT_TRUE(fileExists(fileName));
std::string fileName2 = info.kernelDescriptor.kernelMetadata.kernelName + "_0.elf";
debugger.callBaseNotifyKernelDebugData = true;
debugger.notifyKernelDebugData(&info.debugData, info.kernelDescriptor.kernelMetadata.kernelName, info.heapInfo.pKernelHeap, info.heapInfo.kernelHeapSize);
EXPECT_TRUE(fileExists(fileName2));
std::remove(fileName.c_str());
std::remove(fileName2.c_str());
}
TEST(SourceLevelDebugger, givenDebuggerLibraryAvailableAndExperimentalEnableSourceLevelDebuggerThenDebuggerIsCreated) {
DebugManagerStateRestore stateRestore;
DebuggerLibraryRestore restore;
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::setLibraryAvailable(true);
DebugManager.flags.ExperimentalEnableSourceLevelDebugger.set(1);
auto executionEnvironment = new ExecutionEnvironment();
MockPlatform platform(*executionEnvironment);
platform.initializeWithNewDevices();
auto debugger = std::unique_ptr<Debugger>(Debugger::create(*executionEnvironment->rootDeviceEnvironments[0].get()));
ASSERT_NE(nullptr, debugger.get());
EXPECT_TRUE(debugger->isLegacy());
}
using LegacyDebuggerTest = ::testing::Test;
HWTEST2_F(LegacyDebuggerTest, givenNotXeHpOrXeHpgCoreAndDebugIsActiveThenDisableL3CacheInGmmHelperIsNotSet, IsNotXeHpOrXeHpgCore) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.EnableMockSourceLevelDebugger.set(1);
auto executionEnvironment = new ExecutionEnvironment();
MockPlatform platform(*executionEnvironment);
platform.initializeWithNewDevices();
EXPECT_FALSE(static_cast<MockGmmHelper *>(platform.getClDevice(0)->getDevice().getGmmHelper())->allResourcesUncached);
}
HWTEST2_F(LegacyDebuggerTest, givenDebugIsActiveThenDisableL3CacheInGmmHelperIsSet, IsDG2) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.EnableMockSourceLevelDebugger.set(1);
auto hwInfo = *NEO::defaultHwInfo;
hwInfo.capabilityTable.debuggerSupported = true;
auto executionEnvironment = MockDevice::prepareExecutionEnvironment(&hwInfo, 0u);
MockPlatform platform(*executionEnvironment);
platform.initializeWithNewDevices();
EXPECT_TRUE(static_cast<MockGmmHelper *>(platform.getClDevice(0)->getDevice().getGmmHelper())->allResourcesUncached);
}

View File

@@ -30,10 +30,6 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XE_HP_COREDeviceCaps, givenKernelThatDoesStatelessW
EXPECT_EQ(statelessWritesEmitted, mockKernel.mockKernel->areStatelessWritesUsed());
}
XE_HP_CORE_TEST_F(XE_HP_COREDeviceCaps, givenXE_HP_COREThenDebuggerIsNotSupported) {
EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.debuggerSupported);
}
XE_HP_CORE_TEST_F(XE_HP_COREDeviceCaps, givenXE_HP_COREWhenCheckFtrSupportsInteger64BitAtomicsThenReturnTrue) {
EXPECT_TRUE(pDevice->getHardwareInfo().capabilityTable.ftrSupportsInteger64BitAtomics);
}

View File

@@ -47,12 +47,12 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenL3ToL1DebugFlagWhenStatelessMocsIsProgra
EXPECT_EQ(stateBaseAddress->getL1CachePolicyL1CacheControl(), STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB);
}
DG2TEST_F(CmdsProgrammingTestsDg2, givenL3ToL1DebugFlagAndDebuggerActiveWhenStatelessMocsIsProgrammedThenItHasCorrectL1CachingOn) {
DG2TEST_F(CmdsProgrammingTestsDg2, givenL3ToL1DebugFlagAndDebuggerInitializedWhenStatelessMocsIsProgrammedThenItHasCorrectL1CachingOn) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
DebugManagerStateRestore restore;
DebugManager.flags.ForceL1Caching.set(1u);
pDevice->setDebuggerActive(true);
pDevice->executionEnvironment->rootDeviceEnvironments[0]->initDebuggerL0(pDevice);
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
flushTask(commandStreamReceiver);
@@ -127,9 +127,11 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenAlignedCacheableReadOnlyBufferThenChoseO
alignedFree(ptr);
}
DG2TEST_F(CmdsProgrammingTestsDg2, givenAlignedCacheableReadOnlyBufferAndDebuggerActiveWhenBufferCreateThenChoseOclBufferConstPolicy) {
DG2TEST_F(CmdsProgrammingTestsDg2, givenAlignedCacheableReadOnlyBufferAndDebuggerInitializedWhenBufferCreateThenChoseOclBufferConstPolicy) {
MockContext context;
const_cast<DeviceInfo &>(context.getDevice(0)->getDevice().getDeviceInfo()).debuggerActive = true;
auto clDevice = context.getDevice(0);
clDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->initDebuggerL0(&clDevice->getDevice());
const auto size = MemoryConstants::pageSize;
const auto ptr = (void *)alignedMalloc(size * 2, MemoryConstants::pageSize);
const auto flags = CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY;
@@ -144,9 +146,9 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenAlignedCacheableReadOnlyBufferAndDebugge
EXPECT_EQ(CL_SUCCESS, retVal);
typename FamilyType::RENDER_SURFACE_STATE surfaceState = {};
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false);
buffer->setArgStateful(&surfaceState, false, false, false, false, clDevice->getDevice(), false, false);
const auto expectedMocs = context.getDevice(0)->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST);
const auto expectedMocs = clDevice->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST);
const auto actualMocs = surfaceState.getMemoryObjectControlState();
EXPECT_EQ(expectedMocs, actualMocs);