mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 05:24:02 +08:00
Refactor L0 core tests
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f518dd60dc
commit
d3f3730989
@@ -30,6 +30,8 @@ namespace L0 {
|
||||
|
||||
struct DriverHandleImp *GlobalDriver;
|
||||
|
||||
DriverHandleImp::DriverHandleImp() = default;
|
||||
|
||||
ze_result_t DriverHandleImp::createContext(const ze_context_desc_t *desc,
|
||||
ze_context_handle_t *phContext) {
|
||||
ContextImp *context = new ContextImp(this);
|
||||
|
||||
@@ -18,6 +18,8 @@ class HostPointerManager;
|
||||
|
||||
struct DriverHandleImp : public DriverHandle {
|
||||
~DriverHandleImp() override;
|
||||
DriverHandleImp();
|
||||
|
||||
ze_result_t createContext(const ze_context_desc_t *desc, ze_context_handle_t *phContext) override;
|
||||
ze_result_t getDevice(uint32_t *pCount, ze_device_handle_t *phDevices) override;
|
||||
ze_result_t getProperties(ze_driver_properties_t *properties) override;
|
||||
|
||||
@@ -120,6 +120,7 @@ target_link_libraries(${TARGET_NAME}
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
$<TARGET_OBJECTS:mock_gmm>
|
||||
$<TARGET_OBJECTS:${TARGET_NAME_L0}_fixtures>
|
||||
$<TARGET_OBJECTS:${TARGET_NAME_L0}_mocks>
|
||||
$<TARGET_OBJECTS:${BUILTINS_SPIRV_LIB_NAME}>
|
||||
$<TARGET_OBJECTS:${BUILTINS_BINARIES_BINDFUL_LIB_NAME}>
|
||||
|
||||
@@ -7,8 +7,55 @@
|
||||
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_context.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_device.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
void DeviceFixture::SetUp() { // NOLINT(readability-identifier-naming)
|
||||
neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get());
|
||||
auto mockBuiltIns = new MockBuiltins();
|
||||
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltIns);
|
||||
NEO::DeviceVector devices;
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
device = driverHandle->devices[0];
|
||||
}
|
||||
|
||||
void DeviceFixture::TearDown() { // NOLINT(readability-identifier-naming)
|
||||
}
|
||||
|
||||
void MultiDeviceFixture::SetUp() { // NOLINT(readability-identifier-naming)
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
DebugManager.flags.CreateMultipleSubDevices.set(numSubDevices);
|
||||
auto executionEnvironment = new NEO::ExecutionEnvironment;
|
||||
auto devices = NEO::DeviceFactory::createDevices(*executionEnvironment);
|
||||
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||
ze_result_t res = driverHandle->initialize(std::move(devices));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
}
|
||||
|
||||
void MultiDeviceFixture::TearDown() { // NOLINT(readability-identifier-naming)
|
||||
}
|
||||
|
||||
void ContextFixture::SetUp() {
|
||||
DeviceFixture::SetUp();
|
||||
|
||||
ze_context_handle_t hContext = {};
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t res = driverHandle->createContext(&desc, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
EXPECT_NE(nullptr, hContext);
|
||||
context = L0::Context::fromHandle(hContext);
|
||||
}
|
||||
|
||||
void ContextFixture::TearDown() {
|
||||
context->destroy();
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
@@ -12,47 +12,26 @@
|
||||
#include "shared/test/unit_test/helpers/default_hw_info.h"
|
||||
#include "shared/test/unit_test/mocks/mock_device.h"
|
||||
|
||||
#include "level_zero/core/source/driver/host_pointer_manager.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_context.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_device.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
|
||||
|
||||
namespace L0 {
|
||||
struct Context;
|
||||
struct Device;
|
||||
|
||||
namespace ult {
|
||||
|
||||
struct DeviceFixture {
|
||||
virtual void SetUp() { // NOLINT(readability-identifier-naming)
|
||||
neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get());
|
||||
auto mockBuiltIns = new MockBuiltins();
|
||||
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltIns);
|
||||
NEO::DeviceVector devices;
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
device = driverHandle->devices[0];
|
||||
}
|
||||
virtual void SetUp(); // NOLINT(readability-identifier-naming)
|
||||
virtual void TearDown(); // NOLINT(readability-identifier-naming)
|
||||
|
||||
virtual void TearDown() { // NOLINT(readability-identifier-naming)
|
||||
}
|
||||
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
|
||||
NEO::MockDevice *neoDevice = nullptr;
|
||||
L0::Device *device = nullptr;
|
||||
};
|
||||
|
||||
struct MultiDeviceFixture {
|
||||
virtual void SetUp() { // NOLINT(readability-identifier-naming)
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
DebugManager.flags.CreateMultipleSubDevices.set(numSubDevices);
|
||||
auto executionEnvironment = new NEO::ExecutionEnvironment;
|
||||
auto devices = NEO::DeviceFactory::createDevices(*executionEnvironment);
|
||||
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||
ze_result_t res = driverHandle->initialize(std::move(devices));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
}
|
||||
|
||||
virtual void TearDown() { // NOLINT(readability-identifier-naming)
|
||||
}
|
||||
virtual void SetUp(); // NOLINT(readability-identifier-naming)
|
||||
virtual void TearDown(); // NOLINT(readability-identifier-naming)
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
|
||||
@@ -62,21 +41,8 @@ struct MultiDeviceFixture {
|
||||
};
|
||||
|
||||
struct ContextFixture : DeviceFixture {
|
||||
void SetUp() override {
|
||||
DeviceFixture::SetUp();
|
||||
|
||||
ze_context_handle_t hContext = {};
|
||||
ze_context_desc_t desc;
|
||||
ze_result_t res = driverHandle->createContext(&desc, &hContext);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
EXPECT_NE(nullptr, hContext);
|
||||
context = L0::Context::fromHandle(hContext);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
context->destroy();
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
L0::Context *context = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "opencl/test/unit_test/mocks/mock_memory_operations_handler.h"
|
||||
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_host_pointer_manager.h"
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/built_ins/built_ins.h"
|
||||
|
||||
#include "level_zero/core/source/builtin/builtin_functions_lib_impl.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
@@ -15,12 +15,13 @@
|
||||
|
||||
#include "level_zero/core/source/builtin/builtin_functions_lib_impl.h"
|
||||
#include "level_zero/core/source/cmdqueue/cmdqueue_imp.h"
|
||||
#include "level_zero/core/source/event/event.h"
|
||||
#include "level_zero/core/source/kernel/kernel_imp.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_builtin_functions_lib_impl_timestamps.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_context.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_device_for_spirv.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_event.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
@@ -440,7 +441,7 @@ HWTEST_F(CommandListCreate, givenCommandListWhenSetBarrierThenPipeControlIsProgr
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
}
|
||||
|
||||
class MockEvent : public Mock<Event> {
|
||||
class MockEvent : public ::L0::Event {
|
||||
public:
|
||||
MockEvent() {
|
||||
mockAllocation.reset(new NEO::MockGraphicsAllocation(0, NEO::GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
@@ -451,6 +452,26 @@ class MockEvent : public Mock<Event> {
|
||||
NEO::GraphicsAllocation &getAllocation() override {
|
||||
return *mockAllocation.get();
|
||||
}
|
||||
|
||||
ze_result_t destroy() override {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
};
|
||||
ze_result_t hostSignal() override {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
};
|
||||
ze_result_t hostSynchronize(uint64_t timeout) override {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
};
|
||||
ze_result_t queryStatus() override {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
};
|
||||
ze_result_t reset() override {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
};
|
||||
ze_result_t queryKernelTimestamp(ze_kernel_timestamp_result_t *dstptr) override {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
};
|
||||
|
||||
std::unique_ptr<NEO::GraphicsAllocation> mockAllocation;
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
|
||||
#include "test.h"
|
||||
|
||||
#include "level_zero/core/source/driver/host_pointer_manager.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
@@ -109,6 +109,7 @@ target_link_libraries(${TARGET_NAME}
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
$<TARGET_OBJECTS:mock_gmm>
|
||||
$<TARGET_OBJECTS:${TARGET_NAME_L0}_fixtures>
|
||||
$<TARGET_OBJECTS:${TARGET_NAME_L0}_mocks>
|
||||
$<TARGET_OBJECTS:${BUILTINS_SPIRV_LIB_NAME}>
|
||||
$<TARGET_OBJECTS:${BUILTINS_BINARIES_BINDFUL_LIB_NAME}>
|
||||
|
||||
Reference in New Issue
Block a user