Skip to content

Commit 5eafc34

Browse files
Introduce SBA tracking buffer allocation
Related-To: NEO-4637 - allocate sbaAllocation in L0 debugger Change-Id: Ia1be1ad637bbdd6e7f12ca6fdfb0c486ba23a040 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
1 parent 2e6fc92 commit 5eafc34

File tree

9 files changed

+72
-6
lines changed

9 files changed

+72
-6
lines changed

level_zero/core/source/debugger/debugger_l0.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,29 @@
77

88
#include "level_zero/core/source/debugger/debugger_l0.h"
99

10+
#include "shared/source/device/device.h"
11+
#include "shared/source/helpers/constants.h"
12+
#include "shared/source/memory_manager/allocation_properties.h"
13+
#include "shared/source/memory_manager/memory_manager.h"
14+
1015
namespace L0 {
16+
DebuggerL0::DebuggerL0(NEO::Device *device) : device(device) {
17+
isLegacyMode = false;
18+
19+
NEO::AllocationProperties properties{device->getRootDeviceIndex(), true, MemoryConstants::pageSize,
20+
NEO::GraphicsAllocation::AllocationType::DEBUG_SBA_TRACKING_BUFFER,
21+
false,
22+
CommonConstants::allDevicesBitfield};
23+
24+
sbaAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
25+
}
26+
27+
DebuggerL0 ::~DebuggerL0() {
28+
device->getMemoryManager()->freeGraphicsMemory(sbaAllocation);
29+
}
30+
1131
bool DebuggerL0::isDebuggerActive() {
1232
return true;
1333
}
34+
1435
} // namespace L0

level_zero/core/source/debugger/debugger_l0.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,34 @@
1313

1414
namespace NEO {
1515
class Device;
16-
}
16+
class GraphicsAllocation;
17+
} // namespace NEO
1718

