Enable local memory bank in DG1 (2)
Add ULT Change-Id: I58cd200fd8e35b4afde935c7bd46cf4bfcf1bf0c Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
parent
abacd81234
commit
401dcf8c2a
|
@ -172,7 +172,11 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenDrmMemoryManagerWhenCreateBufferObj
|
|||
auto gpuAddress = 0x1234u;
|
||||
auto size = MemoryConstants::pageSize64k;
|
||||
|
||||
auto bo = std::unique_ptr<BufferObject>(createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), gpuAddress, size, (1 << (MemoryBanks::Bank0 - 1)), 1));
|
||||
auto bo = std::unique_ptr<BufferObject>(memoryManager->createBufferObjectInMemoryRegion(&memoryManager->getDrm(0),
|
||||
gpuAddress,
|
||||
size,
|
||||
(1 << (MemoryBanks::Bank0 - 1)),
|
||||
1));
|
||||
ASSERT_NE(nullptr, bo);
|
||||
|
||||
EXPECT_EQ(1u, mock->ioctlCallsCount);
|
||||
|
@ -201,7 +205,11 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenDrmMemoryManagerWhenCreateBufferObj
|
|||
auto gpuAddress = 0x1234u;
|
||||
auto size = MemoryConstants::pageSize;
|
||||
|
||||
auto bo = std::unique_ptr<BufferObject>(createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), gpuAddress, size, MemoryBanks::MainBank, 1));
|
||||
auto bo = std::unique_ptr<BufferObject>(memoryManager->createBufferObjectInMemoryRegion(&memoryManager->getDrm(0),
|
||||
gpuAddress,
|
||||
size,
|
||||
MemoryBanks::MainBank,
|
||||
1));
|
||||
EXPECT_EQ(nullptr, bo);
|
||||
}
|
||||
|
||||
|
@ -213,7 +221,11 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenDrmMemoryManagerWhenCreateBufferObj
|
|||
auto gpuAddress = 0x1234u;
|
||||
auto size = MemoryConstants::pageSize;
|
||||
|
||||
auto bo = std::unique_ptr<BufferObject>(createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), gpuAddress, size, MemoryBanks::MainBank, 1));
|
||||
auto bo = std::unique_ptr<BufferObject>(memoryManager->createBufferObjectInMemoryRegion(&memoryManager->getDrm(0),
|
||||
gpuAddress,
|
||||
size,
|
||||
MemoryBanks::MainBank,
|
||||
1));
|
||||
EXPECT_EQ(nullptr, bo);
|
||||
}
|
||||
|
||||
|
@ -223,7 +235,11 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenDrmMemoryManagerWhenCreateBufferObj
|
|||
auto gpuAddress = 0x1234u;
|
||||
auto size = 0u;
|
||||
|
||||
auto bo = std::unique_ptr<BufferObject>(createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), gpuAddress, size, MemoryBanks::MainBank, 1));
|
||||
auto bo = std::unique_ptr<BufferObject>(memoryManager->createBufferObjectInMemoryRegion(&memoryManager->getDrm(0),
|
||||
gpuAddress,
|
||||
size,
|
||||
MemoryBanks::MainBank,
|
||||
1));
|
||||
EXPECT_EQ(nullptr, bo);
|
||||
}
|
||||
|
||||
|
@ -241,6 +257,70 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenUseSystemMemoryFlagWhenGraphicsAllo
|
|||
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
|
||||
}
|
||||
|
||||
class DrmMemoryManagerLocalMemoryMemoryBankMock : public TestedDrmMemoryManager {
|
||||
public:
|
||||
DrmMemoryManagerLocalMemoryMemoryBankMock(bool enableLocalMemory,
|
||||
bool allowForcePin,
|
||||
bool validateHostPtrMemory,
|
||||
ExecutionEnvironment &executionEnvironment) : TestedDrmMemoryManager(enableLocalMemory, allowForcePin, validateHostPtrMemory, executionEnvironment) {
|
||||
}
|
||||
|
||||
BufferObject *createBufferObjectInMemoryRegion(Drm *drm,
|
||||
uint64_t gpuAddress,
|
||||
size_t size,
|
||||
uint32_t memoryBanks,
|
||||
size_t maxOsContextCount) override {
|
||||
memoryBankIsOne = (memoryBanks == 1) ? true : false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool memoryBankIsOne = false;
|
||||
};
|
||||
|
||||
class DrmMemoryManagerLocalMemoryMemoryBankTest : public ::testing::Test {
|
||||
public:
|
||||
DrmMockDg1 *mock;
|
||||
|
||||
void SetUp() override {
|
||||
const bool localMemoryEnabled = true;
|
||||
executionEnvironment = new ExecutionEnvironment;
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(defaultHwInfo.get());
|
||||
mock = new DrmMockDg1();
|
||||
mock->memoryInfo.reset(new MockMemoryInfo());
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->setDrm(mock);
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock);
|
||||
|
||||
device.reset(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(),
|
||||
executionEnvironment,
|
||||
rootDeviceIndex));
|
||||
memoryManager = std::make_unique<DrmMemoryManagerLocalMemoryMemoryBankMock>(localMemoryEnabled,
|
||||
false,
|
||||
false,
|
||||
*executionEnvironment);
|
||||
}
|
||||
|
||||
protected:
|
||||
ExecutionEnvironment *executionEnvironment = nullptr;
|
||||
std::unique_ptr<MockDevice> device;
|
||||
std::unique_ptr<DrmMemoryManagerLocalMemoryMemoryBankMock> memoryManager;
|
||||
const uint32_t rootDeviceIndex = 0u;
|
||||
};
|
||||
|
||||
TEST_F(DrmMemoryManagerLocalMemoryMemoryBankTest, givenDeviceMemoryWhenGraphicsAllocationInDevicePoolIsAllocatedThenMemoryBankIsSetToOne) {
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.flags.useSystemMemory = false;
|
||||
allocData.type = GraphicsAllocation::AllocationType::BUFFER;
|
||||
allocData.rootDeviceIndex = rootDeviceIndex;
|
||||
|
||||
memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_TRUE(memoryManager->memoryBankIsOne);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerLocalMemoryTest, givenNotSetUseSystemMemoryWhenGraphicsAllocationInDevicePoolIsAllocatedForBufferThenLocalMemoryAllocationIsReturnedFromStandard64KbHeap) {
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
|
|
|
@ -57,6 +57,7 @@ class DrmMemoryManager : public MemoryManager {
|
|||
int obtainFdFromHandle(int boHandle, uint32_t rootDeviceindex);
|
||||
AddressRange reserveGpuAddress(size_t size, uint32_t rootDeviceIndex) override;
|
||||
void freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) override;
|
||||
MOCKABLE_VIRTUAL BufferObject *createBufferObjectInMemoryRegion(Drm *drm, uint64_t gpuAddress, size_t size, uint32_t memoryBanks, size_t maxOsContextCount);
|
||||
|
||||
protected:
|
||||
BufferObject *findAndReferenceSharedBufferObject(int boHandle);
|
||||
|
@ -87,6 +88,7 @@ class DrmMemoryManager : public MemoryManager {
|
|||
void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) override;
|
||||
DrmAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override;
|
||||
GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override;
|
||||
bool createDrmAllocation(Drm *drm, DrmAllocation *allocation, uint64_t gpuAddress, size_t maxOsContextCount);
|
||||
|
||||
Drm &getDrm(uint32_t rootDeviceIndex) const;
|
||||
uint32_t getRootDeviceIndex(const Drm *drm);
|
||||
|
|
|
@ -9,6 +9,14 @@
|
|||
#include "shared/source/os_interface/linux/drm_memory_manager.h"
|
||||
|
||||
namespace NEO {
|
||||
bool DrmMemoryManager::createDrmAllocation(Drm *drm, DrmAllocation *allocation, uint64_t gpuAddress, size_t maxOsContextCount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BufferObject *DrmMemoryManager::createBufferObjectInMemoryRegion(Drm *drm, uint64_t gpuAddress, size_t size, uint32_t memoryBanks, size_t maxOsContextCount) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) {
|
||||
status = AllocationStatus::RetryInNonDevicePool;
|
||||
return nullptr;
|
||||
|
|
|
@ -19,7 +19,11 @@
|
|||
|
||||
namespace NEO {
|
||||
|
||||
BufferObject *createBufferObjectInMemoryRegion(Drm *drm, uint64_t gpuAddress, size_t size, uint32_t memoryBanks, size_t maxOsContextCount) {
|
||||
BufferObject *DrmMemoryManager::createBufferObjectInMemoryRegion(Drm *drm,
|
||||
uint64_t gpuAddress,
|
||||
size_t size,
|
||||
uint32_t memoryBanks,
|
||||
size_t maxOsContextCount) {
|
||||
auto memoryInfo = static_cast<MemoryInfoImpl *>(drm->getMemoryInfo());
|
||||
if (!memoryInfo) {
|
||||
return nullptr;
|
||||
|
@ -86,7 +90,7 @@ uint64_t getGpuAddress(GraphicsAllocation::AllocationType allocType, GfxPartitio
|
|||
return gpuAddress;
|
||||
}
|
||||
|
||||
bool createDrmAllocation(Drm *drm, DrmAllocation *allocation, uint64_t gpuAddress, size_t maxOsContextCount) {
|
||||
bool DrmMemoryManager::createDrmAllocation(Drm *drm, DrmAllocation *allocation, uint64_t gpuAddress, size_t maxOsContextCount) {
|
||||
std::array<std::unique_ptr<BufferObject>, EngineLimits::maxHandleCount> bos{};
|
||||
auto &storageInfo = allocation->storageInfo;
|
||||
auto boAddress = gpuAddress;
|
||||
|
|
Loading…
Reference in New Issue