mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
Add Debug API handlers
Related-To: NEO-4554 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4764cbd9d3
commit
8f87dfaf0c
@@ -5,13 +5,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/device/device.h"
|
||||
#include "level_zero/tools/source/debug/debug_handlers.h"
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
ZE_APIEXPORT ze_result_t ZE_APICALL
|
||||
zetDeviceGetDebugProperties(
|
||||
zet_device_handle_t hDevice,
|
||||
zet_device_debug_properties_t *pDebugProperties) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
return L0::Device::fromHandle(hDevice)->getDebugProperties(pDebugProperties);
|
||||
}
|
||||
|
||||
ZE_APIEXPORT ze_result_t ZE_APICALL
|
||||
@@ -19,7 +21,7 @@ zetDebugAttach(
|
||||
zet_device_handle_t hDevice,
|
||||
const zet_debug_config_t *config,
|
||||
zet_debug_session_handle_t *phDebug) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
return L0::debugAttach(hDevice, config, phDebug);
|
||||
}
|
||||
|
||||
ZE_APIEXPORT ze_result_t ZE_APICALL
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -36,6 +36,7 @@ struct BuiltinFunctionsLib;
|
||||
struct ExecutionEnvironment;
|
||||
struct MetricContext;
|
||||
struct SysmanDevice;
|
||||
struct DebugSession;
|
||||
|
||||
enum class ModuleType;
|
||||
|
||||
@@ -72,6 +73,8 @@ struct Device : _ze_device_handle_t {
|
||||
|
||||
virtual ze_result_t getCommandQueueGroupProperties(uint32_t *pCount,
|
||||
ze_command_queue_group_properties_t *pCommandQueueGroupProperties) = 0;
|
||||
virtual ze_result_t getDebugProperties(zet_device_debug_properties_t *pDebugProperties) = 0;
|
||||
|
||||
virtual ze_result_t systemBarrier() = 0;
|
||||
|
||||
virtual ~Device() = default;
|
||||
@@ -87,6 +90,7 @@ struct Device : _ze_device_handle_t {
|
||||
virtual NEO::OSInterface &getOsInterface() = 0;
|
||||
virtual uint32_t getPlatformInfo() const = 0;
|
||||
virtual MetricContext &getMetricContext() = 0;
|
||||
virtual DebugSession *getDebugSession(const zet_debug_config_t &config) = 0;
|
||||
|
||||
virtual ze_result_t activateMetricGroups(uint32_t count,
|
||||
zet_metric_group_handle_t *phMetricGroups) = 0;
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "level_zero/core/source/module/module.h"
|
||||
#include "level_zero/core/source/printf_handler/printf_handler.h"
|
||||
#include "level_zero/core/source/sampler/sampler.h"
|
||||
#include "level_zero/tools/source/debug/debug_session.h"
|
||||
#include "level_zero/tools/source/metrics/metric.h"
|
||||
#include "level_zero/tools/source/sysman/sysman.h"
|
||||
|
||||
@@ -486,6 +487,16 @@ ze_result_t DeviceImp::getDeviceImageProperties(ze_device_image_properties_t *pD
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::getDebugProperties(zet_device_debug_properties_t *pDebugProperties) {
|
||||
bool isDebugAttachAvailable = getOsInterface().isDebugAttachAvailable();
|
||||
if (isDebugAttachAvailable && !isSubdevice) {
|
||||
pDebugProperties->flags = zet_device_debug_property_flag_t::ZET_DEVICE_DEBUG_PROPERTY_FLAG_ATTACH;
|
||||
} else {
|
||||
pDebugProperties->flags = 0;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DeviceImp::systemBarrier() { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; }
|
||||
|
||||
ze_result_t DeviceImp::activateMetricGroups(uint32_t count,
|
||||
@@ -799,4 +810,17 @@ ze_result_t DeviceImp::mapOrdinalForAvailableEngineGroup(uint32_t *ordinal) {
|
||||
*ordinal = i - 1;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
};
|
||||
|
||||
DebugSession *DeviceImp::getDebugSession(const zet_debug_config_t &config) {
|
||||
if (debugSession != nullptr) {
|
||||
return debugSession.get();
|
||||
}
|
||||
|
||||
if (!this->isSubdevice) {
|
||||
auto session = DebugSession::create(config, this);
|
||||
debugSession.reset(session);
|
||||
}
|
||||
return debugSession.get();
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -12,10 +12,12 @@
|
||||
#include "level_zero/core/source/device/device.h"
|
||||
#include "level_zero/core/source/driver/driver_handle.h"
|
||||
#include "level_zero/core/source/module/module.h"
|
||||
#include "level_zero/tools/source/debug/debug_session.h"
|
||||
#include "level_zero/tools/source/metrics/metric.h"
|
||||
|
||||
namespace L0 {
|
||||
struct SysmanDevice;
|
||||
|
||||
struct DeviceImp : public Device {
|
||||
uint32_t getRootDeviceIndex() override;
|
||||
ze_result_t canAccessPeer(ze_device_handle_t hPeerDevice, ze_bool_t *value) override;
|
||||
@@ -44,6 +46,8 @@ struct DeviceImp : public Device {
|
||||
ze_result_t getCommandQueueGroupProperties(uint32_t *pCount,
|
||||
ze_command_queue_group_properties_t *pCommandQueueGroupProperties) override;
|
||||
ze_result_t getExternalMemoryProperties(ze_device_external_memory_properties_t *pExternalMemoryProperties) override;
|
||||
ze_result_t getDebugProperties(zet_device_debug_properties_t *pDebugProperties) override;
|
||||
|
||||
ze_result_t systemBarrier() override;
|
||||
void *getExecEnvironment() override;
|
||||
BuiltinFunctionsLib *getBuiltinFunctionsLib() override;
|
||||
@@ -54,6 +58,8 @@ struct DeviceImp : public Device {
|
||||
NEO::OSInterface &getOsInterface() override;
|
||||
uint32_t getPlatformInfo() const override;
|
||||
MetricContext &getMetricContext() override;
|
||||
DebugSession *getDebugSession(const zet_debug_config_t &config) override;
|
||||
|
||||
uint32_t getMaxNumHwThreads() const override;
|
||||
ze_result_t activateMetricGroups(uint32_t count,
|
||||
zet_metric_group_handle_t *phMetricGroups) override;
|
||||
@@ -95,6 +101,7 @@ struct DeviceImp : public Device {
|
||||
protected:
|
||||
NEO::GraphicsAllocation *debugSurface = nullptr;
|
||||
SysmanDevice *pSysmanDevice = nullptr;
|
||||
std::unique_ptr<DebugSession> debugSession = nullptr;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
|
||||
#include "level_zero/tools/source/debug/debug_session.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -242,11 +242,20 @@ struct Mock<Device> : public Device {
|
||||
ze_result_t mapOrdinalForAvailableEngineGroup(uint32_t *ordinal) override {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getDebugProperties(zet_device_debug_properties_t *properties) override {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
DebugSession *getDebugSession(const zet_debug_config_t &config) override {
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Mock<L0::DeviceImp> : public L0::DeviceImp {
|
||||
using Base = L0::DeviceImp;
|
||||
using Base::debugSession;
|
||||
|
||||
explicit Mock(NEO::Device *device, NEO::ExecutionEnvironment *execEnv) {
|
||||
device->incRefInternal();
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "opencl/test/unit_test/global_environment.h"
|
||||
#include "opencl/test/unit_test/helpers/kernel_binary_helper.h"
|
||||
|
||||
#include "level_zero/tools/source/debug/debug_session.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
template <bool useImagesBuiltins>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#
|
||||
# Copyright (C) 2019-2020 Intel Corporation
|
||||
# Copyright (C) 2019-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
add_subdirectory(debug)
|
||||
add_subdirectory(metrics)
|
||||
add_subdirectory(sysman)
|
||||
add_subdirectory(pin)
|
||||
|
||||
19
level_zero/tools/source/debug/CMakeLists.txt
Normal file
19
level_zero/tools/source/debug/CMakeLists.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright (C) 2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_SRCS_TOOLS_DEBUG
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_session.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_handlers.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/debug_handlers.cpp
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${L0_SRCS_TOOLS_DEBUG}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
)
|
||||
20
level_zero/tools/source/debug/debug_handlers.cpp
Normal file
20
level_zero/tools/source/debug/debug_handlers.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/source/debug/debug_session.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
DebugSession *DebugSession::create(const zet_debug_config_t &config, Device *device) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ze_result_t debugAttach(zet_device_handle_t hDevice, const zet_debug_config_t *config, zet_debug_session_handle_t *phDebug) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
13
level_zero/tools/source/debug/debug_handlers.h
Normal file
13
level_zero/tools/source/debug/debug_handlers.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
namespace L0 {
|
||||
ze_result_t debugAttach(zet_device_handle_t hDevice, const zet_debug_config_t *config, zet_debug_session_handle_t *phDebug);
|
||||
}
|
||||
30
level_zero/tools/source/debug/debug_session.h
Normal file
30
level_zero/tools/source/debug/debug_session.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
struct _zet_debug_session_handle_t {};
|
||||
|
||||
namespace L0 {
|
||||
|
||||
struct Device;
|
||||
|
||||
struct DebugSession : _zet_debug_session_handle_t {
|
||||
virtual ~DebugSession() = default;
|
||||
DebugSession() = delete;
|
||||
|
||||
static DebugSession *create(const zet_debug_config_t &config, Device *device);
|
||||
|
||||
static DebugSession *fromHandle(zet_debug_session_handle_t handle) { return static_cast<DebugSession *>(handle); }
|
||||
inline zet_debug_session_handle_t toHandle() { return this; }
|
||||
|
||||
protected:
|
||||
DebugSession(const zet_debug_config_t &config, Device *device){};
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Copyright (C) 2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_debug_session.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/test_debug_api.cpp
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/tools/source/debug/debug_session.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
class OsInterfaceWithDebugAttach : public NEO::OSInterface {
|
||||
public:
|
||||
OsInterfaceWithDebugAttach() : OSInterface() {}
|
||||
bool isDebugAttachAvailable() const override {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct DebugSessionMock : public L0::DebugSession {
|
||||
DebugSessionMock(const zet_debug_config_t &config, L0::Device *device) : DebugSession(config, device){};
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/test/unit_tests/sources/debug/test_debug_api.inl"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
TEST_F(DebugApiTest, givenDeviceWhenDebugAttachIsCalledThenNullptrSessionHandleAndErrorAreReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
|
||||
zet_debug_session_handle_t debugSession = nullptr;
|
||||
auto result = zetDebugAttach(deviceImp.toHandle(), &config, &debugSession);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
|
||||
EXPECT_EQ(nullptr, debugSession);
|
||||
}
|
||||
|
||||
TEST_F(DebugApiTest, givenDebugSessionSetWhenGettingDebugSessionThenCorrectObjectIsReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
deviceImp.debugSession = std::make_unique<DebugSessionMock>(config, &deviceImp);
|
||||
|
||||
EXPECT_NE(nullptr, deviceImp.getDebugSession(config));
|
||||
}
|
||||
|
||||
TEST_F(DebugApiTest, givenNoDebugSessionWhenGettingDebugSessionThenNullptrIsReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
deviceImp.debugSession.release();
|
||||
EXPECT_EQ(nullptr, deviceImp.getDebugSession(config));
|
||||
}
|
||||
|
||||
TEST_F(DebugApiTest, givenSubdeviceWhenGettingDebugSessionThenNullptrIsReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
deviceImp.isSubdevice = true;
|
||||
EXPECT_EQ(nullptr, deviceImp.getDebugSession(config));
|
||||
}
|
||||
|
||||
TEST(DebugSessionTest, WhenDebugSessionCreateIsCalledThenNullptrReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
L0::DebugSession *session = L0::DebugSession::create(config, nullptr);
|
||||
EXPECT_EQ(nullptr, session);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/os_interface/linux/os_interface.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
struct DebugApiFixture : public DeviceFixture {
|
||||
void SetUp() {
|
||||
DeviceFixture::SetUp();
|
||||
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new NEO::OSInterface);
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
using DebugApiTest = Test<DebugApiFixture>;
|
||||
|
||||
TEST_F(DebugApiTest, givenDeviceWhenGettingDebugPropertiesThenNoFlagIsSet) {
|
||||
zet_device_debug_properties_t debugProperties = {};
|
||||
debugProperties.flags = ZET_DEVICE_DEBUG_PROPERTY_FLAG_FORCE_UINT32;
|
||||
|
||||
auto result = zetDeviceGetDebugProperties(device->toHandle(), &debugProperties);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(0u, debugProperties.flags);
|
||||
}
|
||||
|
||||
TEST_F(DebugApiTest, givenDeviceWhenCallingDebugAttachThenErrorIsReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
zet_debug_session_handle_t debugSession = nullptr;
|
||||
|
||||
auto result = zetDebugAttach(device->toHandle(), &config, &debugSession);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
|
||||
EXPECT_EQ(nullptr, debugSession);
|
||||
}
|
||||
|
||||
TEST_F(DebugApiTest, givenSubDeviceWhenCallingDebugAttachThenErrorIsReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
zet_debug_session_handle_t debugSession = nullptr;
|
||||
|
||||
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
deviceImp.isSubdevice = true;
|
||||
|
||||
auto result = zetDebugAttach(deviceImp.toHandle(), &config, &debugSession);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
|
||||
EXPECT_EQ(nullptr, debugSession);
|
||||
}
|
||||
|
||||
TEST_F(DebugApiTest, givenDeviceWhenDebugAttachIsAvaialbleThenGetPropertiesReturnsCorrectFlag) {
|
||||
zet_device_debug_properties_t debugProperties = {};
|
||||
debugProperties.flags = ZET_DEVICE_DEBUG_PROPERTY_FLAG_FORCE_UINT32;
|
||||
|
||||
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new OsInterfaceWithDebugAttach);
|
||||
|
||||
auto result = zetDeviceGetDebugProperties(device->toHandle(), &debugProperties);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(ZET_DEVICE_DEBUG_PROPERTY_FLAG_ATTACH, debugProperties.flags);
|
||||
}
|
||||
|
||||
TEST_F(DebugApiTest, givenSubDeviceWhenDebugAttachIsAvaialbleThenGetPropertiesReturnsNoFlag) {
|
||||
zet_device_debug_properties_t debugProperties = {};
|
||||
debugProperties.flags = ZET_DEVICE_DEBUG_PROPERTY_FLAG_FORCE_UINT32;
|
||||
|
||||
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new OsInterfaceWithDebugAttach);
|
||||
|
||||
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
deviceImp.isSubdevice = true;
|
||||
|
||||
auto result = zetDeviceGetDebugProperties(deviceImp.toHandle(), &debugProperties);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(0u, debugProperties.flags);
|
||||
}
|
||||
|
||||
TEST(DebugSessionTest, givenDebugSessionWhenConvertingToAndFromHandleCorrectHandleAndPointerIsReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
NEO::Device *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get(), 0));
|
||||
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
auto debugSession = std::make_unique<DebugSessionMock>(config, &deviceImp);
|
||||
L0::DebugSession *session = debugSession.get();
|
||||
|
||||
zet_debug_session_handle_t debugSessionHandle = debugSession->toHandle();
|
||||
auto sessionFromHandle = L0::DebugSession::fromHandle(session);
|
||||
|
||||
EXPECT_NE(nullptr, debugSessionHandle);
|
||||
EXPECT_EQ(session, sessionFromHandle);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -104,6 +104,13 @@ class DrmMock : public Drm {
|
||||
return Drm::setContextDebugFlag(drmContextId);
|
||||
}
|
||||
|
||||
bool isDebugAttachAvailable() override {
|
||||
if (allowDebugAttachCallBase) {
|
||||
return Drm::isDebugAttachAvailable();
|
||||
}
|
||||
return allowDebugAttach;
|
||||
}
|
||||
|
||||
static const int mockFd = 33;
|
||||
|
||||
bool failRetTopology = false;
|
||||
@@ -136,6 +143,8 @@ class DrmMock : public Drm {
|
||||
int StoredRetValForVmId = 1;
|
||||
|
||||
bool disableSomeTopology = false;
|
||||
bool allowDebugAttach = false;
|
||||
bool allowDebugAttachCallBase = false;
|
||||
uint32_t passedContextDebugId = uint32_t(-1);
|
||||
|
||||
uint32_t receivedContextCreateFlags = 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
TEST(OsInterfaceTest, GivenLinuxWhenare64kbPagesEnabledThenFalse) {
|
||||
TEST(OsInterfaceTest, GivenLinuxWhenCallingAre64kbPagesEnabledThenReturnFalse) {
|
||||
EXPECT_FALSE(OSInterface::are64kbPagesEnabled());
|
||||
}
|
||||
|
||||
TEST(OsInterfaceTest, GivenLinuxOsInterfaceWhenDeviceHandleQueriedthenZeroIsReturned) {
|
||||
TEST(OsInterfaceTest, GivenLinuxOsInterfaceWhenDeviceHandleQueriedThenZeroIsReturned) {
|
||||
OSInterface osInterface;
|
||||
EXPECT_EQ(0u, osInterface.getDeviceHandle());
|
||||
}
|
||||
@@ -35,4 +35,15 @@ TEST(OsInterfaceTest, GivenLinuxOsWhenCheckForGpuIdleImplicitFlushSupportThenRet
|
||||
EXPECT_TRUE(OSInterface::gpuIdleImplicitFlush);
|
||||
}
|
||||
|
||||
TEST(OsInterfaceTest, GivenLinuxOsInterfaceWhenCallingIsDebugAttachAvailableThenFalseIsReturned) {
|
||||
OSInterface osInterface;
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock *drm = new DrmMock(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
osInterface.get()->setDrm(drm);
|
||||
EXPECT_FALSE(osInterface.isDebugAttachAvailable());
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -137,6 +137,8 @@ class Drm {
|
||||
MOCKABLE_VIRTUAL void unregisterResource(uint32_t handle);
|
||||
MOCKABLE_VIRTUAL uint32_t registerIsaCookie(uint32_t isaHandle);
|
||||
|
||||
MOCKABLE_VIRTUAL bool isDebugAttachAvailable();
|
||||
|
||||
SystemInfo *getSystemInfo() const {
|
||||
return systemInfo.get();
|
||||
}
|
||||
|
||||
@@ -23,4 +23,8 @@ bool Drm::queryTopology(const HardwareInfo &hwInfo, int &sliceCount, int &subSli
|
||||
return translateTopologyInfo(data, sliceCount, subSliceCount, euCount);
|
||||
}
|
||||
|
||||
bool Drm::isDebugAttachAvailable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -26,6 +26,13 @@ void OSInterface::OSInterfaceImpl::setDrm(Drm *drm) {
|
||||
this->drm.reset(drm);
|
||||
}
|
||||
|
||||
bool OSInterface::OSInterfaceImpl::isDebugAttachAvailable() const {
|
||||
if (drm) {
|
||||
return drm->isDebugAttachAvailable();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
OSInterface::OSInterface() {
|
||||
osInterfaceImpl = new OSInterfaceImpl();
|
||||
}
|
||||
@@ -42,6 +49,10 @@ uint32_t OSInterface::getDeviceHandle() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool OSInterface::isDebugAttachAvailable() const {
|
||||
return osInterfaceImpl->isDebugAttachAvailable();
|
||||
}
|
||||
|
||||
bool RootDeviceEnvironment::initOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootDeviceIndex) {
|
||||
Drm *drm = Drm::create(std::move(hwDeviceId), *this);
|
||||
if (!drm) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -22,6 +22,8 @@ class OSInterface::OSInterfaceImpl {
|
||||
}
|
||||
void setDrm(Drm *drm);
|
||||
|
||||
bool isDebugAttachAvailable() const;
|
||||
|
||||
protected:
|
||||
std::unique_ptr<Drm> drm;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -26,6 +26,8 @@ class OSInterface {
|
||||
OSInterfaceImpl *get() const {
|
||||
return osInterfaceImpl;
|
||||
};
|
||||
|
||||
MOCKABLE_VIRTUAL bool isDebugAttachAvailable() const;
|
||||
static bool osEnabled64kbPages;
|
||||
static bool osEnableLocalMemory;
|
||||
static bool are64kbPagesEnabled();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -30,6 +30,10 @@ uint32_t OSInterface::getDeviceHandle() const {
|
||||
return static_cast<uint32_t>(osInterfaceImpl->getDeviceHandle());
|
||||
}
|
||||
|
||||
bool OSInterface::isDebugAttachAvailable() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
OSInterface::OSInterfaceImpl::OSInterfaceImpl() = default;
|
||||
|
||||
D3DKMT_HANDLE OSInterface::OSInterfaceImpl::getAdapterHandle() const {
|
||||
|
||||
@@ -34,3 +34,12 @@ TEST(DrmQueryTest, GivenGtMaxFreqFileExistsWhenFrequencyIsQueriedThenValidValueI
|
||||
|
||||
EXPECT_EQ(expectedMaxFrequency, maxFrequency);
|
||||
}
|
||||
|
||||
TEST(DrmQueryTest, WhenCallingIsDebugAttachAvailableThenReturnValueIsFalse) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
drm.allowDebugAttachCallBase = true;
|
||||
|
||||
EXPECT_FALSE(drm.isDebugAttachAvailable());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user