1819
namespace L0 {
20+
struct SbaTrackedAddresses {
21+
uint64_t GeneralStateBaseAddress;
22+
uint64_t SurfaceStateBaseAddress;
23+
uint64_t DynamicStateBaseAddress;
24+
uint64_t IndirectObjectBaseAddress;
25+
uint64_t InstructionBaseAddress;
26+
uint64_t BindlessSurfaceStateBaseAddress;
27+
uint64_t BindlessSamplerStateBaseAddress;
28+
};
29+
1930
class DebuggerL0 : public NEO::Debugger, NEO::NonCopyableOrMovableClass {
2031
public:
2132
static std::unique_ptr<Debugger> create(NEO::Device *device);
2233
bool isDebuggerActive() override;
2334

24-
DebuggerL0(NEO::Device *device) : device(device) {
25-
isLegacyMode = false;
35+
DebuggerL0(NEO::Device *device);
36+
~DebuggerL0() override;
37+
38+
NEO::GraphicsAllocation *getSbaTrackingBuffer() {
39+
return sbaAllocation;
2640
}
27-
~DebuggerL0() override = default;
2841

2942
protected:
3043
NEO::Device *device = nullptr;
44+
NEO::GraphicsAllocation *sbaAllocation = nullptr;
3145
};
3246
} // namespace L0

level_zero/core/source/device/device.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "shared/source/helpers/hw_info.h"
1414
#include "shared/source/os_interface/os_interface.h"
1515

16+
#include "level_zero/core/source/debugger/debugger_l0.h"
1617
#include "level_zero/core/source/driver/driver.h"
1718
#include "level_zero/core/source/driver/driver_handle.h"
1819
#include <level_zero/ze_api.h>
@@ -107,6 +108,13 @@ struct Device : _ze_device_handle_t {
107108
virtual const NEO::DeviceInfo &getDeviceInfo() const = 0;
108109
virtual NEO::Device *getNEODevice() = 0;
109110
NEO::SourceLevelDebugger *getSourceLevelDebugger() { return getNEODevice()->getSourceLevelDebugger(); }
111+
DebuggerL0 *getL0Debugger() {
112+
auto debugger = getNEODevice()->getDebugger();
113+
if (debugger) {
114+
return !debugger->isLegacy() ? static_cast<DebuggerL0 *>(debugger) : nullptr;
115+
}
116+
return nullptr;
117+
}
110118

111119
virtual NEO::GraphicsAllocation *getDebugSurface() const = 0;
112120

level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,21 @@ TEST_F(L0DebuggerTest, givenL0DebuggerWhenGettingSourceLevelDebuggerThenNullptrR
2727
EXPECT_EQ(nullptr, neoDevice->getSourceLevelDebugger());
2828
}
2929

30+
TEST_F(L0DebuggerTest, givenL0DebuggerWhenGettingL0DebuggerThenValidDebuggerInstanceIsReturned) {
31+
EXPECT_NE(nullptr, device->getL0Debugger());
32+
}
33+
3034
TEST_F(L0DebuggerTest, givenL0DebuggerWhenCallingIsDebuggerActiveThenTrueIsReturned) {
3135
EXPECT_TRUE(neoDevice->getDebugger()->isDebuggerActive());
3236
}
3337

38+
TEST_F(L0DebuggerTest, givenL0DebuggerWhenCreatedThenSbaTrackingBufferIsAllocated) {
39+
auto debugger = device->getL0Debugger();
40+
ASSERT_NE(nullptr, debugger);
41+
ASSERT_NE(nullptr, debugger->getSbaTrackingBuffer());
42+
EXPECT_EQ(NEO::GraphicsAllocation::AllocationType::DEBUG_SBA_TRACKING_BUFFER, debugger->getSbaTrackingBuffer()->getAllocationType());
43+
}
44+
3445
HWTEST_F(L0DebuggerTest, givenDebuggingEnabledWhenCommandListIsExecutedThenKernelDebugCommandsAreAdded) {
3546
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
3647
using STATE_SIP = typename FamilyType::STATE_SIP;

level_zero/core/test/unit_tests/sources/debugger/test_source_level_debugger.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ TEST_F(DeviceWithDebuggerEnabledTest, givenDebuggingEnabledWhenDeviceIsCreatedTh
7878
EXPECT_EQ(NEO::GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA, deviceL0->getDebugSurface()->getAllocationType());
7979
}
8080

81+
TEST_F(DeviceWithDebuggerEnabledTest, givenSldDebuggerWhenGettingL0DebuggerThenNullptrIsReturned) {
82+
EXPECT_EQ(nullptr, deviceL0->getL0Debugger());
83+
}
84+
8185
struct TwoSubDevicesDebuggerEnabledTest : public ActiveDebuggerFixture, public ::testing::Test {
8286
void SetUp() override { // NOLINT(readability-identifier-naming)
8387
DebugManager.flags.CreateMultipleSubDevices.set(2);

level_zero/core/test/unit_tests/sources/device/test_device.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,5 +492,9 @@ TEST_F(DeviceTest, givenNoActiveSourceLevelDebuggerWhenGetIsCalledThenNullptrIsR
492492
EXPECT_EQ(nullptr, device->getSourceLevelDebugger());
493493
}
494494

495+
TEST_F(DeviceTest, givenNoL0DebuggerWhenGettingL0DebuggerThenNullptrReturned) {
496+
EXPECT_EQ(nullptr, device->getL0Debugger());
497+
}
498+
495499
} // namespace ult
496500
} // namespace L0

opencl/source/utilities/logger.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ const char *FileLogger<DebugLevel>::getAllocationTypeString(GraphicsAllocation c
326326
return "WRITE_COMBINED";
327327
case GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA:
328328
return "DEBUG_CONTEXT_SAVE_AREA";
329+
case GraphicsAllocation::AllocationType::DEBUG_SBA_TRACKING_BUFFER:
330+
return "DEBUG_SBA_TRACKING_BUFFER";
329331
default:
330332
return "ILLEGAL_VALUE";
331333
}

opencl/test/unit_test/utilities/file_logger_tests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,8 @@ AllocationTypeTestCase allocationTypeValues[] = {
931931
{GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER, "TIMESTAMP_PACKET_TAG_BUFFER"},
932932
{GraphicsAllocation::AllocationType::UNKNOWN, "UNKNOWN"},
933933
{GraphicsAllocation::AllocationType::WRITE_COMBINED, "WRITE_COMBINED"},
934-
{GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA, "DEBUG_CONTEXT_SAVE_AREA"}};
934+
{GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA, "DEBUG_CONTEXT_SAVE_AREA"},
935+
{GraphicsAllocation::AllocationType::DEBUG_SBA_TRACKING_BUFFER, "DEBUG_SBA_TRACKING_BUFFER"}};
935936

936937
class AllocationTypeLogging : public ::testing::TestWithParam<AllocationTypeTestCase> {};
937938

shared/source/memory_manager/graphics_allocation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
8484
WRITE_COMBINED,
8585
RING_BUFFER,
8686
SEMAPHORE_BUFFER,
87-
DEBUG_CONTEXT_SAVE_AREA
87+
DEBUG_CONTEXT_SAVE_AREA,
88+
DEBUG_SBA_TRACKING_BUFFER
8889
};
8990

9091
~GraphicsAllocation() override;

0 commit comments

Comments
 (0)