2019-12-04 20:45:32 +08:00
|
|
|
/*
|
2021-01-13 05:39:04 +08:00
|
|
|
* Copyright (C) 2019-2021 Intel Corporation
|
2019-12-04 20:45:32 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-11-20 19:04:46 +08:00
|
|
|
#include "shared/source/os_interface/device_factory.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
|
|
|
#include "shared/test/common/helpers/variable_backup.h"
|
|
|
|
#include "shared/test/common/mocks/mock_device.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-03-18 20:08:45 +08:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
|
2020-02-23 22:20:22 +08:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_context.h"
|
|
|
|
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
|
2019-12-04 20:45:32 +08:00
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
class MultiRootDeviceFixture : public ::testing::Test {
|
|
|
|
public:
|
|
|
|
void SetUp() override {
|
2020-11-20 19:04:46 +08:00
|
|
|
deviceFactory = std::make_unique<UltClDeviceFactory>(3, 0);
|
|
|
|
device1 = deviceFactory->rootDevices[1];
|
|
|
|
device2 = deviceFactory->rootDevices[2];
|
2020-09-28 19:11:58 +08:00
|
|
|
|
2020-11-20 19:04:46 +08:00
|
|
|
cl_device_id devices[] = {device1, device2};
|
2020-09-28 19:11:58 +08:00
|
|
|
|
2020-11-04 23:50:54 +08:00
|
|
|
context.reset(new MockContext(ClDeviceVector(devices, 2), false));
|
2020-11-20 19:04:46 +08:00
|
|
|
mockMemoryManager = static_cast<MockMemoryManager *>(device1->getMemoryManager());
|
2021-01-18 23:09:44 +08:00
|
|
|
|
2020-11-20 19:04:46 +08:00
|
|
|
ASSERT_EQ(mockMemoryManager, device1->getMemoryManager());
|
2019-12-04 20:45:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const uint32_t expectedRootDeviceIndex = 1;
|
2020-11-20 19:04:46 +08:00
|
|
|
std::unique_ptr<UltClDeviceFactory> deviceFactory;
|
|
|
|
MockClDevice *device1 = nullptr;
|
|
|
|
MockClDevice *device2 = nullptr;
|
2019-12-04 20:45:32 +08:00
|
|
|
std::unique_ptr<MockContext> context;
|
|
|
|
MockMemoryManager *mockMemoryManager;
|
|
|
|
};
|
2020-12-18 00:26:13 +08:00
|
|
|
class MultiRootDeviceWithSubDevicesFixture : public ::testing::Test {
|
|
|
|
public:
|
|
|
|
void SetUp() override {
|
|
|
|
deviceFactory = std::make_unique<UltClDeviceFactory>(3, 2);
|
|
|
|
device1 = deviceFactory->rootDevices[1];
|
|
|
|
device2 = deviceFactory->rootDevices[2];
|
|
|
|
|
|
|
|
cl_device_id devices[] = {device1, device2, deviceFactory->subDevices[2]};
|
|
|
|
|
|
|
|
context.reset(new MockContext(ClDeviceVector(devices, 3), false));
|
|
|
|
mockMemoryManager = static_cast<MockMemoryManager *>(device1->getMemoryManager());
|
|
|
|
ASSERT_EQ(mockMemoryManager, device1->getMemoryManager());
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint32_t expectedRootDeviceIndex = 1;
|
|
|
|
std::unique_ptr<UltClDeviceFactory> deviceFactory;
|
|
|
|
MockClDevice *device1 = nullptr;
|
|
|
|
MockClDevice *device2 = nullptr;
|
|
|
|
std::unique_ptr<MockContext> context;
|
|
|
|
MockMemoryManager *mockMemoryManager;
|
|
|
|
};
|
2019-12-04 20:45:32 +08:00
|
|
|
}; // namespace NEO
|