mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Program surface state when debugging is enabled
- surface state for debugSurface should be set when kernel is compiled for debug Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
5618d4dfa4
commit
f7613a5827
@@ -723,7 +723,7 @@ void KernelImp::printPrintfOutput() {
|
||||
|
||||
void KernelImp::setDebugSurface() {
|
||||
auto device = module->getDevice();
|
||||
if (module->isDebugEnabled() && device->getNEODevice()->isDebuggerActive()) {
|
||||
if (module->isDebugEnabled() && device->getNEODevice()->getDebugger()) {
|
||||
|
||||
auto surfaceStateHeapRef = ArrayRef<uint8_t>(surfaceStateHeapData.get(), surfaceStateHeapDataSize);
|
||||
|
||||
|
||||
@@ -27,7 +27,10 @@ struct WhiteBox<::L0::KernelImmutableData> : public ::L0::KernelImmutableData {
|
||||
using ::L0::KernelImmutableData::isaGraphicsAllocation;
|
||||
using ::L0::KernelImmutableData::kernelDescriptor;
|
||||
using ::L0::KernelImmutableData::KernelImmutableData;
|
||||
using ::L0::KernelImmutableData::kernelInfo;
|
||||
using ::L0::KernelImmutableData::residencyContainer;
|
||||
using ::L0::KernelImmutableData::surfaceStateHeapSize;
|
||||
using ::L0::KernelImmutableData::surfaceStateHeapTemplate;
|
||||
|
||||
WhiteBox() : ::L0::KernelImmutableData() {}
|
||||
};
|
||||
@@ -51,6 +54,8 @@ struct WhiteBox<::L0::Kernel> : public ::L0::KernelImp {
|
||||
using ::L0::KernelImp::printfBuffer;
|
||||
using ::L0::KernelImp::requiredWorkgroupOrder;
|
||||
using ::L0::KernelImp::residencyContainer;
|
||||
using ::L0::KernelImp::surfaceStateHeapData;
|
||||
using ::L0::KernelImp::surfaceStateHeapDataSize;
|
||||
using ::L0::KernelImp::unifiedMemoryControls;
|
||||
|
||||
void setBufferSurfaceState(uint32_t argIndex, void *address,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -63,6 +63,23 @@ struct MockModuleTranslationUnit : public L0::ModuleTranslationUnit {
|
||||
}
|
||||
};
|
||||
|
||||
struct MockModule : public L0::ModuleImp {
|
||||
using ModuleImp::debugEnabled;
|
||||
|
||||
MockModule(L0::Device *device,
|
||||
L0::ModuleBuildLog *moduleBuildLog,
|
||||
L0::ModuleType type) : ModuleImp(device, moduleBuildLog, type) {
|
||||
maxGroupSize = 32;
|
||||
};
|
||||
|
||||
~MockModule() = default;
|
||||
|
||||
const KernelImmutableData *getKernelImmutableData(const char *functionName) const override {
|
||||
return kernelImmData;
|
||||
}
|
||||
KernelImmutableData *kernelImmData = nullptr;
|
||||
};
|
||||
|
||||
struct MockCompilerInterface : public NEO::CompilerInterface {
|
||||
NEO::TranslationOutput::ErrorCode build(const NEO::Device &device,
|
||||
const NEO::TranslationInput &input,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "test.h"
|
||||
|
||||
#include "level_zero/core/source/module/module_imp.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/module_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_l0_debugger.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_module.h"
|
||||
|
||||
#include "active_debugger_fixture.h"
|
||||
@@ -103,5 +105,69 @@ TEST_F(DeviceWithDebuggerEnabledTest, GivenNonDebuggeableKernelWhenModuleIsIniti
|
||||
EXPECT_FALSE(module->isDebugEnabled());
|
||||
}
|
||||
|
||||
using KernelDebugSurfaceTest = Test<ModuleFixture>;
|
||||
|
||||
HWTEST_F(KernelDebugSurfaceTest, givenDebuggerAndBindfulKernelWhenAppendingKernelToCommandListThenBindfulSurfaceStateForDebugSurfaceIsProgrammed) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
|
||||
auto debugger = MockDebuggerL0Hw<FamilyType>::allocate(neoDevice);
|
||||
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(debugger);
|
||||
|
||||
auto debugSurface = neoDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(
|
||||
{device->getRootDeviceIndex(), true,
|
||||
NEO::SipKernel::maxDbgSurfaceSize,
|
||||
NEO::GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA,
|
||||
false,
|
||||
false,
|
||||
device->getNEODevice()->getDeviceBitfield()});
|
||||
static_cast<L0::DeviceImp *>(device)->setDebugSurface(debugSurface);
|
||||
|
||||
uint8_t binary[10];
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = binary;
|
||||
moduleDesc.inputSize = 10;
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
std::unique_ptr<MockModule> module = std::make_unique<MockModule>(device,
|
||||
moduleBuildLog,
|
||||
ModuleType::User);
|
||||
|
||||
module->debugEnabled = true;
|
||||
|
||||
uint32_t kernelHeap = 0;
|
||||
KernelInfo kernelInfo;
|
||||
kernelInfo.heapInfo.KernelHeapSize = 1;
|
||||
kernelInfo.heapInfo.pKernelHeap = &kernelHeap;
|
||||
|
||||
Mock<::L0::Kernel> kernel;
|
||||
kernel.module = module.get();
|
||||
kernel.immutableData.kernelInfo = &kernelInfo;
|
||||
|
||||
ze_kernel_desc_t desc = {};
|
||||
|
||||
kernel.immutableData.kernelDescriptor->payloadMappings.implicitArgs.systemThreadSurfaceAddress.bindful = sizeof(RENDER_SURFACE_STATE);
|
||||
kernel.immutableData.surfaceStateHeapSize = 2 * sizeof(RENDER_SURFACE_STATE);
|
||||
kernel.immutableData.surfaceStateHeapTemplate.reset(new uint8_t[2 * sizeof(RENDER_SURFACE_STATE)]);
|
||||
module->kernelImmData = &kernel.immutableData;
|
||||
|
||||
kernel.initialize(&desc);
|
||||
|
||||
auto debugSurfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(kernel.surfaceStateHeapData.get());
|
||||
debugSurfaceState = ptrOffset(debugSurfaceState, sizeof(RENDER_SURFACE_STATE));
|
||||
|
||||
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(RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT, debugSurfaceState->getCoherencyType());
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
Reference in New Issue
Block a user