mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Add alternative residency model on Linux
Related-To: NEO-4732 Change-Id: I79e165d2b647af200ca314e1183ecf05903de644 Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
@ -181,7 +181,7 @@ ze_result_t DeviceImp::createModule(const ze_module_desc_t *desc, ze_module_hand
|
|||||||
ze_result_t DeviceImp::evictImage(ze_image_handle_t hImage) {
|
ze_result_t DeviceImp::evictImage(ze_image_handle_t hImage) {
|
||||||
auto alloc = Image::fromHandle(hImage)->getAllocation();
|
auto alloc = Image::fromHandle(hImage)->getAllocation();
|
||||||
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
||||||
auto success = memoryOperationsIface->evict(*alloc);
|
auto success = memoryOperationsIface->evict(neoDevice, *alloc);
|
||||||
return changeMemoryOperationStatusToL0ResultType(success);
|
return changeMemoryOperationStatusToL0ResultType(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ ze_result_t DeviceImp::evictMemory(void *ptr, size_t size) {
|
|||||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
||||||
auto success = memoryOperationsIface->evict(*alloc->gpuAllocations.getGraphicsAllocation(getRootDeviceIndex()));
|
auto success = memoryOperationsIface->evict(neoDevice, *alloc->gpuAllocations.getGraphicsAllocation(getRootDeviceIndex()));
|
||||||
return changeMemoryOperationStatusToL0ResultType(success);
|
return changeMemoryOperationStatusToL0ResultType(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ ze_result_t DeviceImp::getSubDevices(uint32_t *pCount, ze_device_handle_t *phSub
|
|||||||
ze_result_t DeviceImp::makeImageResident(ze_image_handle_t hImage) {
|
ze_result_t DeviceImp::makeImageResident(ze_image_handle_t hImage) {
|
||||||
auto alloc = Image::fromHandle(hImage)->getAllocation();
|
auto alloc = Image::fromHandle(hImage)->getAllocation();
|
||||||
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
||||||
auto success = memoryOperationsIface->makeResident(ArrayRef<NEO::GraphicsAllocation *>(&alloc, 1));
|
auto success = memoryOperationsIface->makeResident(neoDevice, ArrayRef<NEO::GraphicsAllocation *>(&alloc, 1));
|
||||||
return changeMemoryOperationStatusToL0ResultType(success);
|
return changeMemoryOperationStatusToL0ResultType(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,7 +410,7 @@ ze_result_t DeviceImp::makeMemoryResident(void *ptr, size_t size) {
|
|||||||
}
|
}
|
||||||
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
||||||
auto gpuAllocation = alloc->gpuAllocations.getGraphicsAllocation(getRootDeviceIndex());
|
auto gpuAllocation = alloc->gpuAllocations.getGraphicsAllocation(getRootDeviceIndex());
|
||||||
auto success = memoryOperationsIface->makeResident(ArrayRef<NEO::GraphicsAllocation *>(&gpuAllocation, 1));
|
auto success = memoryOperationsIface->makeResident(neoDevice, ArrayRef<NEO::GraphicsAllocation *>(&gpuAllocation, 1));
|
||||||
return changeMemoryOperationStatusToL0ResultType(success);
|
return changeMemoryOperationStatusToL0ResultType(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ void EventImp::makeAllocationResident() {
|
|||||||
|
|
||||||
if (memoryOperationsIface) {
|
if (memoryOperationsIface) {
|
||||||
auto alloc = &(this->eventPool->getAllocation());
|
auto alloc = &(this->eventPool->getAllocation());
|
||||||
memoryOperationsIface->makeResident(ArrayRef<NEO::GraphicsAllocation *>(&alloc, 1));
|
memoryOperationsIface->makeResident(deviceImp->neoDevice, ArrayRef<NEO::GraphicsAllocation *>(&alloc, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,9 +359,12 @@ Buffer *Buffer::create(Context *context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (DebugManager.flags.MakeAllBuffersResident.get()) {
|
if (DebugManager.flags.MakeAllBuffersResident.get()) {
|
||||||
auto graphicsAllocation = pBuffer->getGraphicsAllocation(rootDeviceIndex);
|
for (size_t deviceNum = 0u; deviceNum < context->getNumDevices(); deviceNum++) {
|
||||||
auto rootDeviceEnvironment = pBuffer->executionEnvironment->rootDeviceEnvironments[rootDeviceIndex].get();
|
auto device = context->getDevice(deviceNum);
|
||||||
rootDeviceEnvironment->memoryOperationsInterface->makeResident(ArrayRef<GraphicsAllocation *>(&graphicsAllocation, 1));
|
auto graphicsAllocation = pBuffer->getGraphicsAllocation(device->getRootDeviceIndex());
|
||||||
|
auto rootDeviceEnvironment = pBuffer->executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()].get();
|
||||||
|
rootDeviceEnvironment->memoryOperationsInterface->makeResident(&device->getDevice(), ArrayRef<GraphicsAllocation *>(&graphicsAllocation, 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pBuffer;
|
return pBuffer;
|
||||||
|
@ -69,12 +69,8 @@ bool DrmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer, Reside
|
|||||||
|
|
||||||
auto memoryOperationsInterface = static_cast<DrmMemoryOperationsHandler *>(this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex]->memoryOperationsInterface.get());
|
auto memoryOperationsInterface = static_cast<DrmMemoryOperationsHandler *>(this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex]->memoryOperationsInterface.get());
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock;
|
auto lock = memoryOperationsInterface->lockHandlerForExecWA();
|
||||||
if (DebugManager.flags.MakeAllBuffersResident.get()) {
|
memoryOperationsInterface->mergeWithResidencyContainer(this->osContext, allocationsForResidency);
|
||||||
lock = memoryOperationsInterface->acquireLock();
|
|
||||||
}
|
|
||||||
|
|
||||||
memoryOperationsInterface->mergeWithResidencyContainer(allocationsForResidency);
|
|
||||||
|
|
||||||
this->flushStamp->setStamp(bb->peekHandle());
|
this->flushStamp->setStamp(bb->peekHandle());
|
||||||
this->flushInternal(batchBuffer, allocationsForResidency);
|
this->flushInternal(batchBuffer, allocationsForResidency);
|
||||||
@ -120,7 +116,7 @@ template <typename GfxFamily>
|
|||||||
void DrmCommandStreamReceiver<GfxFamily>::processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) {
|
void DrmCommandStreamReceiver<GfxFamily>::processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) {
|
||||||
for (auto &alloc : inputAllocationsForResidency) {
|
for (auto &alloc : inputAllocationsForResidency) {
|
||||||
auto drmAlloc = static_cast<DrmAllocation *>(alloc);
|
auto drmAlloc = static_cast<DrmAllocation *>(alloc);
|
||||||
drmAlloc->getBOsForResidency(osContext->getContextId(), handleId, this->residency);
|
drmAlloc->makeBOsResident(osContext->getContextId(), 0u, handleId, &this->residency, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2467,23 +2467,6 @@ TEST(SharedBuffersTest, whenBuffersIsCreatedWithSharingHandlerThenItIsSharedBuff
|
|||||||
buffer->release();
|
buffer->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ResidencyTests, whenBuffersIsCreatedWithMakeResidentFlagThenItSuccessfulyCreates) {
|
|
||||||
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
|
||||||
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
|
||||||
ultHwConfig.forceOsAgnosticMemoryManager = false;
|
|
||||||
DebugManagerStateRestore restorer;
|
|
||||||
DebugManager.flags.MakeAllBuffersResident.set(true);
|
|
||||||
|
|
||||||
initPlatform();
|
|
||||||
auto device = platform()->getClDevice(0u);
|
|
||||||
|
|
||||||
MockContext context(device, false);
|
|
||||||
auto retValue = CL_SUCCESS;
|
|
||||||
auto clBuffer = clCreateBuffer(&context, 0u, 4096u, nullptr, &retValue);
|
|
||||||
ASSERT_EQ(retValue, CL_SUCCESS);
|
|
||||||
clReleaseMemObject(clBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
class BufferTests : public ::testing::Test {
|
class BufferTests : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
|
@ -15,8 +15,8 @@ class GraphicsAllocation;
|
|||||||
class MockMemoryOperationsHandler : public MemoryOperationsHandler {
|
class MockMemoryOperationsHandler : public MemoryOperationsHandler {
|
||||||
public:
|
public:
|
||||||
MockMemoryOperationsHandler() {}
|
MockMemoryOperationsHandler() {}
|
||||||
MemoryOperationsStatus makeResident(ArrayRef<GraphicsAllocation *> gfxAllocations) override { return MemoryOperationsStatus::UNSUPPORTED; }
|
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override { return MemoryOperationsStatus::UNSUPPORTED; }
|
||||||
MemoryOperationsStatus evict(GraphicsAllocation &gfxAllocation) override { return MemoryOperationsStatus::UNSUPPORTED; }
|
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override { return MemoryOperationsStatus::UNSUPPORTED; }
|
||||||
MemoryOperationsStatus isResident(GraphicsAllocation &gfxAllocation) override { return MemoryOperationsStatus::UNSUPPORTED; }
|
MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override { return MemoryOperationsStatus::UNSUPPORTED; }
|
||||||
};
|
};
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
@ -37,7 +37,7 @@ TEST(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSharedAllocationIsCreatedFro
|
|||||||
};
|
};
|
||||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
auto mock = new MockDrm(0, *executionEnvironment.rootDeviceEnvironments[0]);
|
auto mock = new MockDrm(0, *executionEnvironment.rootDeviceEnvironments[0]);
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(mock);
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(mock);
|
||||||
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(executionEnvironment);
|
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(executionEnvironment);
|
||||||
@ -103,7 +103,7 @@ TEST(DrmMemoryManagerTest, givenMultipleThreadsWhenSharedAllocationIsCreatedThen
|
|||||||
|
|
||||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
auto mock = new MockDrm(0, *executionEnvironment.rootDeviceEnvironments[0]);
|
auto mock = new MockDrm(0, *executionEnvironment.rootDeviceEnvironments[0]);
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(mock);
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(mock);
|
||||||
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(executionEnvironment);
|
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(executionEnvironment);
|
||||||
|
@ -35,7 +35,7 @@ class DrmCommandStreamTest : public ::testing::Test {
|
|||||||
|
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(mock);
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(mock);
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
|
|
||||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
|
auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
|
||||||
mock->createVirtualMemoryAddressSpace(HwHelper::getSubDevicesCount(hwInfo));
|
mock->createVirtualMemoryAddressSpace(HwHelper::getSubDevicesCount(hwInfo));
|
||||||
@ -82,11 +82,12 @@ class DrmCommandStreamTest : public ::testing::Test {
|
|||||||
std::unique_ptr<OsContextLinux> osContext;
|
std::unique_ptr<OsContextLinux> osContext;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DrmCommandStreamEnhancedTest : public ::testing::Test {
|
template <typename T>
|
||||||
|
class DrmCommandStreamEnhancedTemplate : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
std::unique_ptr<DebugManagerStateRestore> dbgState;
|
std::unique_ptr<DebugManagerStateRestore> dbgState;
|
||||||
MockExecutionEnvironment *executionEnvironment;
|
MockExecutionEnvironment *executionEnvironment;
|
||||||
DrmMockCustom *mock;
|
T *mock;
|
||||||
CommandStreamReceiver *csr = nullptr;
|
CommandStreamReceiver *csr = nullptr;
|
||||||
const uint32_t rootDeviceIndex = 0u;
|
const uint32_t rootDeviceIndex = 0u;
|
||||||
|
|
||||||
@ -102,10 +103,10 @@ class DrmCommandStreamEnhancedTest : public ::testing::Test {
|
|||||||
//make sure this is disabled, we don't want to test this now
|
//make sure this is disabled, we don't want to test this now
|
||||||
DebugManager.flags.EnableForcePin.set(false);
|
DebugManager.flags.EnableForcePin.set(false);
|
||||||
|
|
||||||
mock = new DrmMockCustom();
|
mock = new T();
|
||||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
|
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
|
||||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->setDrm(mock);
|
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->setDrm(mock);
|
||||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
|
|
||||||
csr = new TestedDrmCommandStreamReceiver<GfxFamily>(*executionEnvironment, rootDeviceIndex);
|
csr = new TestedDrmCommandStreamReceiver<GfxFamily>(*executionEnvironment, rootDeviceIndex);
|
||||||
ASSERT_NE(nullptr, csr);
|
ASSERT_NE(nullptr, csr);
|
||||||
@ -127,7 +128,7 @@ class DrmCommandStreamEnhancedTest : public ::testing::Test {
|
|||||||
|
|
||||||
template <typename GfxFamily>
|
template <typename GfxFamily>
|
||||||
void makeResidentBufferObjects(DrmAllocation *drmAllocation) {
|
void makeResidentBufferObjects(DrmAllocation *drmAllocation) {
|
||||||
drmAllocation->appendBOs(0u, static_cast<TestedDrmCommandStreamReceiver<GfxFamily> *>(csr)->residency);
|
drmAllocation->bindBOs(0u, 0u, &static_cast<TestedDrmCommandStreamReceiver<GfxFamily> *>(csr)->residency, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename GfxFamily>
|
template <typename GfxFamily>
|
||||||
@ -143,7 +144,7 @@ class DrmCommandStreamEnhancedTest : public ::testing::Test {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
class MockBufferObject : public BufferObject {
|
class MockBufferObject : public BufferObject {
|
||||||
friend DrmCommandStreamEnhancedTest;
|
friend DrmCommandStreamEnhancedTemplate<T>;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MockBufferObject(Drm *drm, size_t size) : BufferObject(drm, 1, 0) {
|
MockBufferObject(Drm *drm, size_t size) : BufferObject(drm, 1, 0) {
|
||||||
@ -155,3 +156,5 @@ class DrmCommandStreamEnhancedTest : public ::testing::Test {
|
|||||||
return new MockBufferObject(this->mock, size);
|
return new MockBufferObject(this->mock, size);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using DrmCommandStreamEnhancedTest = DrmCommandStreamEnhancedTemplate<DrmMockCustom>;
|
||||||
|
@ -32,7 +32,7 @@ HWTEST_F(DrmCommandStreamMMTest, MMwithPinBB) {
|
|||||||
|
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(drm);
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(drm);
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
|
|
||||||
DrmCommandStreamReceiver<FamilyType> csr(executionEnvironment, 0, gemCloseWorkerMode::gemCloseWorkerInactive);
|
DrmCommandStreamReceiver<FamilyType> csr(executionEnvironment, 0, gemCloseWorkerMode::gemCloseWorkerInactive);
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ HWTEST_F(DrmCommandStreamMMTest, givenExecutionEnvironmentWithMoreThanOneRootDev
|
|||||||
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(defaultHwInfo.get());
|
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(defaultHwInfo.get());
|
||||||
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
|
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
|
||||||
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->setDrm(new DrmMockCustom());
|
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->setDrm(new DrmMockCustom());
|
||||||
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto memoryManager = new TestedDrmMemoryManager(false, true, false, executionEnvironment);
|
auto memoryManager = new TestedDrmMemoryManager(false, true, false, executionEnvironment);
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "shared/source/memory_manager/internal_allocation_storage.h"
|
#include "shared/source/memory_manager/internal_allocation_storage.h"
|
||||||
#include "shared/source/memory_manager/residency.h"
|
#include "shared/source/memory_manager/residency.h"
|
||||||
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
||||||
|
#include "shared/source/os_interface/linux/drm_memory_operations_handler_default.h"
|
||||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||||
#include "shared/source/os_interface/linux/os_interface.h"
|
#include "shared/source/os_interface/linux/os_interface.h"
|
||||||
#include "shared/source/os_interface/os_context.h"
|
#include "shared/source/os_interface/os_context.h"
|
||||||
@ -592,73 +593,6 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenGemCloseWorkerInactiveMode
|
|||||||
mm->freeGraphicsMemory(dummyAllocation);
|
mm->freeGraphicsMemory(dummyAllocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenAllocInMemoryOperationsInterfaceWhenFlushThenAllocIsResident) {
|
|
||||||
auto commandBuffer = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
|
|
||||||
LinearStream cs(commandBuffer);
|
|
||||||
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
|
|
||||||
CommandStreamReceiverHw<FamilyType>::alignToCacheLine(cs);
|
|
||||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr};
|
|
||||||
|
|
||||||
auto allocation = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
|
|
||||||
executionEnvironment->rootDeviceEnvironments[csr->getRootDeviceIndex()]->memoryOperationsInterface->makeResident(ArrayRef<GraphicsAllocation *>(&allocation, 1));
|
|
||||||
|
|
||||||
csr->flush(batchBuffer, csr->getResidencyAllocations());
|
|
||||||
|
|
||||||
const auto boRequirments = [&allocation](const auto &bo) {
|
|
||||||
return (static_cast<int>(bo.handle) == static_cast<DrmAllocation *>(allocation)->getBO()->peekHandle() &&
|
|
||||||
bo.offset == static_cast<DrmAllocation *>(allocation)->getBO()->peekAddress());
|
|
||||||
};
|
|
||||||
|
|
||||||
auto &residency = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->getExecStorage();
|
|
||||||
EXPECT_TRUE(std::find_if(residency.begin(), residency.end(), boRequirments) != residency.end());
|
|
||||||
EXPECT_EQ(residency.size(), 2u);
|
|
||||||
residency.clear();
|
|
||||||
|
|
||||||
csr->flush(batchBuffer, csr->getResidencyAllocations());
|
|
||||||
EXPECT_TRUE(std::find_if(residency.begin(), residency.end(), boRequirments) != residency.end());
|
|
||||||
EXPECT_EQ(residency.size(), 2u);
|
|
||||||
residency.clear();
|
|
||||||
|
|
||||||
csr->getResidencyAllocations().clear();
|
|
||||||
executionEnvironment->rootDeviceEnvironments[csr->getRootDeviceIndex()]->memoryOperationsInterface->evict(*allocation);
|
|
||||||
|
|
||||||
csr->flush(batchBuffer, csr->getResidencyAllocations());
|
|
||||||
|
|
||||||
EXPECT_FALSE(std::find_if(residency.begin(), residency.end(), boRequirments) != residency.end());
|
|
||||||
EXPECT_EQ(residency.size(), 1u);
|
|
||||||
|
|
||||||
mm->freeGraphicsMemory(allocation);
|
|
||||||
mm->freeGraphicsMemory(commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenMakeAllBuffersResidentSetWhenFlushThenDrmMemoryOperationHandlerIsLocked) {
|
|
||||||
struct MockDrmMemoryOperationsHandler : public DrmMemoryOperationsHandler {
|
|
||||||
using DrmMemoryOperationsHandler::mutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MockDrmCsr : public DrmCommandStreamReceiver<FamilyType> {
|
|
||||||
using DrmCommandStreamReceiver<FamilyType>::DrmCommandStreamReceiver;
|
|
||||||
void flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
|
|
||||||
auto memoryOperationsInterface = static_cast<MockDrmMemoryOperationsHandler *>(this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex]->memoryOperationsInterface.get());
|
|
||||||
EXPECT_FALSE(memoryOperationsInterface->mutex.try_lock());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
DebugManagerStateRestore restorer;
|
|
||||||
DebugManager.flags.MakeAllBuffersResident.set(true);
|
|
||||||
|
|
||||||
auto commandBuffer = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
|
|
||||||
LinearStream cs(commandBuffer);
|
|
||||||
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
|
|
||||||
CommandStreamReceiverHw<FamilyType>::alignToCacheLine(cs);
|
|
||||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr};
|
|
||||||
|
|
||||||
MockDrmCsr mockCsr(*executionEnvironment, rootDeviceIndex, gemCloseWorkerMode::gemCloseWorkerInactive);
|
|
||||||
mockCsr.flush(batchBuffer, mockCsr.getResidencyAllocations());
|
|
||||||
|
|
||||||
mm->freeGraphicsMemory(commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenTwoAllocationsWhenBackingStorageIsDifferentThenMakeResidentShouldAddTwoLocations) {
|
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenTwoAllocationsWhenBackingStorageIsDifferentThenMakeResidentShouldAddTwoLocations) {
|
||||||
auto allocation = static_cast<DrmAllocation *>(mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
auto allocation = static_cast<DrmAllocation *>(mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
||||||
auto allocation2 = static_cast<DrmAllocation *>(mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
auto allocation2 = static_cast<DrmAllocation *>(mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
||||||
|
@ -72,7 +72,7 @@ class DrmGemCloseWorkerFixture {
|
|||||||
|
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(drmMock);
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(drmMock);
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
|
|
||||||
this->mm = new DrmMemoryManager(gemCloseWorkerMode::gemCloseWorkerInactive,
|
this->mm = new DrmMemoryManager(gemCloseWorkerMode::gemCloseWorkerInactive,
|
||||||
false,
|
false,
|
||||||
|
@ -9,9 +9,13 @@
|
|||||||
#include "shared/source/os_interface/linux/drm_memory_manager.h"
|
#include "shared/source/os_interface/linux/drm_memory_manager.h"
|
||||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||||
#include "shared/source/os_interface/linux/os_interface.h"
|
#include "shared/source/os_interface/linux/os_interface.h"
|
||||||
|
#include "shared/test/unit_test/helpers/ult_hw_config.h"
|
||||||
|
|
||||||
#include "opencl/test/unit_test/mocks/linux/mock_drm_memory_manager.h"
|
#include "opencl/test/unit_test/mocks/linux/mock_drm_memory_manager.h"
|
||||||
|
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
|
||||||
|
#include "opencl/test/unit_test/mocks/mock_context.h"
|
||||||
#include "opencl/test/unit_test/mocks/mock_execution_environment.h"
|
#include "opencl/test/unit_test/mocks/mock_execution_environment.h"
|
||||||
|
#include "opencl/test/unit_test/os_interface/linux/drm_command_stream_fixture.h"
|
||||||
#include "opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.h"
|
#include "opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.h"
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
@ -22,7 +26,7 @@ using namespace NEO;
|
|||||||
TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenAllocateInDevicePoolIsCalledThenNullptrAndStatusRetryIsReturned) {
|
TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenAllocateInDevicePoolIsCalledThenNullptrAndStatusRetryIsReturned) {
|
||||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]));
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]));
|
||||||
TestedDrmMemoryManager memoryManager(executionEnvironment);
|
TestedDrmMemoryManager memoryManager(executionEnvironment);
|
||||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||||
@ -39,7 +43,7 @@ TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenAllocateInDevicePoolIs
|
|||||||
TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenLockResourceIsCalledOnNullBufferObjectThenReturnNullPtr) {
|
TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenLockResourceIsCalledOnNullBufferObjectThenReturnNullPtr) {
|
||||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
TestedDrmMemoryManager memoryManager(executionEnvironment);
|
TestedDrmMemoryManager memoryManager(executionEnvironment);
|
||||||
DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory);
|
DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory);
|
||||||
|
|
||||||
@ -52,7 +56,7 @@ TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenLockResourceIsCalledOn
|
|||||||
TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenFreeGraphicsMemoryIsCalledOnAllocationWithNullBufferObjectThenEarlyReturn) {
|
TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenFreeGraphicsMemoryIsCalledOnAllocationWithNullBufferObjectThenEarlyReturn) {
|
||||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
TestedDrmMemoryManager memoryManager(executionEnvironment);
|
TestedDrmMemoryManager memoryManager(executionEnvironment);
|
||||||
|
|
||||||
auto drmAllocation = new DrmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory);
|
auto drmAllocation = new DrmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory);
|
||||||
@ -95,3 +99,87 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenCopyMemoryToAllocationThen
|
|||||||
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenGetLocalMemoryIsCalledThenSizeOfLocalMemoryIsReturned) {
|
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenGetLocalMemoryIsCalledThenSizeOfLocalMemoryIsReturned) {
|
||||||
EXPECT_EQ(0 * GB, memoryManager->getLocalMemorySize(rootDeviceIndex));
|
EXPECT_EQ(0 * GB, memoryManager->getLocalMemorySize(rootDeviceIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenMakeAllBuffersResidentSetWhenFlushThenDrmMemoryOperationHandlerIsLocked) {
|
||||||
|
struct MockDrmMemoryOperationsHandler : public DrmMemoryOperationsHandler {
|
||||||
|
using DrmMemoryOperationsHandler::mutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MockDrmCsr : public DrmCommandStreamReceiver<FamilyType> {
|
||||||
|
using DrmCommandStreamReceiver<FamilyType>::DrmCommandStreamReceiver;
|
||||||
|
void flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency) override {
|
||||||
|
auto memoryOperationsInterface = static_cast<MockDrmMemoryOperationsHandler *>(this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex]->memoryOperationsInterface.get());
|
||||||
|
EXPECT_FALSE(memoryOperationsInterface->mutex.try_lock());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
DebugManagerStateRestore restorer;
|
||||||
|
DebugManager.flags.MakeAllBuffersResident.set(true);
|
||||||
|
|
||||||
|
auto commandBuffer = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||||
|
LinearStream cs(commandBuffer);
|
||||||
|
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
|
||||||
|
CommandStreamReceiverHw<FamilyType>::alignToCacheLine(cs);
|
||||||
|
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr};
|
||||||
|
|
||||||
|
MockDrmCsr mockCsr(*executionEnvironment, rootDeviceIndex, gemCloseWorkerMode::gemCloseWorkerInactive);
|
||||||
|
mockCsr.flush(batchBuffer, mockCsr.getResidencyAllocations());
|
||||||
|
|
||||||
|
mm->freeGraphicsMemory(commandBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenAllocInMemoryOperationsInterfaceWhenFlushThenAllocIsResident) {
|
||||||
|
auto commandBuffer = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||||
|
LinearStream cs(commandBuffer);
|
||||||
|
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
|
||||||
|
CommandStreamReceiverHw<FamilyType>::alignToCacheLine(cs);
|
||||||
|
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr};
|
||||||
|
|
||||||
|
auto allocation = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
|
||||||
|
executionEnvironment->rootDeviceEnvironments[csr->getRootDeviceIndex()]->memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocation, 1));
|
||||||
|
|
||||||
|
csr->flush(batchBuffer, csr->getResidencyAllocations());
|
||||||
|
|
||||||
|
const auto boRequirments = [&allocation](const auto &bo) {
|
||||||
|
return (static_cast<int>(bo.handle) == static_cast<DrmAllocation *>(allocation)->getBO()->peekHandle() &&
|
||||||
|
bo.offset == static_cast<DrmAllocation *>(allocation)->getBO()->peekAddress());
|
||||||
|
};
|
||||||
|
|
||||||
|
auto &residency = static_cast<TestedDrmCommandStreamReceiver<FamilyType> *>(csr)->getExecStorage();
|
||||||
|
EXPECT_TRUE(std::find_if(residency.begin(), residency.end(), boRequirments) != residency.end());
|
||||||
|
EXPECT_EQ(residency.size(), 2u);
|
||||||
|
residency.clear();
|
||||||
|
|
||||||
|
csr->flush(batchBuffer, csr->getResidencyAllocations());
|
||||||
|
EXPECT_TRUE(std::find_if(residency.begin(), residency.end(), boRequirments) != residency.end());
|
||||||
|
EXPECT_EQ(residency.size(), 2u);
|
||||||
|
residency.clear();
|
||||||
|
|
||||||
|
csr->getResidencyAllocations().clear();
|
||||||
|
executionEnvironment->rootDeviceEnvironments[csr->getRootDeviceIndex()]->memoryOperationsInterface->evict(device.get(), *allocation);
|
||||||
|
|
||||||
|
csr->flush(batchBuffer, csr->getResidencyAllocations());
|
||||||
|
|
||||||
|
EXPECT_FALSE(std::find_if(residency.begin(), residency.end(), boRequirments) != residency.end());
|
||||||
|
EXPECT_EQ(residency.size(), 1u);
|
||||||
|
|
||||||
|
mm->freeGraphicsMemory(allocation);
|
||||||
|
mm->freeGraphicsMemory(commandBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(ResidencyTests, whenBuffersIsCreatedWithMakeResidentFlagThenItSuccessfulyCreates) {
|
||||||
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||||
|
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
||||||
|
ultHwConfig.forceOsAgnosticMemoryManager = false;
|
||||||
|
DebugManagerStateRestore restorer;
|
||||||
|
DebugManager.flags.MakeAllBuffersResident.set(true);
|
||||||
|
|
||||||
|
initPlatform();
|
||||||
|
auto device = platform()->getClDevice(0u);
|
||||||
|
|
||||||
|
MockContext context(device, false);
|
||||||
|
auto retValue = CL_SUCCESS;
|
||||||
|
auto clBuffer = clCreateBuffer(&context, 0u, 4096u, nullptr, &retValue);
|
||||||
|
ASSERT_EQ(retValue, CL_SUCCESS);
|
||||||
|
clReleaseMemObject(clBuffer);
|
||||||
|
}
|
@ -3671,7 +3671,7 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryCallSequenceTest, givenDrmMemoryManagerAn
|
|||||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]));
|
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]));
|
||||||
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
GMockDrmMemoryManager gmockDrmMemoryManager(executionEnvironment);
|
GMockDrmMemoryManager gmockDrmMemoryManager(executionEnvironment);
|
||||||
|
|
||||||
AllocationProperties properties{0, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER};
|
AllocationProperties properties{0, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER};
|
||||||
@ -3691,7 +3691,7 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryCallSequenceTest, givenDrmMemoryManagerAn
|
|||||||
TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest, givenDrmMemoryManagerAndFreeGraphicsMemoryIsCalledForSharedAllocationThenUnreferenceBufferObjectIsCalledWithSynchronousDestroySetToFalse) {
|
TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest, givenDrmMemoryManagerAndFreeGraphicsMemoryIsCalledForSharedAllocationThenUnreferenceBufferObjectIsCalledWithSynchronousDestroySetToFalse) {
|
||||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||||
const uint32_t rootDeviceIndex = 0u;
|
const uint32_t rootDeviceIndex = 0u;
|
||||||
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
|
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
|
||||||
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->setDrm(Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]));
|
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->setDrm(Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]));
|
||||||
::testing::NiceMock<GMockDrmMemoryManager> gmockDrmMemoryManager(executionEnvironment);
|
::testing::NiceMock<GMockDrmMemoryManager> gmockDrmMemoryManager(executionEnvironment);
|
||||||
|
@ -28,7 +28,7 @@ class DrmMemoryManagerBasic : public ::testing::Test {
|
|||||||
for (auto i = 0u; i < numRootDevices; i++) {
|
for (auto i = 0u; i < numRootDevices; i++) {
|
||||||
executionEnvironment.rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
|
executionEnvironment.rootDeviceEnvironments[i]->osInterface = std::make_unique<OSInterface>();
|
||||||
executionEnvironment.rootDeviceEnvironments[i]->osInterface->get()->setDrm(Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[i]));
|
executionEnvironment.rootDeviceEnvironments[i]->osInterface->get()->setDrm(Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[i]));
|
||||||
executionEnvironment.rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
executionEnvironment.rootDeviceEnvironments[i]->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const uint32_t rootDeviceIndex = 1u;
|
const uint32_t rootDeviceIndex = 1u;
|
||||||
@ -59,7 +59,7 @@ class DrmMemoryManagerFixture : public MemoryManagementFixture {
|
|||||||
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[i].get();
|
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[i].get();
|
||||||
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
|
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
|
||||||
rootDeviceEnvironment->osInterface->get()->setDrm(new DrmMockCustom());
|
rootDeviceEnvironment->osInterface->get()->setDrm(new DrmMockCustom());
|
||||||
rootDeviceEnvironment->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
rootDeviceEnvironment->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex].get();
|
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex].get();
|
||||||
@ -132,7 +132,7 @@ class DrmMemoryManagerFixtureWithoutQuietIoctlExpectation {
|
|||||||
rootDeviceEnvironment->setHwInfo(defaultHwInfo.get());
|
rootDeviceEnvironment->setHwInfo(defaultHwInfo.get());
|
||||||
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
|
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
|
||||||
rootDeviceEnvironment->osInterface->get()->setDrm(new DrmMockCustom);
|
rootDeviceEnvironment->osInterface->get()->setDrm(new DrmMockCustom);
|
||||||
rootDeviceEnvironment->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
rootDeviceEnvironment->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
}
|
}
|
||||||
mock = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->getDrm());
|
mock = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->getDrm());
|
||||||
memoryManager.reset(new TestedDrmMemoryManager(*executionEnvironment));
|
memoryManager.reset(new TestedDrmMemoryManager(*executionEnvironment));
|
||||||
|
@ -114,6 +114,11 @@ int DrmMock::ioctl(unsigned long request, void *arg) {
|
|||||||
static_cast<drm_i915_gem_context_param *>(arg)->value = this->StoredPersistentContextsSupport;
|
static_cast<drm_i915_gem_context_param *>(arg)->value = this->StoredPersistentContextsSupport;
|
||||||
return this->StoredRetValForPersistant;
|
return this->StoredRetValForPersistant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (receivedContextParamRequest.param == I915_CONTEXT_PARAM_VM) {
|
||||||
|
static_cast<drm_i915_gem_context_param *>(arg)->value = 1u;
|
||||||
|
return 0u;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request == DRM_IOCTL_I915_GEM_EXECBUFFER2) {
|
if (request == DRM_IOCTL_I915_GEM_EXECBUFFER2) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
#include "shared/source/os_interface/linux/drm_memory_operations_handler_default.h"
|
||||||
|
|
||||||
#include "opencl/test/unit_test/mocks/mock_graphics_allocation.h"
|
#include "opencl/test/unit_test/mocks/mock_graphics_allocation.h"
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
@ -14,45 +14,36 @@
|
|||||||
|
|
||||||
using namespace NEO;
|
using namespace NEO;
|
||||||
|
|
||||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
struct MockDrmMemoryOperationsHandlerDefault : public DrmMemoryOperationsHandlerDefault {
|
||||||
|
using DrmMemoryOperationsHandlerDefault::residency;
|
||||||
#include "opencl/test/unit_test/mocks/mock_graphics_allocation.h"
|
|
||||||
#include "test.h"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
using namespace NEO;
|
|
||||||
|
|
||||||
struct MockDrmMemoryOperationsHandler : public DrmMemoryOperationsHandler {
|
|
||||||
using DrmMemoryOperationsHandler::residency;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DrmMemoryOperationsHandlerTest : public ::testing::Test {
|
struct DrmMemoryOperationsHandlerBaseTest : public ::testing::Test {
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
drmMemoryOperationsHandler = std::make_unique<MockDrmMemoryOperationsHandler>();
|
drmMemoryOperationsHandler = std::make_unique<MockDrmMemoryOperationsHandlerDefault>();
|
||||||
|
|
||||||
allocationPtr = &graphicsAllocation;
|
allocationPtr = &graphicsAllocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
MockGraphicsAllocation graphicsAllocation;
|
MockGraphicsAllocation graphicsAllocation;
|
||||||
GraphicsAllocation *allocationPtr;
|
GraphicsAllocation *allocationPtr;
|
||||||
std::unique_ptr<MockDrmMemoryOperationsHandler> drmMemoryOperationsHandler;
|
std::unique_ptr<MockDrmMemoryOperationsHandlerDefault> drmMemoryOperationsHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(DrmMemoryOperationsHandlerTest, whenMakingResidentAllocaionExpectMakeResidentFail) {
|
TEST_F(DrmMemoryOperationsHandlerBaseTest, whenMakingResidentAllocaionExpectMakeResidentFail) {
|
||||||
EXPECT_EQ(drmMemoryOperationsHandler->makeResident(ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(drmMemoryOperationsHandler->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 1u);
|
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 1u);
|
||||||
EXPECT_TRUE(drmMemoryOperationsHandler->residency.find(allocationPtr) != drmMemoryOperationsHandler->residency.end());
|
EXPECT_TRUE(drmMemoryOperationsHandler->residency.find(allocationPtr) != drmMemoryOperationsHandler->residency.end());
|
||||||
EXPECT_EQ(drmMemoryOperationsHandler->isResident(graphicsAllocation), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, graphicsAllocation), MemoryOperationsStatus::SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DrmMemoryOperationsHandlerTest, whenEvictingResidentAllocationExpectEvictFalse) {
|
TEST_F(DrmMemoryOperationsHandlerBaseTest, whenEvictingResidentAllocationExpectEvictFalse) {
|
||||||
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 0u);
|
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 0u);
|
||||||
EXPECT_EQ(drmMemoryOperationsHandler->makeResident(ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(drmMemoryOperationsHandler->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_EQ(drmMemoryOperationsHandler->isResident(graphicsAllocation), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, graphicsAllocation), MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 1u);
|
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 1u);
|
||||||
EXPECT_TRUE(drmMemoryOperationsHandler->residency.find(allocationPtr) != drmMemoryOperationsHandler->residency.end());
|
EXPECT_TRUE(drmMemoryOperationsHandler->residency.find(allocationPtr) != drmMemoryOperationsHandler->residency.end());
|
||||||
EXPECT_EQ(drmMemoryOperationsHandler->evict(graphicsAllocation), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(drmMemoryOperationsHandler->evict(nullptr, graphicsAllocation), MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_EQ(drmMemoryOperationsHandler->isResident(graphicsAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
|
EXPECT_EQ(drmMemoryOperationsHandler->isResident(nullptr, graphicsAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
|
||||||
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 0u);
|
EXPECT_EQ(drmMemoryOperationsHandler->residency.size(), 0u);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ struct clCreateCommandQueueWithPropertiesLinux : public UltCommandStreamReceiver
|
|||||||
auto osInterface = new OSInterface();
|
auto osInterface = new OSInterface();
|
||||||
osInterface->get()->setDrm(drm);
|
osInterface->get()->setDrm(drm);
|
||||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface.reset(osInterface);
|
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface.reset(osInterface);
|
||||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
executionEnvironment->memoryManager.reset(new TestedDrmMemoryManager(*executionEnvironment));
|
executionEnvironment->memoryManager.reset(new TestedDrmMemoryManager(*executionEnvironment));
|
||||||
mdevice = std::make_unique<MockClDevice>(MockDevice::create<MockDevice>(executionEnvironment, rootDeviceIndex));
|
mdevice = std::make_unique<MockClDevice>(MockDevice::create<MockDevice>(executionEnvironment, rootDeviceIndex));
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
|
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
|
||||||
#include "shared/test/unit_test/helpers/ult_hw_config.h"
|
#include "shared/test/unit_test/helpers/ult_hw_config.h"
|
||||||
#include "shared/test/unit_test/helpers/variable_backup.h"
|
#include "shared/test/unit_test/helpers/variable_backup.h"
|
||||||
|
#include "shared/test/unit_test/mocks/mock_device.h"
|
||||||
|
|
||||||
#include "opencl/source/cl_device/cl_device.h"
|
#include "opencl/source/cl_device/cl_device.h"
|
||||||
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
|
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
|
||||||
@ -53,43 +54,43 @@ struct WddmMemoryOperationsHandlerTest : public WddmTest {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(WddmMemoryOperationsHandlerTest, givenRegularAllocatioWhenMakingResidentAllocaionExpectMakeResidentCalled) {
|
TEST_F(WddmMemoryOperationsHandlerTest, givenRegularAllocatioWhenMakingResidentAllocaionExpectMakeResidentCalled) {
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(wddmAllocation), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmAllocation), MemoryOperationsStatus::SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WddmMemoryOperationsHandlerTest, givenFragmentedAllocationWhenMakingResidentAllocaionExpectMakeResidentCalled) {
|
TEST_F(WddmMemoryOperationsHandlerTest, givenFragmentedAllocationWhenMakingResidentAllocaionExpectMakeResidentCalled) {
|
||||||
allocationPtr = &wddmFragmentedAllocation;
|
allocationPtr = &wddmFragmentedAllocation;
|
||||||
|
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WddmMemoryOperationsHandlerTest, givenVariousAllocationsWhenMakingResidentAllocaionExpectMakeResidentCalled) {
|
TEST_F(WddmMemoryOperationsHandlerTest, givenVariousAllocationsWhenMakingResidentAllocaionExpectMakeResidentCalled) {
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(ArrayRef<GraphicsAllocation *>(allocationData)), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(allocationData)), MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(wddmAllocation), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmAllocation), MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WddmMemoryOperationsHandlerTest, givenRegularAllocatioWhenEvictingResidentAllocationExpectEvictCalled) {
|
TEST_F(WddmMemoryOperationsHandlerTest, givenRegularAllocatioWhenEvictingResidentAllocationExpectEvictCalled) {
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->evict(wddmAllocation), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(wddmMemoryOperationsHandler->evict(nullptr, wddmAllocation), MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(wddmAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
|
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WddmMemoryOperationsHandlerTest, givenFragmentedAllocationWhenEvictingResidentAllocationExpectEvictCalled) {
|
TEST_F(WddmMemoryOperationsHandlerTest, givenFragmentedAllocationWhenEvictingResidentAllocationExpectEvictCalled) {
|
||||||
allocationPtr = &wddmFragmentedAllocation;
|
allocationPtr = &wddmFragmentedAllocation;
|
||||||
|
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocationPtr, 1)), MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->evict(wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(wddmMemoryOperationsHandler->evict(nullptr, wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(wddmFragmentedAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
|
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmFragmentedAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WddmMemoryOperationsHandlerTest, givenVariousAllocationsWhenEvictingResidentAllocationExpectEvictCalled) {
|
TEST_F(WddmMemoryOperationsHandlerTest, givenVariousAllocationsWhenEvictingResidentAllocationExpectEvictCalled) {
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(ArrayRef<GraphicsAllocation *>(allocationData)), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(wddmMemoryOperationsHandler->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(allocationData)), MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->evict(wddmAllocation), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(wddmMemoryOperationsHandler->evict(nullptr, wddmAllocation), MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(wddmAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
|
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->evict(wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(wddmMemoryOperationsHandler->evict(nullptr, wddmFragmentedAllocation), MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(wddmFragmentedAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
|
EXPECT_EQ(wddmMemoryOperationsHandler->isResident(nullptr, wddmFragmentedAllocation), MemoryOperationsStatus::MEMORY_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(WddmResidentBufferTests, whenBuffersIsCreatedWithMakeResidentFlagSetThenItIsMadeResidentUponCreation) {
|
TEST(WddmResidentBufferTests, whenBuffersIsCreatedWithMakeResidentFlagSetThenItIsMadeResidentUponCreation) {
|
||||||
@ -110,7 +111,7 @@ TEST(WddmResidentBufferTests, whenBuffersIsCreatedWithMakeResidentFlagSetThenItI
|
|||||||
auto memoryOperationsHandler = device->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
auto memoryOperationsHandler = device->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
||||||
auto neoBuffer = castToObject<MemObj>(clBuffer);
|
auto neoBuffer = castToObject<MemObj>(clBuffer);
|
||||||
auto bufferAllocation = neoBuffer->getGraphicsAllocation(device->getRootDeviceIndex());
|
auto bufferAllocation = neoBuffer->getGraphicsAllocation(device->getRootDeviceIndex());
|
||||||
auto status = memoryOperationsHandler->isResident(*bufferAllocation);
|
auto status = memoryOperationsHandler->isResident(nullptr, *bufferAllocation);
|
||||||
|
|
||||||
EXPECT_EQ(status, MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(status, MemoryOperationsStatus::SUCCESS);
|
||||||
|
|
||||||
|
@ -253,4 +253,8 @@ NEO::SourceLevelDebugger *Device::getSourceLevelDebugger() {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<EngineControl> &Device::getEngines() const {
|
||||||
|
return this->engines;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
@ -61,6 +61,7 @@ class Device : public ReferenceTrackedObject<Device> {
|
|||||||
MOCKABLE_VIRTUAL bool isDebuggerActive() const;
|
MOCKABLE_VIRTUAL bool isDebuggerActive() const;
|
||||||
Debugger *getDebugger() { return getRootDeviceEnvironment().debugger.get(); }
|
Debugger *getDebugger() { return getRootDeviceEnvironment().debugger.get(); }
|
||||||
NEO::SourceLevelDebugger *getSourceLevelDebugger();
|
NEO::SourceLevelDebugger *getSourceLevelDebugger();
|
||||||
|
const std::vector<EngineControl> &getEngines() const;
|
||||||
|
|
||||||
ExecutionEnvironment *getExecutionEnvironment() const { return executionEnvironment; }
|
ExecutionEnvironment *getExecutionEnvironment() const { return executionEnvironment; }
|
||||||
const RootDeviceEnvironment &getRootDeviceEnvironment() const { return *executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]; }
|
const RootDeviceEnvironment &getRootDeviceEnvironment() const { return *executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]; }
|
||||||
|
@ -59,7 +59,7 @@ bool WddmDirectSubmission<GfxFamily, Dispatcher>::allocateOsResources(DirectSubm
|
|||||||
bool ret = wddm->getWddmInterface()->createMonitoredFence(ringFence);
|
bool ret = wddm->getWddmInterface()->createMonitoredFence(ringFence);
|
||||||
ringFence.currentFenceValue = 1;
|
ringFence.currentFenceValue = 1;
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ret = memoryInterface->makeResident(ArrayRef<GraphicsAllocation *>(allocations)) == MemoryOperationsStatus::SUCCESS;
|
ret = memoryInterface->makeResident(&device, ArrayRef<GraphicsAllocation *>(allocations)) == MemoryOperationsStatus::SUCCESS;
|
||||||
}
|
}
|
||||||
perfLogResidencyVariadicLog(wddm->getResidencyLogger(), "ULLS resource allocation finished with: %d\n", ret);
|
perfLogResidencyVariadicLog(wddm->getResidencyLogger(), "ULLS resource allocation finished with: %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -73,4 +73,5 @@ uint32_t GraphicsAllocation::getUsedPageSize() const {
|
|||||||
|
|
||||||
constexpr uint32_t GraphicsAllocation::objectNotUsed;
|
constexpr uint32_t GraphicsAllocation::objectNotUsed;
|
||||||
constexpr uint32_t GraphicsAllocation::objectNotResident;
|
constexpr uint32_t GraphicsAllocation::objectNotResident;
|
||||||
|
constexpr uint32_t GraphicsAllocation::objectAlwaysResident;
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
@ -183,7 +183,12 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
|||||||
void setInspectionId(uint32_t newInspectionId, uint32_t contextId) { usageInfos[contextId].inspectionId = newInspectionId; }
|
void setInspectionId(uint32_t newInspectionId, uint32_t contextId) { usageInfos[contextId].inspectionId = newInspectionId; }
|
||||||
|
|
||||||
bool isResident(uint32_t contextId) const { return GraphicsAllocation::objectNotResident != getResidencyTaskCount(contextId); }
|
bool isResident(uint32_t contextId) const { return GraphicsAllocation::objectNotResident != getResidencyTaskCount(contextId); }
|
||||||
void updateResidencyTaskCount(uint32_t newTaskCount, uint32_t contextId) { usageInfos[contextId].residencyTaskCount = newTaskCount; }
|
bool isAlwaysResident(uint32_t contextId) const { return GraphicsAllocation::objectAlwaysResident == getResidencyTaskCount(contextId); }
|
||||||
|
void updateResidencyTaskCount(uint32_t newTaskCount, uint32_t contextId) {
|
||||||
|
if (usageInfos[contextId].residencyTaskCount != GraphicsAllocation::objectAlwaysResident || newTaskCount == GraphicsAllocation::objectNotResident) {
|
||||||
|
usageInfos[contextId].residencyTaskCount = newTaskCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
uint32_t getResidencyTaskCount(uint32_t contextId) const { return usageInfos[contextId].residencyTaskCount; }
|
uint32_t getResidencyTaskCount(uint32_t contextId) const { return usageInfos[contextId].residencyTaskCount; }
|
||||||
void releaseResidencyInOsContext(uint32_t contextId) { updateResidencyTaskCount(objectNotResident, contextId); }
|
void releaseResidencyInOsContext(uint32_t contextId) { updateResidencyTaskCount(objectNotResident, contextId); }
|
||||||
bool isResidencyTaskCountBelow(uint32_t taskCount, uint32_t contextId) const { return !isResident(contextId) || getResidencyTaskCount(contextId) < taskCount; }
|
bool isResidencyTaskCountBelow(uint32_t taskCount, uint32_t contextId) const { return !isResident(contextId) || getResidencyTaskCount(contextId) < taskCount; }
|
||||||
@ -242,6 +247,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
|||||||
static constexpr uint32_t allBanks = 0xffffffff;
|
static constexpr uint32_t allBanks = 0xffffffff;
|
||||||
constexpr static uint32_t objectNotResident = std::numeric_limits<uint32_t>::max();
|
constexpr static uint32_t objectNotResident = std::numeric_limits<uint32_t>::max();
|
||||||
constexpr static uint32_t objectNotUsed = std::numeric_limits<uint32_t>::max();
|
constexpr static uint32_t objectNotUsed = std::numeric_limits<uint32_t>::max();
|
||||||
|
constexpr static uint32_t objectAlwaysResident = std::numeric_limits<uint32_t>::max() - 1;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct UsageInfo {
|
struct UsageInfo {
|
||||||
|
@ -9,8 +9,10 @@
|
|||||||
#include "shared/source/memory_manager/memory_operations_status.h"
|
#include "shared/source/memory_manager/memory_operations_status.h"
|
||||||
#include "shared/source/utilities/arrayref.h"
|
#include "shared/source/utilities/arrayref.h"
|
||||||
|
|
||||||
namespace NEO {
|
#include <vector>
|
||||||
|
|
||||||
|
namespace NEO {
|
||||||
|
class Device;
|
||||||
class GraphicsAllocation;
|
class GraphicsAllocation;
|
||||||
|
|
||||||
class MemoryOperationsHandler {
|
class MemoryOperationsHandler {
|
||||||
@ -18,8 +20,8 @@ class MemoryOperationsHandler {
|
|||||||
MemoryOperationsHandler() = default;
|
MemoryOperationsHandler() = default;
|
||||||
virtual ~MemoryOperationsHandler() = default;
|
virtual ~MemoryOperationsHandler() = default;
|
||||||
|
|
||||||
virtual MemoryOperationsStatus makeResident(ArrayRef<GraphicsAllocation *> gfxAllocations) = 0;
|
virtual MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) = 0;
|
||||||
virtual MemoryOperationsStatus evict(GraphicsAllocation &gfxAllocation) = 0;
|
virtual MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) = 0;
|
||||||
virtual MemoryOperationsStatus isResident(GraphicsAllocation &gfxAllocation) = 0;
|
virtual MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) = 0;
|
||||||
};
|
};
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
@ -19,7 +19,7 @@ AubMemoryOperationsHandler::AubMemoryOperationsHandler(aub_stream::AubManager *a
|
|||||||
this->aubManager = aubManager;
|
this->aubManager = aubManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryOperationsStatus AubMemoryOperationsHandler::makeResident(ArrayRef<GraphicsAllocation *> gfxAllocations) {
|
MemoryOperationsStatus AubMemoryOperationsHandler::makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) {
|
||||||
if (!aubManager) {
|
if (!aubManager) {
|
||||||
return MemoryOperationsStatus::DEVICE_UNINITIALIZED;
|
return MemoryOperationsStatus::DEVICE_UNINITIALIZED;
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ MemoryOperationsStatus AubMemoryOperationsHandler::makeResident(ArrayRef<Graphic
|
|||||||
return MemoryOperationsStatus::SUCCESS;
|
return MemoryOperationsStatus::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryOperationsStatus AubMemoryOperationsHandler::evict(GraphicsAllocation &gfxAllocation) {
|
MemoryOperationsStatus AubMemoryOperationsHandler::evict(Device *device, GraphicsAllocation &gfxAllocation) {
|
||||||
auto lock = acquireLock(resourcesLock);
|
auto lock = acquireLock(resourcesLock);
|
||||||
auto itor = std::find(residentAllocations.begin(), residentAllocations.end(), &gfxAllocation);
|
auto itor = std::find(residentAllocations.begin(), residentAllocations.end(), &gfxAllocation);
|
||||||
if (itor == residentAllocations.end()) {
|
if (itor == residentAllocations.end()) {
|
||||||
@ -48,7 +48,7 @@ MemoryOperationsStatus AubMemoryOperationsHandler::evict(GraphicsAllocation &gfx
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryOperationsStatus AubMemoryOperationsHandler::isResident(GraphicsAllocation &gfxAllocation) {
|
MemoryOperationsStatus AubMemoryOperationsHandler::isResident(Device *device, GraphicsAllocation &gfxAllocation) {
|
||||||
auto lock = acquireLock(resourcesLock);
|
auto lock = acquireLock(resourcesLock);
|
||||||
auto itor = std::find(residentAllocations.begin(), residentAllocations.end(), &gfxAllocation);
|
auto itor = std::find(residentAllocations.begin(), residentAllocations.end(), &gfxAllocation);
|
||||||
if (itor == residentAllocations.end()) {
|
if (itor == residentAllocations.end()) {
|
||||||
|
@ -21,9 +21,9 @@ class AubMemoryOperationsHandler : public MemoryOperationsHandler {
|
|||||||
AubMemoryOperationsHandler(aub_stream::AubManager *aubManager);
|
AubMemoryOperationsHandler(aub_stream::AubManager *aubManager);
|
||||||
~AubMemoryOperationsHandler() override = default;
|
~AubMemoryOperationsHandler() override = default;
|
||||||
|
|
||||||
MemoryOperationsStatus makeResident(ArrayRef<GraphicsAllocation *> gfxAllocations) override;
|
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
|
||||||
MemoryOperationsStatus evict(GraphicsAllocation &gfxAllocation) override;
|
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override;
|
||||||
MemoryOperationsStatus isResident(GraphicsAllocation &gfxAllocation) override;
|
MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override;
|
||||||
void setAubManager(aub_stream::AubManager *aubManager);
|
void setAubManager(aub_stream::AubManager *aubManager);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -23,8 +23,12 @@ set(NEO_CORE_OS_INTERFACE_LINUX
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_neo.h
|
${CMAKE_CURRENT_SOURCE_DIR}/drm_neo.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_neo.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/drm_neo.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_null_device.h
|
${CMAKE_CURRENT_SOURCE_DIR}/drm_null_device.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler.h
|
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_bind.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_bind.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/drm_memory_operations_handler_create.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id.h
|
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id_linux.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id_linux.cpp
|
||||||
|
@ -28,30 +28,39 @@ uint64_t DrmAllocation::peekInternalHandle(MemoryManager *memoryManager) {
|
|||||||
return static_cast<uint64_t>((static_cast<DrmMemoryManager *>(memoryManager))->obtainFdFromHandle(getBO()->peekHandle(), this->rootDeviceIndex));
|
return static_cast<uint64_t>((static_cast<DrmMemoryManager *>(memoryManager))->obtainFdFromHandle(getBO()->peekHandle(), this->rootDeviceIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmAllocation::getBOsForResidency(uint32_t osContextId, uint32_t handleId, std::vector<BufferObject *> &bufferObjects) {
|
void DrmAllocation::makeBOsResident(uint32_t osContextId, uint32_t drmContextId, uint32_t handleId, std::vector<BufferObject *> *bufferObjects, bool bind) {
|
||||||
if (this->fragmentsStorage.fragmentCount) {
|
if (this->fragmentsStorage.fragmentCount) {
|
||||||
for (unsigned int f = 0; f < this->fragmentsStorage.fragmentCount; f++) {
|
for (unsigned int f = 0; f < this->fragmentsStorage.fragmentCount; f++) {
|
||||||
if (!this->fragmentsStorage.fragmentStorageData[f].residency->resident[osContextId]) {
|
if (!this->fragmentsStorage.fragmentStorageData[f].residency->resident[osContextId]) {
|
||||||
appendBO(this->fragmentsStorage.fragmentStorageData[f].osHandleStorage->bo, bufferObjects);
|
bindBO(this->fragmentsStorage.fragmentStorageData[f].osHandleStorage->bo, drmContextId, bufferObjects, bind);
|
||||||
this->fragmentsStorage.fragmentStorageData[f].residency->resident[osContextId] = true;
|
this->fragmentsStorage.fragmentStorageData[f].residency->resident[osContextId] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
appendBOs(handleId, bufferObjects);
|
bindBOs(handleId, drmContextId, bufferObjects, bind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmAllocation::appendBO(BufferObject *bo, std::vector<BufferObject *> &bufferObjects) {
|
void DrmAllocation::bindBO(BufferObject *bo, uint32_t drmContextId, std::vector<BufferObject *> *bufferObjects, bool bind) {
|
||||||
if (bo) {
|
if (bo) {
|
||||||
if (bo->peekIsReusableAllocation()) {
|
if (bufferObjects) {
|
||||||
for (auto bufferObject : bufferObjects) {
|
if (bo->peekIsReusableAllocation()) {
|
||||||
if (bufferObject == bo) {
|
for (auto bufferObject : *bufferObjects) {
|
||||||
return;
|
if (bufferObject == bo) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bufferObjects.push_back(bo);
|
bufferObjects->push_back(bo);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (bind) {
|
||||||
|
bo->bind(drmContextId);
|
||||||
|
} else {
|
||||||
|
bo->unbind(drmContextId);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,9 +60,9 @@ class DrmAllocation : public GraphicsAllocation {
|
|||||||
|
|
||||||
uint64_t peekInternalHandle(MemoryManager *memoryManager) override;
|
uint64_t peekInternalHandle(MemoryManager *memoryManager) override;
|
||||||
|
|
||||||
void getBOsForResidency(uint32_t osContextId, uint32_t handleId, std::vector<BufferObject *> &bufferObjects);
|
void makeBOsResident(uint32_t osContextId, uint32_t drmContextId, uint32_t handleId, std::vector<BufferObject *> *bufferObjects, bool bind);
|
||||||
void appendBO(BufferObject *bo, std::vector<BufferObject *> &bufferObjects);
|
void bindBO(BufferObject *bo, uint32_t drmContextId, std::vector<BufferObject *> *bufferObjects, bool bind);
|
||||||
void appendBOs(uint32_t handleId, std::vector<BufferObject *> &bufferObjects);
|
void bindBOs(uint32_t handleId, uint32_t drmContextId, std::vector<BufferObject *> *bufferObjects, bool bind);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BufferObjects bufferObjects{};
|
BufferObjects bufferObjects{};
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
|
||||||
void DrmAllocation::appendBOs(uint32_t handleId, std::vector<BufferObject *> &bufferObjects) {
|
void DrmAllocation::bindBOs(uint32_t handleId, uint32_t drmContextId, std::vector<BufferObject *> *bufferObjects, bool bind) {
|
||||||
auto bo = this->getBO();
|
auto bo = this->getBO();
|
||||||
appendBO(bo, bufferObjects);
|
bindBO(bo, drmContextId, bufferObjects, bind);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
@ -128,6 +128,20 @@ int BufferObject::exec(uint32_t used, size_t startOffset, unsigned int flags, bo
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BufferObject::bind(uint32_t drmContextId) {
|
||||||
|
auto ret = this->drm->bindBufferObject(drmContextId, this);
|
||||||
|
auto err = this->drm->getErrno();
|
||||||
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "bind buffer object returned with %d. errno=%d(%s)\n", ret, err, strerror(err));
|
||||||
|
UNRECOVERABLE_IF(ret != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BufferObject::unbind(uint32_t drmContextId) {
|
||||||
|
auto ret = this->drm->unbindBufferObject(drmContextId, this);
|
||||||
|
auto err = this->drm->getErrno();
|
||||||
|
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "unbind buffer object returned with %d. errno=%d(%s)\n", ret, err, strerror(err));
|
||||||
|
UNRECOVERABLE_IF(ret != 0);
|
||||||
|
}
|
||||||
|
|
||||||
void BufferObject::printExecutionBuffer(drm_i915_gem_execbuffer2 &execbuf, const size_t &residencyCount, drm_i915_gem_exec_object2 *execObjectsStorage) {
|
void BufferObject::printExecutionBuffer(drm_i915_gem_execbuffer2 &execbuf, const size_t &residencyCount, drm_i915_gem_exec_object2 *execObjectsStorage) {
|
||||||
std::string logger = "drm_i915_gem_execbuffer2 {\n";
|
std::string logger = "drm_i915_gem_execbuffer2 {\n";
|
||||||
logger += " buffers_ptr: " + std::to_string(execbuf.buffers_ptr) + ",\n";
|
logger += " buffers_ptr: " + std::to_string(execbuf.buffers_ptr) + ",\n";
|
||||||
|
@ -33,6 +33,9 @@ class BufferObject {
|
|||||||
|
|
||||||
int exec(uint32_t used, size_t startOffset, unsigned int flags, bool requiresCoherency, uint32_t drmContextId, BufferObject *const residency[], size_t residencyCount, drm_i915_gem_exec_object2 *execObjectsStorage);
|
int exec(uint32_t used, size_t startOffset, unsigned int flags, bool requiresCoherency, uint32_t drmContextId, BufferObject *const residency[], size_t residencyCount, drm_i915_gem_exec_object2 *execObjectsStorage);
|
||||||
|
|
||||||
|
void bind(uint32_t drmContextId);
|
||||||
|
void unbind(uint32_t drmContextId);
|
||||||
|
|
||||||
void printExecutionBuffer(drm_i915_gem_execbuffer2 &execbuf, const size_t &residencyCount, drm_i915_gem_exec_object2 *execObjectsStorage);
|
void printExecutionBuffer(drm_i915_gem_execbuffer2 &execbuf, const size_t &residencyCount, drm_i915_gem_exec_object2 *execObjectsStorage);
|
||||||
|
|
||||||
int wait(int64_t timeoutNs);
|
int wait(int64_t timeoutNs);
|
||||||
|
@ -589,7 +589,10 @@ void DrmMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocation *gf
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) {
|
void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) {
|
||||||
executionEnvironment.rootDeviceEnvironments[gfxAllocation->getRootDeviceIndex()]->memoryOperationsInterface->evict(*gfxAllocation);
|
for (auto &engine : this->registeredEngines) {
|
||||||
|
auto memoryOperationsInterface = static_cast<DrmMemoryOperationsHandler *>(executionEnvironment.rootDeviceEnvironments[gfxAllocation->getRootDeviceIndex()]->memoryOperationsInterface.get());
|
||||||
|
memoryOperationsInterface->evictWithinOsContext(engine.osContext, *gfxAllocation);
|
||||||
|
}
|
||||||
|
|
||||||
for (auto handleId = 0u; handleId < gfxAllocation->getNumGmms(); handleId++) {
|
for (auto handleId = 0u; handleId < gfxAllocation->getNumGmms(); handleId++) {
|
||||||
delete gfxAllocation->getGmm(handleId);
|
delete gfxAllocation->getGmm(handleId);
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019-2020 Intel Corporation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
namespace NEO {
|
|
||||||
|
|
||||||
DrmMemoryOperationsHandler::DrmMemoryOperationsHandler() = default;
|
|
||||||
DrmMemoryOperationsHandler::~DrmMemoryOperationsHandler() = default;
|
|
||||||
|
|
||||||
MemoryOperationsStatus DrmMemoryOperationsHandler::makeResident(ArrayRef<GraphicsAllocation *> gfxAllocations) {
|
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
|
||||||
this->residency.insert(gfxAllocations.begin(), gfxAllocations.end());
|
|
||||||
return MemoryOperationsStatus::SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryOperationsStatus DrmMemoryOperationsHandler::evict(GraphicsAllocation &gfxAllocation) {
|
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
|
||||||
this->residency.erase(&gfxAllocation);
|
|
||||||
return MemoryOperationsStatus::SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryOperationsStatus DrmMemoryOperationsHandler::isResident(GraphicsAllocation &gfxAllocation) {
|
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
|
||||||
auto ret = this->residency.find(&gfxAllocation);
|
|
||||||
if (ret == this->residency.end()) {
|
|
||||||
return MemoryOperationsStatus::MEMORY_NOT_FOUND;
|
|
||||||
}
|
|
||||||
return MemoryOperationsStatus::SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrmMemoryOperationsHandler::mergeWithResidencyContainer(ResidencyContainer &residencyContainer) {
|
|
||||||
for (auto gfxAllocation = this->residency.begin(); gfxAllocation != this->residency.end(); gfxAllocation++) {
|
|
||||||
auto ret = std::find(residencyContainer.begin(), residencyContainer.end(), *gfxAllocation);
|
|
||||||
if (ret == residencyContainer.end()) {
|
|
||||||
residencyContainer.push_back(*gfxAllocation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_lock<std::mutex> DrmMemoryOperationsHandler::acquireLock() {
|
|
||||||
return std::unique_lock<std::mutex>(this->mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace NEO
|
|
@ -9,25 +9,23 @@
|
|||||||
#include "shared/source/memory_manager/memory_operations_handler.h"
|
#include "shared/source/memory_manager/memory_operations_handler.h"
|
||||||
#include "shared/source/memory_manager/residency_container.h"
|
#include "shared/source/memory_manager/residency_container.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <unordered_set>
|
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
class OsContext;
|
||||||
class DrmMemoryOperationsHandler : public MemoryOperationsHandler {
|
class DrmMemoryOperationsHandler : public MemoryOperationsHandler {
|
||||||
public:
|
public:
|
||||||
DrmMemoryOperationsHandler();
|
DrmMemoryOperationsHandler() = default;
|
||||||
~DrmMemoryOperationsHandler() override;
|
~DrmMemoryOperationsHandler() override = default;
|
||||||
|
|
||||||
MemoryOperationsStatus makeResident(ArrayRef<GraphicsAllocation *> gfxAllocations) override;
|
virtual MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) = 0;
|
||||||
MemoryOperationsStatus evict(GraphicsAllocation &gfxAllocation) override;
|
virtual void mergeWithResidencyContainer(OsContext *osContext, ResidencyContainer &residencyContainer) = 0;
|
||||||
MemoryOperationsStatus isResident(GraphicsAllocation &gfxAllocation) override;
|
virtual std::unique_lock<std::mutex> lockHandlerForExecWA() = 0;
|
||||||
|
|
||||||
void mergeWithResidencyContainer(ResidencyContainer &residencyContainer);
|
static std::unique_ptr<DrmMemoryOperationsHandler> create();
|
||||||
|
|
||||||
std::unique_lock<std::mutex> acquireLock();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unordered_set<GraphicsAllocation *> residency;
|
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
};
|
};
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "shared/source/os_interface/linux/drm_memory_operations_handler_bind.h"
|
||||||
|
|
||||||
|
#include "shared/source/device/device.h"
|
||||||
|
#include "shared/source/os_interface/linux/drm_allocation.h"
|
||||||
|
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
||||||
|
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||||
|
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||||
|
#include "shared/source/os_interface/linux/os_interface.h"
|
||||||
|
|
||||||
|
namespace NEO {
|
||||||
|
|
||||||
|
DrmMemoryOperationsHandlerBind::DrmMemoryOperationsHandlerBind() = default;
|
||||||
|
DrmMemoryOperationsHandlerBind::~DrmMemoryOperationsHandlerBind() = default;
|
||||||
|
|
||||||
|
MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) {
|
||||||
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
auto engines = device->getEngines();
|
||||||
|
for (const auto &engine : engines) {
|
||||||
|
auto &drmContextIds = static_cast<const OsContextLinux *>(engine.osContext)->getDrmContextIds();
|
||||||
|
for (uint32_t drmIterator = 0u; drmIterator < drmContextIds.size(); drmIterator++) {
|
||||||
|
for (auto gfxAllocation = gfxAllocations.begin(); gfxAllocation != gfxAllocations.end(); gfxAllocation++) {
|
||||||
|
auto drmAllocation = static_cast<DrmAllocation *>(*gfxAllocation);
|
||||||
|
if (!drmAllocation->isAlwaysResident(engine.osContext->getContextId())) {
|
||||||
|
drmAllocation->makeBOsResident(engine.osContext->getContextId(), drmContextIds[drmIterator], drmIterator, nullptr, true);
|
||||||
|
drmAllocation->updateResidencyTaskCount(GraphicsAllocation::objectAlwaysResident, engine.osContext->getContextId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return MemoryOperationsStatus::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryOperationsStatus DrmMemoryOperationsHandlerBind::evict(Device *device, GraphicsAllocation &gfxAllocation) {
|
||||||
|
auto engines = device->getEngines();
|
||||||
|
auto retVal = MemoryOperationsStatus::SUCCESS;
|
||||||
|
for (const auto &engine : engines) {
|
||||||
|
retVal = this->evictWithinOsContext(engine.osContext, gfxAllocation);
|
||||||
|
if (retVal != MemoryOperationsStatus::SUCCESS) {
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return MemoryOperationsStatus::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryOperationsStatus DrmMemoryOperationsHandlerBind::evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) {
|
||||||
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
auto &drmContextIds = static_cast<const OsContextLinux *>(osContext)->getDrmContextIds();
|
||||||
|
for (uint32_t drmIterator = 0u; drmIterator < drmContextIds.size(); drmIterator++) {
|
||||||
|
auto drmAllocation = static_cast<DrmAllocation *>(&gfxAllocation);
|
||||||
|
if (drmAllocation->isAlwaysResident(osContext->getContextId())) {
|
||||||
|
drmAllocation->makeBOsResident(osContext->getContextId(), drmContextIds[drmIterator], drmIterator, nullptr, false);
|
||||||
|
drmAllocation->updateResidencyTaskCount(GraphicsAllocation::objectNotResident, osContext->getContextId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return MemoryOperationsStatus::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryOperationsStatus DrmMemoryOperationsHandlerBind::isResident(Device *device, GraphicsAllocation &gfxAllocation) {
|
||||||
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
bool isResident = true;
|
||||||
|
auto engines = device->getEngines();
|
||||||
|
for (const auto &engine : engines) {
|
||||||
|
isResident &= gfxAllocation.isAlwaysResident(engine.osContext->getContextId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isResident) {
|
||||||
|
return MemoryOperationsStatus::SUCCESS;
|
||||||
|
}
|
||||||
|
return MemoryOperationsStatus::MEMORY_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrmMemoryOperationsHandlerBind::mergeWithResidencyContainer(OsContext *osContext, ResidencyContainer &residencyContainer) {
|
||||||
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
for (auto gfxAllocation = residencyContainer.begin(); gfxAllocation != residencyContainer.end();) {
|
||||||
|
if ((*gfxAllocation)->isAlwaysResident(osContext->getContextId())) {
|
||||||
|
gfxAllocation = residencyContainer.erase(gfxAllocation);
|
||||||
|
} else {
|
||||||
|
gfxAllocation++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_lock<std::mutex> DrmMemoryOperationsHandlerBind::lockHandlerForExecWA() {
|
||||||
|
return std::unique_lock<std::mutex>();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace NEO
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||||
|
|
||||||
|
namespace NEO {
|
||||||
|
class DrmMemoryOperationsHandlerBind : public DrmMemoryOperationsHandler {
|
||||||
|
public:
|
||||||
|
DrmMemoryOperationsHandlerBind();
|
||||||
|
~DrmMemoryOperationsHandlerBind() override;
|
||||||
|
|
||||||
|
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
|
||||||
|
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override;
|
||||||
|
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override;
|
||||||
|
MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override;
|
||||||
|
|
||||||
|
void mergeWithResidencyContainer(OsContext *osContext, ResidencyContainer &residencyContainer) override;
|
||||||
|
std::unique_lock<std::mutex> lockHandlerForExecWA() override;
|
||||||
|
};
|
||||||
|
} // namespace NEO
|
@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019-2020 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "shared/source/os_interface/linux/drm_memory_operations_handler_default.h"
|
||||||
|
|
||||||
|
namespace NEO {
|
||||||
|
|
||||||
|
std::unique_ptr<DrmMemoryOperationsHandler> DrmMemoryOperationsHandler::create() {
|
||||||
|
return std::make_unique<DrmMemoryOperationsHandlerDefault>();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace NEO
|
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "shared/source/os_interface/linux/drm_memory_operations_handler_default.h"
|
||||||
|
|
||||||
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace NEO {
|
||||||
|
|
||||||
|
DrmMemoryOperationsHandlerDefault::DrmMemoryOperationsHandlerDefault() = default;
|
||||||
|
DrmMemoryOperationsHandlerDefault::~DrmMemoryOperationsHandlerDefault() = default;
|
||||||
|
|
||||||
|
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) {
|
||||||
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
this->residency.insert(gfxAllocations.begin(), gfxAllocations.end());
|
||||||
|
return MemoryOperationsStatus::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) {
|
||||||
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
this->residency.erase(&gfxAllocation);
|
||||||
|
return MemoryOperationsStatus::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::evict(Device *device, GraphicsAllocation &gfxAllocation) {
|
||||||
|
OsContext *osContext = nullptr;
|
||||||
|
return this->evictWithinOsContext(osContext, gfxAllocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::isResident(Device *device, GraphicsAllocation &gfxAllocation) {
|
||||||
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
auto ret = this->residency.find(&gfxAllocation);
|
||||||
|
if (ret == this->residency.end()) {
|
||||||
|
return MemoryOperationsStatus::MEMORY_NOT_FOUND;
|
||||||
|
}
|
||||||
|
return MemoryOperationsStatus::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrmMemoryOperationsHandlerDefault::mergeWithResidencyContainer(OsContext *osContext, ResidencyContainer &residencyContainer) {
|
||||||
|
for (auto gfxAllocation = this->residency.begin(); gfxAllocation != this->residency.end(); gfxAllocation++) {
|
||||||
|
auto ret = std::find(residencyContainer.begin(), residencyContainer.end(), *gfxAllocation);
|
||||||
|
if (ret == residencyContainer.end()) {
|
||||||
|
residencyContainer.push_back(*gfxAllocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_lock<std::mutex> DrmMemoryOperationsHandlerDefault::lockHandlerForExecWA() {
|
||||||
|
if (DebugManager.flags.MakeAllBuffersResident.get()) {
|
||||||
|
return std::unique_lock<std::mutex>(this->mutex);
|
||||||
|
}
|
||||||
|
return std::unique_lock<std::mutex>();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace NEO
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||||
|
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
|
namespace NEO {
|
||||||
|
class OsContextLinux;
|
||||||
|
class DrmMemoryOperationsHandlerDefault : public DrmMemoryOperationsHandler {
|
||||||
|
public:
|
||||||
|
DrmMemoryOperationsHandlerDefault();
|
||||||
|
~DrmMemoryOperationsHandlerDefault() override;
|
||||||
|
|
||||||
|
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
|
||||||
|
MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override;
|
||||||
|
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override;
|
||||||
|
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override;
|
||||||
|
|
||||||
|
void mergeWithResidencyContainer(OsContext *osContext, ResidencyContainer &residencyContainer) override;
|
||||||
|
std::unique_lock<std::mutex> lockHandlerForExecWA() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::unordered_set<GraphicsAllocation *> residency;
|
||||||
|
};
|
||||||
|
} // namespace NEO
|
@ -29,6 +29,7 @@ struct GT_SYSTEM_INFO;
|
|||||||
namespace NEO {
|
namespace NEO {
|
||||||
#define I915_CONTEXT_PRIVATE_PARAM_BOOST 0x80000000
|
#define I915_CONTEXT_PRIVATE_PARAM_BOOST 0x80000000
|
||||||
|
|
||||||
|
class BufferObject;
|
||||||
class DeviceFactory;
|
class DeviceFactory;
|
||||||
struct HardwareInfo;
|
struct HardwareInfo;
|
||||||
struct RootDeviceEnvironment;
|
struct RootDeviceEnvironment;
|
||||||
@ -86,6 +87,8 @@ class Drm {
|
|||||||
bool createVirtualMemoryAddressSpace(uint32_t vmCount);
|
bool createVirtualMemoryAddressSpace(uint32_t vmCount);
|
||||||
void destroyVirtualMemoryAddressSpace();
|
void destroyVirtualMemoryAddressSpace();
|
||||||
uint32_t getVirtualMemoryAddressSpace(uint32_t vmId);
|
uint32_t getVirtualMemoryAddressSpace(uint32_t vmId);
|
||||||
|
int bindBufferObject(uint32_t drmContextId, BufferObject *bo);
|
||||||
|
int unbindBufferObject(uint32_t drmContextId, BufferObject *bo);
|
||||||
int setupHardwareInfo(DeviceDescriptor *, bool);
|
int setupHardwareInfo(DeviceDescriptor *, bool);
|
||||||
|
|
||||||
bool areNonPersistentContextsSupported() const { return nonPersistentContextsSupported; }
|
bool areNonPersistentContextsSupported() const { return nonPersistentContextsSupported; }
|
||||||
|
@ -41,4 +41,12 @@ unsigned int Drm::bindDrmContext(uint32_t drmContextId, uint32_t deviceIndex, au
|
|||||||
return DrmEngineMapper::engineNodeMap(engineType);
|
return DrmEngineMapper::engineNodeMap(engineType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Drm::bindBufferObject(uint32_t drmContextId, BufferObject *bo) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Drm::unbindBufferObject(uint32_t drmContextId, BufferObject *bo) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
@ -49,4 +49,12 @@ unsigned int Drm::bindDrmContext(uint32_t drmContextId, uint32_t deviceIndex, au
|
|||||||
return DrmEngineMapper::engineNodeMap(engineType);
|
return DrmEngineMapper::engineNodeMap(engineType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Drm::bindBufferObject(uint32_t drmContextId, BufferObject *bo) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Drm::unbindBufferObject(uint32_t drmContextId, BufferObject *bo) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
@ -45,6 +45,10 @@ OsContextLinux::OsContextLinux(Drm &drm, uint32_t contextId, DeviceBitfield devi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Drm &OsContextLinux::getDrm() const {
|
||||||
|
return this->drm;
|
||||||
|
}
|
||||||
|
|
||||||
OsContextLinux::~OsContextLinux() {
|
OsContextLinux::~OsContextLinux() {
|
||||||
for (auto drmContextId : drmContextIds) {
|
for (auto drmContextId : drmContextIds) {
|
||||||
drm.destroyDrmContext(drmContextId);
|
drm.destroyDrmContext(drmContextId);
|
||||||
|
@ -24,6 +24,7 @@ class OsContextLinux : public OsContext {
|
|||||||
|
|
||||||
unsigned int getEngineFlag() const { return engineFlag; }
|
unsigned int getEngineFlag() const { return engineFlag; }
|
||||||
const std::vector<uint32_t> &getDrmContextIds() const { return drmContextIds; }
|
const std::vector<uint32_t> &getDrmContextIds() const { return drmContextIds; }
|
||||||
|
Drm &getDrm() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
unsigned int engineFlag = 0;
|
unsigned int engineFlag = 0;
|
||||||
|
@ -46,7 +46,7 @@ bool RootDeviceEnvironment::initOsInterface(std::unique_ptr<HwDeviceId> &&hwDevi
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
memoryOperationsInterface = DrmMemoryOperationsHandler::create();
|
||||||
osInterface.reset(new OSInterface());
|
osInterface.reset(new OSInterface());
|
||||||
osInterface->get()->setDrm(drm);
|
osInterface->get()->setDrm(drm);
|
||||||
auto hardwareInfo = getMutableHardwareInfo();
|
auto hardwareInfo = getMutableHardwareInfo();
|
||||||
|
@ -392,7 +392,7 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
|
|||||||
residencyController.removeFromTrimCandidateListIfUsed(input, true);
|
residencyController.removeFromTrimCandidateListIfUsed(input, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
executionEnvironment.rootDeviceEnvironments[gfxAllocation->getRootDeviceIndex()]->memoryOperationsInterface->evict(*input);
|
executionEnvironment.rootDeviceEnvironments[gfxAllocation->getRootDeviceIndex()]->memoryOperationsInterface->evict(nullptr, *input);
|
||||||
|
|
||||||
auto defaultGmm = gfxAllocation->getDefaultGmm();
|
auto defaultGmm = gfxAllocation->getDefaultGmm();
|
||||||
if (defaultGmm) {
|
if (defaultGmm) {
|
||||||
|
@ -18,7 +18,7 @@ WddmMemoryOperationsHandler::WddmMemoryOperationsHandler(Wddm *wddm) : wddm(wddm
|
|||||||
residentAllocations = std::make_unique<WddmResidentAllocationsContainer>(wddm);
|
residentAllocations = std::make_unique<WddmResidentAllocationsContainer>(wddm);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryOperationsStatus WddmMemoryOperationsHandler::makeResident(ArrayRef<GraphicsAllocation *> gfxAllocations) {
|
MemoryOperationsStatus WddmMemoryOperationsHandler::makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) {
|
||||||
uint32_t totalHandlesCount = 0;
|
uint32_t totalHandlesCount = 0;
|
||||||
constexpr uint32_t stackAllocations = 64;
|
constexpr uint32_t stackAllocations = 64;
|
||||||
constexpr uint32_t stackHandlesCount = NEO::maxFragmentsCount * EngineLimits::maxHandleCount * stackAllocations;
|
constexpr uint32_t stackHandlesCount = NEO::maxFragmentsCount * EngineLimits::maxHandleCount * stackAllocations;
|
||||||
@ -44,7 +44,7 @@ MemoryOperationsStatus WddmMemoryOperationsHandler::makeResident(ArrayRef<Graphi
|
|||||||
return residentAllocations->makeResidentResources(handlesForResidency.begin(), totalHandlesCount, totalSize);
|
return residentAllocations->makeResidentResources(handlesForResidency.begin(), totalHandlesCount, totalSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryOperationsStatus WddmMemoryOperationsHandler::evict(GraphicsAllocation &gfxAllocation) {
|
MemoryOperationsStatus WddmMemoryOperationsHandler::evict(Device *device, GraphicsAllocation &gfxAllocation) {
|
||||||
constexpr uint32_t stackHandlesCount = NEO::maxFragmentsCount * EngineLimits::maxHandleCount;
|
constexpr uint32_t stackHandlesCount = NEO::maxFragmentsCount * EngineLimits::maxHandleCount;
|
||||||
StackVec<D3DKMT_HANDLE, stackHandlesCount> handlesForEviction;
|
StackVec<D3DKMT_HANDLE, stackHandlesCount> handlesForEviction;
|
||||||
WddmAllocation &wddmAllocation = reinterpret_cast<WddmAllocation &>(gfxAllocation);
|
WddmAllocation &wddmAllocation = reinterpret_cast<WddmAllocation &>(gfxAllocation);
|
||||||
@ -67,7 +67,7 @@ MemoryOperationsStatus WddmMemoryOperationsHandler::evict(GraphicsAllocation &gf
|
|||||||
return residentAllocations->evictResources(handlesForEviction.begin(), totalHandleCount);
|
return residentAllocations->evictResources(handlesForEviction.begin(), totalHandleCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryOperationsStatus WddmMemoryOperationsHandler::isResident(GraphicsAllocation &gfxAllocation) {
|
MemoryOperationsStatus WddmMemoryOperationsHandler::isResident(Device *device, GraphicsAllocation &gfxAllocation) {
|
||||||
WddmAllocation &wddmAllocation = reinterpret_cast<WddmAllocation &>(gfxAllocation);
|
WddmAllocation &wddmAllocation = reinterpret_cast<WddmAllocation &>(gfxAllocation);
|
||||||
D3DKMT_HANDLE defaultHandle = 0u;
|
D3DKMT_HANDLE defaultHandle = 0u;
|
||||||
if (wddmAllocation.fragmentsStorage.fragmentCount > 0) {
|
if (wddmAllocation.fragmentsStorage.fragmentCount > 0) {
|
||||||
|
@ -20,9 +20,9 @@ class WddmMemoryOperationsHandler : public MemoryOperationsHandler {
|
|||||||
WddmMemoryOperationsHandler(Wddm *wddm);
|
WddmMemoryOperationsHandler(Wddm *wddm);
|
||||||
~WddmMemoryOperationsHandler() override = default;
|
~WddmMemoryOperationsHandler() override = default;
|
||||||
|
|
||||||
MemoryOperationsStatus makeResident(ArrayRef<GraphicsAllocation *> gfxAllocations) override;
|
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
|
||||||
MemoryOperationsStatus evict(GraphicsAllocation &gfxAllocation) override;
|
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override;
|
||||||
MemoryOperationsStatus isResident(GraphicsAllocation &gfxAllocation) override;
|
MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Wddm *wddm;
|
Wddm *wddm;
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
TEST_F(AubMemoryOperationsHandlerTests, givenNullPtrAsAubManagerWhenMakeResidentCalledThenFalseReturned) {
|
TEST_F(AubMemoryOperationsHandlerTests, givenNullPtrAsAubManagerWhenMakeResidentCalledThenFalseReturned) {
|
||||||
getMemoryOperationsHandler()->setAubManager(nullptr);
|
getMemoryOperationsHandler()->setAubManager(nullptr);
|
||||||
auto memoryOperationsInterface = getMemoryOperationsHandler();
|
auto memoryOperationsInterface = getMemoryOperationsHandler();
|
||||||
auto result = memoryOperationsInterface->makeResident(ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
|
auto result = memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
|
||||||
EXPECT_EQ(result, MemoryOperationsStatus::DEVICE_UNINITIALIZED);
|
EXPECT_EQ(result, MemoryOperationsStatus::DEVICE_UNINITIALIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledThe
|
|||||||
MockAubManager aubManager;
|
MockAubManager aubManager;
|
||||||
getMemoryOperationsHandler()->setAubManager(&aubManager);
|
getMemoryOperationsHandler()->setAubManager(&aubManager);
|
||||||
auto memoryOperationsInterface = getMemoryOperationsHandler();
|
auto memoryOperationsInterface = getMemoryOperationsHandler();
|
||||||
auto result = memoryOperationsInterface->makeResident(ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
|
auto result = memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
|
||||||
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
|
||||||
EXPECT_TRUE(aubManager.writeMemoryCalled);
|
EXPECT_TRUE(aubManager.writeMemoryCalled);
|
||||||
}
|
}
|
||||||
@ -30,36 +30,36 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAllocationWhenMakeResidentCalledThe
|
|||||||
MockAubManager aubManager;
|
MockAubManager aubManager;
|
||||||
getMemoryOperationsHandler()->setAubManager(&aubManager);
|
getMemoryOperationsHandler()->setAubManager(&aubManager);
|
||||||
auto memoryOperationsInterface = getMemoryOperationsHandler();
|
auto memoryOperationsInterface = getMemoryOperationsHandler();
|
||||||
memoryOperationsInterface->makeResident(ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
|
memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
|
||||||
EXPECT_EQ(aubManager.hintToWriteMemory, AubMemDump::DataTypeHintValues::TraceNotype);
|
EXPECT_EQ(aubManager.hintToWriteMemory, AubMemDump::DataTypeHintValues::TraceNotype);
|
||||||
}
|
}
|
||||||
TEST_F(AubMemoryOperationsHandlerTests, givenNonResidentAllocationWhenIsResidentCalledThenFalseReturned) {
|
TEST_F(AubMemoryOperationsHandlerTests, givenNonResidentAllocationWhenIsResidentCalledThenFalseReturned) {
|
||||||
MockAubManager aubManager;
|
MockAubManager aubManager;
|
||||||
getMemoryOperationsHandler()->setAubManager(&aubManager);
|
getMemoryOperationsHandler()->setAubManager(&aubManager);
|
||||||
auto memoryOperationsInterface = getMemoryOperationsHandler();
|
auto memoryOperationsInterface = getMemoryOperationsHandler();
|
||||||
auto result = memoryOperationsInterface->isResident(allocation);
|
auto result = memoryOperationsInterface->isResident(nullptr, allocation);
|
||||||
EXPECT_EQ(result, MemoryOperationsStatus::MEMORY_NOT_FOUND);
|
EXPECT_EQ(result, MemoryOperationsStatus::MEMORY_NOT_FOUND);
|
||||||
}
|
}
|
||||||
TEST_F(AubMemoryOperationsHandlerTests, givenResidentAllocationWhenIsResidentCalledThenTrueReturned) {
|
TEST_F(AubMemoryOperationsHandlerTests, givenResidentAllocationWhenIsResidentCalledThenTrueReturned) {
|
||||||
MockAubManager aubManager;
|
MockAubManager aubManager;
|
||||||
getMemoryOperationsHandler()->setAubManager(&aubManager);
|
getMemoryOperationsHandler()->setAubManager(&aubManager);
|
||||||
auto memoryOperationsInterface = getMemoryOperationsHandler();
|
auto memoryOperationsInterface = getMemoryOperationsHandler();
|
||||||
memoryOperationsInterface->makeResident(ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
|
memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
|
||||||
auto result = memoryOperationsInterface->isResident(allocation);
|
auto result = memoryOperationsInterface->isResident(nullptr, allocation);
|
||||||
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
|
||||||
}
|
}
|
||||||
TEST_F(AubMemoryOperationsHandlerTests, givenNonResidentAllocationWhenEvictCalledThenFalseReturned) {
|
TEST_F(AubMemoryOperationsHandlerTests, givenNonResidentAllocationWhenEvictCalledThenFalseReturned) {
|
||||||
MockAubManager aubManager;
|
MockAubManager aubManager;
|
||||||
getMemoryOperationsHandler()->setAubManager(&aubManager);
|
getMemoryOperationsHandler()->setAubManager(&aubManager);
|
||||||
auto memoryOperationsInterface = getMemoryOperationsHandler();
|
auto memoryOperationsInterface = getMemoryOperationsHandler();
|
||||||
auto result = memoryOperationsInterface->evict(allocation);
|
auto result = memoryOperationsInterface->evict(nullptr, allocation);
|
||||||
EXPECT_EQ(result, MemoryOperationsStatus::MEMORY_NOT_FOUND);
|
EXPECT_EQ(result, MemoryOperationsStatus::MEMORY_NOT_FOUND);
|
||||||
}
|
}
|
||||||
TEST_F(AubMemoryOperationsHandlerTests, givenResidentAllocationWhenEvictCalledThenTrueReturned) {
|
TEST_F(AubMemoryOperationsHandlerTests, givenResidentAllocationWhenEvictCalledThenTrueReturned) {
|
||||||
MockAubManager aubManager;
|
MockAubManager aubManager;
|
||||||
getMemoryOperationsHandler()->setAubManager(&aubManager);
|
getMemoryOperationsHandler()->setAubManager(&aubManager);
|
||||||
auto memoryOperationsInterface = getMemoryOperationsHandler();
|
auto memoryOperationsInterface = getMemoryOperationsHandler();
|
||||||
memoryOperationsInterface->makeResident(ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
|
memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
|
||||||
auto result = memoryOperationsInterface->evict(allocation);
|
auto result = memoryOperationsInterface->evict(nullptr, allocation);
|
||||||
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
|
EXPECT_EQ(result, MemoryOperationsStatus::SUCCESS);
|
||||||
}
|
}
|
Reference in New Issue
Block a user