mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
L0Debug - Notify cmdQueue create for subdevices
- PROCESS ENTRY triggered for first cmdQ created Related-To: NEO-5784 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
547dd59272
commit
ebcb3faad2
@@ -63,7 +63,7 @@ ze_result_t CommandQueueImp::initialize(bool copyOnly, bool isInternal) {
|
||||
partitionCount = csr->getActivePartitions();
|
||||
}
|
||||
if (NEO::Debugger::isDebugEnabled(internalUsage) && device->getL0Debugger()) {
|
||||
device->getL0Debugger()->notifyCommandQueueCreated();
|
||||
device->getL0Debugger()->notifyCommandQueueCreated(device->getNEODevice());
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
|
||||
@@ -61,7 +61,7 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::destroy() {
|
||||
}
|
||||
buffers.destroy(this->getDevice());
|
||||
if (NEO::Debugger::isDebugEnabled(internalUsage) && device->getL0Debugger()) {
|
||||
device->getL0Debugger()->notifyCommandQueueDestroyed();
|
||||
device->getL0Debugger()->notifyCommandQueueDestroyed(device->getNEODevice());
|
||||
}
|
||||
delete this;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "level_zero/core/source/cmdlist/cmdlist.h"
|
||||
#include "level_zero/core/source/device/device.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h"
|
||||
#include "level_zero/core/test/unit_tests/sources/debugger/l0_debugger_fixture.h"
|
||||
|
||||
@@ -26,13 +27,13 @@ namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
struct L0DebuggerLinuxFixture {
|
||||
void SetUp() { // NOLINT(readability-identifier-naming)
|
||||
void SetUp(HardwareInfo *hwInfo = nullptr) {
|
||||
auto executionEnvironment = new NEO::ExecutionEnvironment();
|
||||
auto mockBuiltIns = new MockBuiltins();
|
||||
auto mockBuiltIns = new NEO::MockBuiltins();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->setDebuggingEnabled();
|
||||
executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltIns);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(hwInfo ? hwInfo : defaultHwInfo.get());
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
auto osInterface = new OSInterface();
|
||||
drmMock = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
@@ -50,8 +51,7 @@ struct L0DebuggerLinuxFixture {
|
||||
device = driverHandle->devices[0];
|
||||
}
|
||||
|
||||
void TearDown() { // NOLINT(readability-identifier-naming)
|
||||
}
|
||||
void TearDown(){};
|
||||
|
||||
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
@@ -59,7 +59,39 @@ struct L0DebuggerLinuxFixture {
|
||||
DrmMockResources *drmMock = nullptr;
|
||||
};
|
||||
|
||||
struct L0DebuggerLinuxMultitileFixture : public L0DebuggerLinuxFixture {
|
||||
|
||||
void SetUp() {
|
||||
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(1);
|
||||
constexpr auto numSubDevices = 2u;
|
||||
DebugManager.flags.CreateMultipleSubDevices.set(2);
|
||||
hwInfo = *defaultHwInfo;
|
||||
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.IsValid = 1;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.TileCount = numSubDevices;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.Tile0 = 1;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.Tile1 = 1;
|
||||
hwInfo.gtSystemInfo.MultiTileArchInfo.TileMask = 3;
|
||||
|
||||
L0DebuggerLinuxFixture::SetUp(&hwInfo);
|
||||
|
||||
subDevice0 = neoDevice->getSubDevice(0)->getSpecializedDevice<Device>();
|
||||
subDevice1 = neoDevice->getSubDevice(1)->getSpecializedDevice<Device>();
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
L0DebuggerLinuxFixture::TearDown();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
HardwareInfo hwInfo;
|
||||
L0::Device *subDevice0 = nullptr;
|
||||
L0::Device *subDevice1 = nullptr;
|
||||
};
|
||||
|
||||
using L0DebuggerLinuxTest = Test<L0DebuggerLinuxFixture>;
|
||||
using L0DebuggerLinuxMultitileTest = Test<L0DebuggerLinuxMultitileFixture>;
|
||||
|
||||
TEST_F(L0DebuggerLinuxTest, givenProgramDebuggingEnabledWhenDriverHandleIsCreatedThenItAllocatesL0Debugger) {
|
||||
EXPECT_NE(nullptr, neoDevice->getDebugger());
|
||||
@@ -292,5 +324,40 @@ HWTEST_F(L0DebuggerLinuxTest, givenDebuggingEnabledWhenImmCommandListsCreatedAnd
|
||||
EXPECT_EQ(2u, debuggerL0Hw->commandQueueDestroyedCount);
|
||||
}
|
||||
|
||||
HWTEST_F(L0DebuggerLinuxMultitileTest, givenDebuggingEnabledWhenCommandQueuesCreatedThenDebuggerIsNotified) {
|
||||
|
||||
auto debuggerL0Hw = static_cast<MockDebuggerL0Hw<FamilyType> *>(device->getL0Debugger());
|
||||
drmMock->ioctlCallsCount = 0;
|
||||
neoDevice->getDefaultEngine().commandStreamReceiver->getOsContext().ensureContextInitialized();
|
||||
|
||||
EXPECT_EQ(2u, debuggerL0Hw->uuidL0CommandQueueHandle.size());
|
||||
|
||||
ze_command_queue_desc_t queueDesc = {};
|
||||
ze_result_t returnValue;
|
||||
|
||||
auto commandQueue1 = CommandQueue::create(productFamily, subDevice0, neoDevice->getDefaultEngine().commandStreamReceiver, &queueDesc, false, false, returnValue);
|
||||
EXPECT_EQ(1u, drmMock->ioctlCallsCount);
|
||||
EXPECT_EQ(1u, debuggerL0Hw->commandQueueCreatedCount);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
|
||||
|
||||
auto commandQueue2 = CommandQueue::create(productFamily, subDevice1, neoDevice->getDefaultEngine().commandStreamReceiver, &queueDesc, false, false, returnValue);
|
||||
EXPECT_EQ(2u, debuggerL0Hw->commandQueueCreatedCount);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
|
||||
|
||||
for (uint32_t index = 0; index < neoDevice->getNumSubDevices(); index++) {
|
||||
EXPECT_NE(0u, debuggerL0Hw->uuidL0CommandQueueHandle[index]);
|
||||
}
|
||||
|
||||
commandQueue1->destroy();
|
||||
EXPECT_EQ(1u, debuggerL0Hw->commandQueueDestroyedCount);
|
||||
|
||||
commandQueue2->destroy();
|
||||
EXPECT_EQ(2u, drmMock->unregisterCalledCount);
|
||||
EXPECT_EQ(2u, debuggerL0Hw->commandQueueDestroyedCount);
|
||||
|
||||
for (uint32_t index = 0; index < neoDevice->getNumSubDevices(); index++) {
|
||||
EXPECT_EQ(0u, debuggerL0Hw->uuidL0CommandQueueHandle[index]);
|
||||
}
|
||||
}
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
@@ -459,10 +459,20 @@ void DebugSessionLinux::handleEvent(prelim_drm_i915_debug_event *event) {
|
||||
clientHandleToConnection[uuid->client_handle]->uuidToModule.erase(uuid->handle);
|
||||
}
|
||||
|
||||
if (destroy && (uuidL0CommandQueueHandle == uuid->handle) && (clientHandle == uuid->client_handle)) {
|
||||
if (destroy && (clientHandle == uuid->client_handle)) {
|
||||
|
||||
for (const auto &uuidToDevice : uuidL0CommandQueueHandleToDevice) {
|
||||
if (uuidToDevice.first == uuid->handle) {
|
||||
uuidL0CommandQueueHandleToDevice.erase(uuidToDevice.first);
|
||||
|
||||
if (uuidL0CommandQueueHandleToDevice.size() == 0) {
|
||||
zet_debug_event_t debugEvent = {};
|
||||
debugEvent.type = ZET_DEBUG_EVENT_TYPE_PROCESS_EXIT;
|
||||
pushApiEvent(debugEvent, nullptr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -485,11 +495,21 @@ void DebugSessionLinux::handleEvent(prelim_drm_i915_debug_event *event) {
|
||||
if (uuidString == NEO::uuidL0CommandQueueHash) {
|
||||
if ((clientHandle == invalidClientHandle) || (clientHandle == uuid->client_handle)) {
|
||||
clientHandle = uuid->client_handle;
|
||||
uuidL0CommandQueueHandle = uuid->handle;
|
||||
|
||||
uint32_t deviceIndex = 0;
|
||||
if (readUuid.payload_size == sizeof(NEO::DebuggerL0::CommandQueueNotification)) {
|
||||
auto notification = reinterpret_cast<NEO::DebuggerL0::CommandQueueNotification *>(payload.get());
|
||||
deviceIndex = notification->subDeviceIndex;
|
||||
UNRECOVERABLE_IF(notification->subDeviceIndex >= notification->subDeviceCount);
|
||||
}
|
||||
|
||||
if (uuidL0CommandQueueHandleToDevice.size() == 0) {
|
||||
zet_debug_event_t debugEvent = {};
|
||||
debugEvent.type = ZET_DEBUG_EVENT_TYPE_PROCESS_ENTRY;
|
||||
pushApiEvent(debugEvent, nullptr);
|
||||
}
|
||||
uuidL0CommandQueueHandleToDevice[uuid->handle] = deviceIndex;
|
||||
}
|
||||
}
|
||||
|
||||
if (validClassUuid) {
|
||||
|
||||
@@ -248,7 +248,7 @@ struct DebugSessionLinux : DebugSessionImp {
|
||||
|
||||
uint64_t clientHandle = invalidClientHandle;
|
||||
uint64_t clientHandleClosed = invalidClientHandle;
|
||||
uint64_t uuidL0CommandQueueHandle = invalidClientHandle;
|
||||
std::unordered_map<uint64_t, uint32_t> uuidL0CommandQueueHandleToDevice;
|
||||
uint64_t euControlInterruptSeqno[NEO::EngineLimits::maxHandleCount];
|
||||
|
||||
std::unordered_map<uint64_t, std::unique_ptr<ClientConnection>> clientHandleToConnection;
|
||||
|
||||
@@ -296,7 +296,7 @@ struct MockDebugSessionLinux : public L0::DebugSessionLinux {
|
||||
using L0::DebugSessionLinux::ThreadControlCmd;
|
||||
using L0::DebugSessionLinux::typeToRegsetDesc;
|
||||
using L0::DebugSessionLinux::typeToRegsetFlags;
|
||||
using L0::DebugSessionLinux::uuidL0CommandQueueHandle;
|
||||
using L0::DebugSessionLinux::uuidL0CommandQueueHandleToDevice;
|
||||
using L0::DebugSessionLinux::writeGpuMemory;
|
||||
|
||||
MockDebugSessionLinux(const zet_debug_config_t &config, L0::Device *device, int debugFd) : DebugSessionLinux(config, device, debugFd) {
|
||||
@@ -1152,6 +1152,9 @@ TEST_F(DebugApiLinuxTest, GivenUuidCommandQueueCreatedHandledThenProcessEntryEve
|
||||
EXPECT_EQ(1u, session->apiEvents.size());
|
||||
EXPECT_EQ(MockDebugSessionLinux::mockClientHandle, session->clientHandle);
|
||||
EXPECT_EQ(3, handler->ioctlCalled);
|
||||
|
||||
EXPECT_EQ(0u, session->uuidL0CommandQueueHandleToDevice[2]);
|
||||
|
||||
auto event = session->apiEvents.front();
|
||||
EXPECT_EQ(ZET_DEBUG_EVENT_TYPE_PROCESS_ENTRY, event.type);
|
||||
|
||||
@@ -1159,11 +1162,86 @@ TEST_F(DebugApiLinuxTest, GivenUuidCommandQueueCreatedHandledThenProcessEntryEve
|
||||
uuid.client_handle = MockDebugSessionLinux::mockClientHandle;
|
||||
handler->returnUuid = &readUuid;
|
||||
session->handleEvent(&uuid.base);
|
||||
EXPECT_EQ(2u, session->apiEvents.size());
|
||||
EXPECT_EQ(1u, session->apiEvents.size());
|
||||
EXPECT_EQ(MockDebugSessionLinux::mockClientHandle, session->clientHandle);
|
||||
EXPECT_EQ(4, handler->ioctlCalled);
|
||||
event = session->apiEvents.front();
|
||||
}
|
||||
|
||||
TEST_F(DebugApiLinuxTest, GivenUuidCommandQueueWhenQueuesOnToSubdevicesCreatedAndDestroyedThenProcessEntryAndExitEventIsGeneratedOnce) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
auto session = std::make_unique<MockDebugSessionLinux>(config, device, 10);
|
||||
ASSERT_NE(nullptr, session);
|
||||
session->clientHandle = MockDebugSessionLinux::mockClientHandle;
|
||||
|
||||
prelim_drm_i915_debug_event_uuid uuid = {};
|
||||
uuid.base.type = PRELIM_DRM_I915_DEBUG_EVENT_UUID;
|
||||
uuid.base.flags = PRELIM_DRM_I915_DEBUG_EVENT_CREATE;
|
||||
uuid.base.size = sizeof(prelim_drm_i915_debug_event_uuid);
|
||||
uuid.client_handle = MockDebugSessionLinux::mockClientHandle;
|
||||
uuid.handle = 2;
|
||||
uuid.payload_size = sizeof(NEO::DebuggerL0::CommandQueueNotification);
|
||||
|
||||
auto uuidHash = NEO::uuidL0CommandQueueHash;
|
||||
prelim_drm_i915_debug_read_uuid readUuid = {};
|
||||
memcpy(readUuid.uuid, uuidHash, strlen(uuidHash));
|
||||
|
||||
NEO::DebuggerL0::CommandQueueNotification notification;
|
||||
notification.subDeviceCount = 2;
|
||||
notification.subDeviceIndex = 1;
|
||||
readUuid.payload_ptr = reinterpret_cast<uint64_t>(¬ification);
|
||||
readUuid.payload_size = sizeof(NEO::DebuggerL0::CommandQueueNotification);
|
||||
readUuid.handle = uuid.handle;
|
||||
|
||||
auto handler = new MockIoctlHandler;
|
||||
session->ioctlHandler.reset(handler);
|
||||
handler->returnUuid = &readUuid;
|
||||
|
||||
// Handle UUID create for commandQueue on subdevice 1
|
||||
session->handleEvent(&uuid.base);
|
||||
EXPECT_EQ(1, handler->ioctlCalled);
|
||||
EXPECT_EQ(1u, session->apiEvents.size());
|
||||
auto event = session->apiEvents.front();
|
||||
EXPECT_EQ(ZET_DEBUG_EVENT_TYPE_PROCESS_ENTRY, event.type);
|
||||
|
||||
EXPECT_EQ(1u, session->uuidL0CommandQueueHandleToDevice.size());
|
||||
|
||||
notification.subDeviceCount = 2;
|
||||
notification.subDeviceIndex = 0;
|
||||
uuid.handle = 3;
|
||||
handler->returnUuid = &readUuid;
|
||||
|
||||
// Handle UUID create for commandQueue on subdevice 0
|
||||
session->handleEvent(&uuid.base);
|
||||
EXPECT_EQ(2, handler->ioctlCalled);
|
||||
EXPECT_EQ(1u, session->apiEvents.size());
|
||||
|
||||
EXPECT_EQ(2u, session->uuidL0CommandQueueHandleToDevice.size());
|
||||
EXPECT_EQ(1u, session->uuidL0CommandQueueHandleToDevice[2]);
|
||||
EXPECT_EQ(0u, session->uuidL0CommandQueueHandleToDevice[3]);
|
||||
|
||||
// Handle UUID destroy for commandQueue on subdevice 0
|
||||
uuid.base.flags = PRELIM_DRM_I915_DEBUG_EVENT_DESTROY;
|
||||
session->handleEvent(&uuid.base);
|
||||
|
||||
EXPECT_EQ(1u, session->uuidL0CommandQueueHandleToDevice.size());
|
||||
EXPECT_EQ(1u, session->apiEvents.size());
|
||||
|
||||
// Handle UUID destroy with invalid uuid handle
|
||||
uuid.handle = 300;
|
||||
session->handleEvent(&uuid.base);
|
||||
EXPECT_EQ(1u, session->uuidL0CommandQueueHandleToDevice.size());
|
||||
|
||||
// Handle UUID destroy for commandQueue on subdevice 1
|
||||
uuid.handle = 2;
|
||||
session->handleEvent(&uuid.base);
|
||||
EXPECT_EQ(0u, session->uuidL0CommandQueueHandleToDevice.size());
|
||||
EXPECT_EQ(2u, session->apiEvents.size());
|
||||
|
||||
session->apiEvents.pop();
|
||||
event = session->apiEvents.front();
|
||||
EXPECT_EQ(ZET_DEBUG_EVENT_TYPE_PROCESS_EXIT, event.type);
|
||||
}
|
||||
|
||||
TEST_F(DebugApiLinuxTest, GivenCommandQueueDestroyedWhenHandlingEventThenExitEventIsGenerated) {
|
||||
@@ -1173,7 +1251,8 @@ TEST_F(DebugApiLinuxTest, GivenCommandQueueDestroyedWhenHandlingEventThenExitEve
|
||||
auto session = std::make_unique<MockDebugSessionLinux>(config, device, 10);
|
||||
ASSERT_NE(nullptr, session);
|
||||
session->clientHandle = DebugSessionLinux::invalidHandle;
|
||||
session->uuidL0CommandQueueHandle = 5;
|
||||
const uint64_t validUuidCmdQHandle = 5u;
|
||||
session->uuidL0CommandQueueHandleToDevice[validUuidCmdQHandle] = 0;
|
||||
|
||||
prelim_drm_i915_debug_event_uuid uuid = {};
|
||||
uuid.base.type = PRELIM_DRM_I915_DEBUG_EVENT_UUID;
|
||||
@@ -1193,7 +1272,7 @@ TEST_F(DebugApiLinuxTest, GivenCommandQueueDestroyedWhenHandlingEventThenExitEve
|
||||
session->handleEvent(&uuid.base);
|
||||
EXPECT_EQ(0u, session->apiEvents.size());
|
||||
|
||||
uuid.handle = session->uuidL0CommandQueueHandle;
|
||||
uuid.handle = validUuidCmdQHandle;
|
||||
session->handleEvent(&uuid.base);
|
||||
EXPECT_EQ(0u, session->apiEvents.size());
|
||||
|
||||
|
||||
@@ -25,6 +25,14 @@ DebugerL0CreateFn debuggerL0Factory[IGFX_MAX_CORE] = {};
|
||||
DebuggerL0::DebuggerL0(NEO::Device *device) : device(device) {
|
||||
isLegacyMode = false;
|
||||
|
||||
const auto deviceCount = std::max(1u, device->getNumSubDevices());
|
||||
commandQueueCount.resize(deviceCount);
|
||||
uuidL0CommandQueueHandle.resize(deviceCount);
|
||||
|
||||
for (uint32_t i = 0; i < deviceCount; i++) {
|
||||
commandQueueCount[i] = 0;
|
||||
uuidL0CommandQueueHandle[i] = 0;
|
||||
}
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace NEO {
|
||||
@@ -91,8 +92,8 @@ class DebuggerL0 : public NEO::Debugger, NEO::NonCopyableOrMovableClass {
|
||||
void captureStateBaseAddress(NEO::LinearStream &cmdStream, SbaAddresses sba) override;
|
||||
void printTrackedAddresses(uint32_t contextId);
|
||||
MOCKABLE_VIRTUAL void registerElf(NEO::DebugData *debugData, NEO::GraphicsAllocation *isaAllocation);
|
||||
MOCKABLE_VIRTUAL void notifyCommandQueueCreated();
|
||||
MOCKABLE_VIRTUAL void notifyCommandQueueDestroyed();
|
||||
MOCKABLE_VIRTUAL void notifyCommandQueueCreated(NEO::Device *device);
|
||||
MOCKABLE_VIRTUAL void notifyCommandQueueDestroyed(NEO::Device *device);
|
||||
MOCKABLE_VIRTUAL void notifyModuleLoadAllocations(const StackVec<NEO::GraphicsAllocation *, 32> &allocs);
|
||||
MOCKABLE_VIRTUAL void notifyModuleCreate(void *module, uint32_t moduleSize, uint64_t moduleLoadAddress);
|
||||
MOCKABLE_VIRTUAL void registerAllocationType(GraphicsAllocation *allocation);
|
||||
@@ -110,6 +111,11 @@ class DebuggerL0 : public NEO::Debugger, NEO::NonCopyableOrMovableClass {
|
||||
}
|
||||
bool getSingleAddressSpaceSbaTracking() { return singleAddressSpaceSbaTracking; }
|
||||
|
||||
struct CommandQueueNotification {
|
||||
uint32_t subDeviceIndex = 0;
|
||||
uint32_t subDeviceCount = 0;
|
||||
};
|
||||
|
||||
protected:
|
||||
static bool isAnyTrackedAddressChanged(SbaAddresses sba) {
|
||||
return sba.GeneralStateBaseAddress != 0 ||
|
||||
@@ -125,12 +131,14 @@ class DebuggerL0 : public NEO::Debugger, NEO::NonCopyableOrMovableClass {
|
||||
std::unordered_map<uint32_t, NEO::GraphicsAllocation *> perContextSbaAllocations;
|
||||
NEO::AddressRange sbaTrackingGpuVa{};
|
||||
NEO::GraphicsAllocation *moduleDebugArea = nullptr;
|
||||
std::atomic<uint32_t> commandQueueCount = 0u;
|
||||
uint32_t uuidL0CommandQueueHandle = 0;
|
||||
std::vector<uint32_t> commandQueueCount;
|
||||
std::vector<uint32_t> uuidL0CommandQueueHandle;
|
||||
bool singleAddressSpaceSbaTracking = false;
|
||||
std::mutex debuggerL0Mutex;
|
||||
};
|
||||
|
||||
static_assert(std::is_standard_layout<DebuggerL0::CommandQueueNotification>::value, "DebuggerL0::CommandQueueNotification issue");
|
||||
|
||||
using DebugerL0CreateFn = DebuggerL0 *(*)(NEO::Device *device);
|
||||
extern DebugerL0CreateFn debuggerL0Factory[];
|
||||
|
||||
|
||||
@@ -64,20 +64,31 @@ bool DebuggerL0::removeZebinModule(uint32_t moduleHandle) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void DebuggerL0::notifyCommandQueueCreated() {
|
||||
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
|
||||
if (++commandQueueCount == 1) {
|
||||
auto drm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
|
||||
uuidL0CommandQueueHandle = drm->notifyFirstCommandQueueCreated();
|
||||
void DebuggerL0::notifyCommandQueueCreated(NEO::Device *device) {
|
||||
if (this->device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
|
||||
std::unique_lock<std::mutex> commandQueueCountLock(debuggerL0Mutex);
|
||||
|
||||
auto index = device->isSubDevice() ? static_cast<NEO::SubDevice *>(device)->getSubDeviceIndex() : 0;
|
||||
|
||||
if (++commandQueueCount[index] == 1) {
|
||||
auto drm = this->device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
|
||||
|
||||
CommandQueueNotification notification = {index, this->device->getNumSubDevices()};
|
||||
uuidL0CommandQueueHandle[index] = drm->notifyFirstCommandQueueCreated(¬ification, sizeof(CommandQueueNotification));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerL0::notifyCommandQueueDestroyed() {
|
||||
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
|
||||
if (--commandQueueCount == 0) {
|
||||
auto drm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
|
||||
drm->notifyLastCommandQueueDestroyed(uuidL0CommandQueueHandle);
|
||||
void DebuggerL0::notifyCommandQueueDestroyed(NEO::Device *device) {
|
||||
if (this->device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
|
||||
std::unique_lock<std::mutex> commandQueueCountLock(debuggerL0Mutex);
|
||||
|
||||
auto index = device->isSubDevice() ? static_cast<NEO::SubDevice *>(device)->getSubDeviceIndex() : 0;
|
||||
|
||||
if (--commandQueueCount[index] == 0) {
|
||||
auto drm = this->device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Drm>();
|
||||
drm->notifyLastCommandQueueDestroyed(uuidL0CommandQueueHandle[index]);
|
||||
uuidL0CommandQueueHandle[index] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,10 +186,10 @@ static NTSTATUS runEscape(NEO::Wddm *wddm, KM_ESCAPE_INFO &escapeInfo) {
|
||||
return wddm->escape(escapeCommand);
|
||||
}
|
||||
|
||||
void DebuggerL0::notifyCommandQueueCreated() {
|
||||
void DebuggerL0::notifyCommandQueueCreated(NEO::Device *deviceIn) {
|
||||
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
|
||||
std::unique_lock<std::mutex> commandQueueCountLock(debuggerL0Mutex);
|
||||
if (++commandQueueCount == 1) {
|
||||
if (++commandQueueCount[0] == 1) {
|
||||
auto pWddm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Wddm>();
|
||||
int val = 0;
|
||||
KM_ESCAPE_INFO escapeInfo = {0};
|
||||
@@ -202,10 +202,10 @@ void DebuggerL0::notifyCommandQueueCreated() {
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerL0::notifyCommandQueueDestroyed() {
|
||||
void DebuggerL0::notifyCommandQueueDestroyed(NEO::Device *deviceIn) {
|
||||
if (device->getRootDeviceEnvironment().osInterface.get() != nullptr) {
|
||||
std::unique_lock<std::mutex> commandQueueCountLock(debuggerL0Mutex);
|
||||
if (--commandQueueCount == 0) {
|
||||
if (--commandQueueCount[0] == 0) {
|
||||
auto pWddm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<NEO::Wddm>();
|
||||
int val = 0;
|
||||
KM_ESCAPE_INFO escapeInfo = {0};
|
||||
|
||||
@@ -109,8 +109,8 @@ void Drm::setContextDebugFlag(uint32_t drmContextId) {
|
||||
DEBUG_BREAK_IF(retVal != 0 && contextDebugSupported);
|
||||
}
|
||||
|
||||
uint32_t Drm::notifyFirstCommandQueueCreated() {
|
||||
const auto result = ioctlHelper->registerStringClassUuid(uuidL0CommandQueueHash, (uintptr_t)uuidL0CommandQueueName, strnlen_s(uuidL0CommandQueueName, 100));
|
||||
uint32_t Drm::notifyFirstCommandQueueCreated(const void *data, size_t size) {
|
||||
const auto result = ioctlHelper->registerStringClassUuid(uuidL0CommandQueueHash, (uintptr_t)data, size);
|
||||
DEBUG_BREAK_IF(result.retVal);
|
||||
return result.handle;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ class Drm : public DriverModel {
|
||||
|
||||
MOCKABLE_VIRTUAL bool completionFenceSupport();
|
||||
|
||||
MOCKABLE_VIRTUAL uint32_t notifyFirstCommandQueueCreated();
|
||||
MOCKABLE_VIRTUAL uint32_t notifyFirstCommandQueueCreated(const void *data, size_t size);
|
||||
MOCKABLE_VIRTUAL void notifyLastCommandQueueDestroyed(uint32_t handle);
|
||||
|
||||
uint64_t getPatIndex(Gmm *gmm, AllocationType allocationType, CacheRegion cacheRegion, CachePolicy cachePolicy, bool closEnabled) const;
|
||||
|
||||
@@ -337,7 +337,7 @@ class DrmMockResources : public DrmMock {
|
||||
return bindAvailable;
|
||||
}
|
||||
|
||||
uint32_t notifyFirstCommandQueueCreated() override {
|
||||
uint32_t notifyFirstCommandQueueCreated(const void *data, size_t size) override {
|
||||
ioctlCallsCount++;
|
||||
return 4;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ class MockDebuggerL0Hw : public NEO::DebuggerL0Hw<GfxFamily> {
|
||||
using NEO::DebuggerL0::perContextSbaAllocations;
|
||||
using NEO::DebuggerL0::sbaTrackingGpuVa;
|
||||
using NEO::DebuggerL0::singleAddressSpaceSbaTracking;
|
||||
using NEO::DebuggerL0::uuidL0CommandQueueHandle;
|
||||
|
||||
MockDebuggerL0Hw(NEO::Device *device) : NEO::DebuggerL0Hw<GfxFamily>(device) {}
|
||||
~MockDebuggerL0Hw() override = default;
|
||||
@@ -80,14 +81,14 @@ class MockDebuggerL0Hw : public NEO::DebuggerL0Hw<GfxFamily> {
|
||||
return NEO::DebuggerL0Hw<GfxFamily>::removeZebinModule(moduleHandle);
|
||||
}
|
||||
|
||||
void notifyCommandQueueCreated() override {
|
||||
void notifyCommandQueueCreated(NEO::Device *device) override {
|
||||
commandQueueCreatedCount++;
|
||||
NEO::DebuggerL0Hw<GfxFamily>::notifyCommandQueueCreated();
|
||||
NEO::DebuggerL0Hw<GfxFamily>::notifyCommandQueueCreated(device);
|
||||
}
|
||||
|
||||
void notifyCommandQueueDestroyed() override {
|
||||
void notifyCommandQueueDestroyed(NEO::Device *device) override {
|
||||
commandQueueDestroyedCount++;
|
||||
NEO::DebuggerL0Hw<GfxFamily>::notifyCommandQueueDestroyed();
|
||||
NEO::DebuggerL0Hw<GfxFamily>::notifyCommandQueueDestroyed(device);
|
||||
}
|
||||
|
||||
void registerAllocationType(NEO::GraphicsAllocation *allocation) override {
|
||||
|
||||
@@ -143,7 +143,7 @@ TEST_F(DrmDebugPrelimTest, GivenDrmWhenNotifyFirstCommandQueueCreatedCalledThenC
|
||||
DrmQueryMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
auto handle = drm.context.uuidHandle;
|
||||
auto registeredHandle = drm.notifyFirstCommandQueueCreated();
|
||||
auto registeredHandle = drm.notifyFirstCommandQueueCreated(nullptr, 0);
|
||||
|
||||
EXPECT_EQ(handle + 1, drm.context.uuidHandle);
|
||||
EXPECT_EQ(handle, registeredHandle);
|
||||
@@ -151,8 +151,7 @@ TEST_F(DrmDebugPrelimTest, GivenDrmWhenNotifyFirstCommandQueueCreatedCalledThenC
|
||||
const auto &receivedUuid = drm.context.receivedRegisterUuid;
|
||||
ASSERT_TRUE(receivedUuid);
|
||||
EXPECT_EQ(DrmPrelimHelper::getStringUuidClass(), receivedUuid->uuidClass);
|
||||
EXPECT_EQ(receivedUuid->size, strlen(uuidL0CommandQueueName));
|
||||
EXPECT_EQ(0, memcmp(reinterpret_cast<const char *>(receivedUuid->ptr), uuidL0CommandQueueName, receivedUuid->size));
|
||||
EXPECT_EQ(receivedUuid->size, 0u);
|
||||
EXPECT_EQ(0, memcmp(receivedUuid->uuid, uuidL0CommandQueueHash, sizeof(receivedUuid->uuid)));
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ TEST_F(DrmDebugTest, whenNotifyCommandQueueCreateDestroyAreCalledThenImplementat
|
||||
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drmMock.ioctlCallsCount = 0;
|
||||
|
||||
auto handle = drmMock.notifyFirstCommandQueueCreated();
|
||||
auto handle = drmMock.notifyFirstCommandQueueCreated(nullptr, 0);
|
||||
EXPECT_EQ(0u, handle);
|
||||
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user