Create L0 debugger object

Related-To: NEO-4713

Change-Id: I9d10019bbe6e8514ce10bdd729a64ea233bf91b0
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2020-06-18 17:08:55 +02:00
committed by sys_ocldev
parent 3029db07c3
commit 68847ef942
26 changed files with 300 additions and 10 deletions

View File

@@ -10,4 +10,5 @@ set(L0_SRCS_DEBUGGER
${CMAKE_CURRENT_SOURCE_DIR}/debugger_l0.h
)
set_property(GLOBAL PROPERTY L0_SRCS_DEBUGGER ${L0_SRCS_DEBUGGER})
add_subdirectories()
set_property(GLOBAL PROPERTY L0_SRCS_DEBUGGER ${L0_SRCS_DEBUGGER})

View File

@@ -6,13 +6,27 @@
*/
#pragma once
#include "shared/source/debugger/debugger.h"
#include "shared/source/helpers/non_copyable_or_moveable.h"
#include <memory>
namespace NEO {
class Device;
}
namespace L0 {
class DebuggerL0 : public NEO::Debugger {
class DebuggerL0 : public NEO::Debugger, NEO::NonCopyableOrMovableClass {
public:
static std::unique_ptr<Debugger> create(NEO::Device *device);
bool isDebuggerActive() override;
DebuggerL0(NEO::Device *device) : device(device) {
isLegacyMode = false;
}
~DebuggerL0() override = default;
protected:
NEO::Device *device = nullptr;
};
} // namespace L0

View File

@@ -0,0 +1,13 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(L0_SRCS_DEBUGGER_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/debugger_l0_linux.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debugger_l0_linux.h
)
set_property(GLOBAL PROPERTY L0_SRCS_DEBUGGER_LINUX ${L0_SRCS_DEBUGGER_LINUX})

View File

@@ -0,0 +1,15 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/core/source/debugger/linux/debugger_l0_linux.h"
namespace L0 {
std::unique_ptr<NEO::Debugger> DebuggerL0::create(NEO::Device *device) {
return std::make_unique<DebuggerL0Linux>(device);
}
} // namespace L0

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "level_zero/core/source/debugger/debugger_l0.h"
namespace L0 {
class DebuggerL0Linux : public DebuggerL0 {
public:
DebuggerL0Linux(NEO::Device *device) : DebuggerL0(device) {
}
~DebuggerL0Linux() override = default;
};
} // namespace L0

View File

@@ -0,0 +1,14 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(L0_SRCS_DEBUGGER_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/debugger_l0_windows.cpp
)
if(WIN32)
set_property(GLOBAL PROPERTY L0_SRCS_DEBUGGER_WINDOWS ${L0_SRCS_DEBUGGER_WINDOWS})
endif()

View File

@@ -0,0 +1,14 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/core/source/debugger/debugger_l0.h"
namespace L0 {
std::unique_ptr<NEO::Debugger> DebuggerL0::create(NEO::Device *device) {
return std::unique_ptr<NEO::Debugger>(nullptr);
}
} // namespace L0

View File

@@ -106,10 +106,8 @@ struct Device : _ze_device_handle_t {
virtual NEO::PreemptionMode getDevicePreemptionMode() const = 0;
virtual const NEO::DeviceInfo &getDeviceInfo() const = 0;
virtual NEO::Device *getNEODevice() = 0;
NEO::SourceLevelDebugger *getSourceLevelDebugger() { return getNEODevice()->getSourceLevelDebugger(); }
NEO::SourceLevelDebugger *getSourceLevelDebugger() {
return getNEODevice() ? reinterpret_cast<NEO::SourceLevelDebugger *>(getNEODevice()->getDebugger()) : nullptr;
}
virtual NEO::GraphicsAllocation *getDebugSurface() const = 0;
virtual NEO::GraphicsAllocation *allocateManagedMemoryFromHostPtr(void *buffer,

View File

@@ -13,6 +13,7 @@
#include "shared/source/os_interface/debug_env_reader.h"
#include "shared/source/os_interface/os_library.h"
#include "level_zero/core/source/debugger/debugger_l0.h"
#include "level_zero/core/source/device/device_imp.h"
#include "driver_version_l0.h"
@@ -108,6 +109,10 @@ ze_result_t DriverHandleImp::getMemAllocProperties(const void *ptr,
DriverHandleImp::~DriverHandleImp() {
for (auto &device : this->devices) {
if (device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->debugger.get() &&
!device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->debugger->isLegacy()) {
device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->debugger.reset(nullptr);
}
delete device;
}
if (this->svmAllocsManager) {
@@ -149,6 +154,11 @@ ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>
}
}
if (enableProgramDebugging) {
UNRECOVERABLE_IF(neoDevice->getDebugger() != nullptr && enableProgramDebugging);
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->debugger = DebuggerL0::create(neoDevice.get());
}
auto device = Device::create(this, neoDevice.release(), currentDeviceMask, false);
this->devices.push_back(device);
}