mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Remove not needed definitions and includes from mock_device.h
Change-Id: I95585f05805ee85577dfa0b981b32f828853af8a Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
7ec8e6a3f2
commit
56f67748fd
@ -13,6 +13,7 @@
|
||||
#include "unit_tests/command_queue/command_queue_fixture.h"
|
||||
#include "unit_tests/indirect_heap/indirect_heap_fixture.h"
|
||||
#include "unit_tests/helpers/hw_parse.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "unit_tests/mocks/mock_gmm.h"
|
||||
#include "unit_tests/mocks/mock_event.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "test.h"
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.inl"
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/gen_common/hw_cmds.h"
|
||||
#include "runtime/helpers/file_io.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "runtime/os_interface/debug_settings_manager.h"
|
||||
|
@ -22,9 +22,9 @@
|
||||
#include "unit_tests/mocks/mock_builtins.h"
|
||||
#include "unit_tests/mocks/mock_device.h"
|
||||
|
||||
#include "hw_cmds.h"
|
||||
#include "test.h"
|
||||
#include "driver_version.h"
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
class EnqueueHandlerTest : public OCLRT::DeviceFixture,
|
||||
public testing::Test {
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "unit_tests/mocks/mock_buffer.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "runtime/api/api.h"
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
namespace OCLRT {
|
||||
typedef struct _cl_object_for_test2 *cl_object_for_test2;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "unit_tests/mocks/mock_device.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "test.h"
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "unit_tests/mocks/mock_mdi.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
@ -19,10 +19,10 @@
|
||||
#include "unit_tests/gen_common/matchers.h"
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/helpers/memory_management.h"
|
||||
#include "unit_tests/libult/ult_command_stream_receiver.h"
|
||||
#include "unit_tests/mocks/mock_buffer.h"
|
||||
#include "unit_tests/mocks/mock_command_queue.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
#include "unit_tests/mocks/mock_gmm_resource_info.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
@ -6,10 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "unit_tests/mocks/mock_device.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/device/driver_info.h"
|
||||
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "runtime/os_interface/os_time.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
#include "unit_tests/mocks/mock_ostime.h"
|
||||
#include "unit_tests/tests_configuration.h"
|
||||
@ -24,7 +21,7 @@ MockDevice::MockDevice(const HardwareInfo &hwInfo)
|
||||
this->executionEnvironment->memoryManager = std::move(this->mockMemoryManager);
|
||||
this->commandStreamReceiver = commandStreamReceiver;
|
||||
}
|
||||
OCLRT::MockDevice::MockDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex)
|
||||
MockDevice::MockDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex)
|
||||
: Device(hwInfo, executionEnvironment, deviceIndex) {
|
||||
bool aubUsage = (testMode == TestMode::AubTests) || (testMode == TestMode::AubTestsWithTbx);
|
||||
this->mockMemoryManager.reset(new OsAgnosticMemoryManager(false, this->getHardwareCapabilities().localMemorySupported, aubUsage, *executionEnvironment));
|
||||
@ -57,12 +54,14 @@ void MockDevice::resetCommandStreamReceiver(CommandStreamReceiver *newCsr) {
|
||||
this->tagAddress = executionEnvironment->commandStreamReceivers[getDeviceIndex()]->getTagAddress();
|
||||
}
|
||||
|
||||
OCLRT::FailMemoryManager::FailMemoryManager(int32_t fail) {
|
||||
allocations.reserve(fail);
|
||||
agnostic = new OsAgnosticMemoryManager(false, false, executionEnvironment);
|
||||
this->fail = fail;
|
||||
}
|
||||
|
||||
MockAlignedMallocManagerDevice::MockAlignedMallocManagerDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex) : MockDevice(hwInfo, executionEnvironment, deviceIndex) {
|
||||
this->mockMemoryManager.reset(new MockAllocSysMemAgnosticMemoryManager(*executionEnvironment));
|
||||
}
|
||||
FailDevice::FailDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex)
|
||||
: MockDevice(hwInfo, executionEnvironment, deviceIndex) {
|
||||
this->mockMemoryManager.reset(new FailMemoryManager(*executionEnvironment));
|
||||
}
|
||||
FailDeviceAfterOne::FailDeviceAfterOne(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex)
|
||||
: MockDevice(hwInfo, executionEnvironment, deviceIndex) {
|
||||
this->mockMemoryManager.reset(new FailMemoryManager(1));
|
||||
}
|
||||
|
@ -7,16 +7,11 @@
|
||||
|
||||
#pragma once
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "runtime/memory_manager/memory_manager.h"
|
||||
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "unit_tests/libult/ult_command_stream_receiver.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
|
||||
namespace OCLRT {
|
||||
class OSTime;
|
||||
class MemoryManager;
|
||||
class FailMemoryManager;
|
||||
|
||||
extern CommandStreamReceiver *createCommandStream(const HardwareInfo *pHwInfo, ExecutionEnvironment &executionEnvironment);
|
||||
|
||||
@ -121,85 +116,14 @@ inline Device *MockDevice::createWithNewExecutionEnvironment<Device>(const Hardw
|
||||
return Device::create<Device>(pHwInfo, new ExecutionEnvironment, 0u);
|
||||
}
|
||||
|
||||
class FailMemoryManager : public MockMemoryManager {
|
||||
public:
|
||||
using MockMemoryManager::MockMemoryManager;
|
||||
FailMemoryManager(int32_t fail);
|
||||
virtual ~FailMemoryManager() override {
|
||||
if (agnostic) {
|
||||
for (auto alloc : allocations) {
|
||||
agnostic->freeGraphicsMemory(alloc);
|
||||
}
|
||||
delete agnostic;
|
||||
}
|
||||
};
|
||||
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override {
|
||||
if (fail <= 0) {
|
||||
return nullptr;
|
||||
}
|
||||
fail--;
|
||||
GraphicsAllocation *alloc = agnostic->allocateGraphicsMemory(size, alignment, forcePin, uncacheable);
|
||||
allocations.push_back(alloc);
|
||||
return alloc;
|
||||
};
|
||||
GraphicsAllocation *allocateGraphicsMemoryForNonSvmHostPtr(size_t size, void *cpuPtr) override { return nullptr; }
|
||||
GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin, bool preferRenderCompressed) override {
|
||||
return nullptr;
|
||||
};
|
||||
GraphicsAllocation *allocateGraphicsMemory(size_t size, const void *ptr) override {
|
||||
return nullptr;
|
||||
};
|
||||
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) override {
|
||||
return nullptr;
|
||||
};
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness) override {
|
||||
return nullptr;
|
||||
};
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle) override {
|
||||
return nullptr;
|
||||
};
|
||||
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override{};
|
||||
void *lockResource(GraphicsAllocation *gfxAllocation) override { return nullptr; };
|
||||
void unlockResource(GraphicsAllocation *gfxAllocation) override{};
|
||||
|
||||
MemoryManager::AllocationStatus populateOsHandles(OsHandleStorage &handleStorage) override {
|
||||
return AllocationStatus::Error;
|
||||
};
|
||||
void cleanOsHandles(OsHandleStorage &handleStorage) override{};
|
||||
|
||||
uint64_t getSystemSharedMemory() override {
|
||||
return 0;
|
||||
};
|
||||
|
||||
uint64_t getMaxApplicationAddress() override {
|
||||
return MemoryConstants::max32BitAppAddress;
|
||||
};
|
||||
|
||||
GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, size_t hostPtrSize, const void *hostPtr) override {
|
||||
return nullptr;
|
||||
};
|
||||
GraphicsAllocation *allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) override {
|
||||
return nullptr;
|
||||
}
|
||||
int32_t fail = 0;
|
||||
OsAgnosticMemoryManager *agnostic = nullptr;
|
||||
std::vector<GraphicsAllocation *> allocations;
|
||||
};
|
||||
|
||||
class FailDevice : public MockDevice {
|
||||
public:
|
||||
FailDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex)
|
||||
: MockDevice(hwInfo, executionEnvironment, deviceIndex) {
|
||||
this->mockMemoryManager.reset(new FailMemoryManager(*executionEnvironment));
|
||||
}
|
||||
FailDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex);
|
||||
};
|
||||
|
||||
class FailDeviceAfterOne : public MockDevice {
|
||||
public:
|
||||
FailDeviceAfterOne(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex)
|
||||
: MockDevice(hwInfo, executionEnvironment, deviceIndex) {
|
||||
this->mockMemoryManager.reset(new FailMemoryManager(1));
|
||||
}
|
||||
FailDeviceAfterOne(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex);
|
||||
};
|
||||
|
||||
class MockAlignedMallocManagerDevice : public MockDevice {
|
||||
|
@ -79,4 +79,10 @@ GraphicsAllocation *MockMemoryManager::allocateGraphicsMemory(size_t size, size_
|
||||
return OsAgnosticMemoryManager::allocateGraphicsMemory(size, alignment, forcePin, uncacheable);
|
||||
}
|
||||
|
||||
FailMemoryManager::FailMemoryManager(int32_t fail) {
|
||||
allocations.reserve(fail);
|
||||
agnostic = new OsAgnosticMemoryManager(false, false, executionEnvironment);
|
||||
this->fail = fail;
|
||||
}
|
||||
|
||||
} // namespace OCLRT
|
||||
|
@ -81,4 +81,69 @@ class MockAllocSysMemAgnosticMemoryManager : public OsAgnosticMemoryManager {
|
||||
AlignedMallocRestrictions testRestrictions;
|
||||
AlignedMallocRestrictions *ptrRestrictions;
|
||||
};
|
||||
|
||||
class FailMemoryManager : public MockMemoryManager {
|
||||
public:
|
||||
using MockMemoryManager::MockMemoryManager;
|
||||
FailMemoryManager(int32_t fail);
|
||||
virtual ~FailMemoryManager() override {
|
||||
if (agnostic) {
|
||||
for (auto alloc : allocations) {
|
||||
agnostic->freeGraphicsMemory(alloc);
|
||||
}
|
||||
delete agnostic;
|
||||
}
|
||||
};
|
||||
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override {
|
||||
if (fail <= 0) {
|
||||
return nullptr;
|
||||
}
|
||||
fail--;
|
||||
GraphicsAllocation *alloc = agnostic->allocateGraphicsMemory(size, alignment, forcePin, uncacheable);
|
||||
allocations.push_back(alloc);
|
||||
return alloc;
|
||||
};
|
||||
GraphicsAllocation *allocateGraphicsMemoryForNonSvmHostPtr(size_t size, void *cpuPtr) override { return nullptr; }
|
||||
GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin, bool preferRenderCompressed) override {
|
||||
return nullptr;
|
||||
};
|
||||
GraphicsAllocation *allocateGraphicsMemory(size_t size, const void *ptr) override {
|
||||
return nullptr;
|
||||
};
|
||||
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) override {
|
||||
return nullptr;
|
||||
};
|
||||
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness) override {
|
||||
return nullptr;
|
||||
};
|
||||
GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle) override {
|
||||
return nullptr;
|
||||
};
|
||||
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override{};
|
||||
void *lockResource(GraphicsAllocation *gfxAllocation) override { return nullptr; };
|
||||
void unlockResource(GraphicsAllocation *gfxAllocation) override{};
|
||||
|
||||
MemoryManager::AllocationStatus populateOsHandles(OsHandleStorage &handleStorage) override {
|
||||
return AllocationStatus::Error;
|
||||
};
|
||||
void cleanOsHandles(OsHandleStorage &handleStorage) override{};
|
||||
|
||||
uint64_t getSystemSharedMemory() override {
|
||||
return 0;
|
||||
};
|
||||
|
||||
uint64_t getMaxApplicationAddress() override {
|
||||
return MemoryConstants::max32BitAppAddress;
|
||||
};
|
||||
|
||||
GraphicsAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, size_t hostPtrSize, const void *hostPtr) override {
|
||||
return nullptr;
|
||||
};
|
||||
GraphicsAllocation *allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) override {
|
||||
return nullptr;
|
||||
}
|
||||
int32_t fail = 0;
|
||||
OsAgnosticMemoryManager *agnostic = nullptr;
|
||||
std::vector<GraphicsAllocation *> allocations;
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "test.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "runtime/helpers/file_io.h"
|
||||
#include "runtime/helpers/string_helpers.h"
|
||||
#include "runtime/os_interface/debug_settings_manager.h"
|
||||
|
Reference in New Issue
Block a user