mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Remove residency control from Buffer Object.
- Residency is being controlled by Graphics Allocation. - Duplicates are now eliminated only for shared resources. Change-Id: Ib51e2739a07728ae0b94abf6cce2e9981b017111
This commit is contained in:
committed by
sys_ocldev
parent
0942edd6af
commit
3c0a6bd24d
@@ -17,6 +17,7 @@
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/helpers/execution_environment_helper.h"
|
||||
#include "unit_tests/helpers/hw_parse.h"
|
||||
#include "unit_tests/mocks/linux/mock_drm_command_stream_receiver.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "unit_tests/mocks/mock_host_ptr_manager.h"
|
||||
#include "unit_tests/mocks/mock_submissions_aggregator.h"
|
||||
@@ -688,7 +689,7 @@ class DrmCommandStreamEnhancedFixture
|
||||
}
|
||||
|
||||
bool isResident(BufferObject *bo) {
|
||||
return tCsr->isResident(bo) && bo->peekIsResident();
|
||||
return tCsr->isResident(bo);
|
||||
}
|
||||
|
||||
const BufferObject *getResident(BufferObject *bo) {
|
||||
@@ -696,73 +697,6 @@ class DrmCommandStreamEnhancedFixture
|
||||
}
|
||||
|
||||
protected:
|
||||
template <typename GfxFamily>
|
||||
class TestedDrmCommandStreamReceiver : public DrmCommandStreamReceiver<GfxFamily> {
|
||||
public:
|
||||
using CommandStreamReceiver::commandStream;
|
||||
|
||||
TestedDrmCommandStreamReceiver(gemCloseWorkerMode mode, ExecutionEnvironment &executionEnvironment)
|
||||
: DrmCommandStreamReceiver<GfxFamily>(*platformDevices[0], executionEnvironment, mode) {
|
||||
}
|
||||
TestedDrmCommandStreamReceiver(ExecutionEnvironment &executionEnvironment)
|
||||
: DrmCommandStreamReceiver<GfxFamily>(*platformDevices[0], executionEnvironment,
|
||||
gemCloseWorkerMode::gemCloseWorkerInactive) {
|
||||
}
|
||||
|
||||
void overrideGemCloseWorkerOperationMode(gemCloseWorkerMode overrideValue) {
|
||||
this->gemCloseWorkerOperationMode = overrideValue;
|
||||
}
|
||||
|
||||
void overrideDispatchPolicy(DispatchMode overrideValue) {
|
||||
this->dispatchMode = overrideValue;
|
||||
}
|
||||
|
||||
bool isResident(BufferObject *bo) {
|
||||
bool resident = false;
|
||||
for (auto it : this->residency) {
|
||||
if (it == bo) {
|
||||
resident = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return resident;
|
||||
}
|
||||
|
||||
void makeNonResident(GraphicsAllocation &gfxAllocation) override {
|
||||
makeNonResidentResult.called = true;
|
||||
makeNonResidentResult.allocation = &gfxAllocation;
|
||||
DrmCommandStreamReceiver<GfxFamily>::makeNonResident(gfxAllocation);
|
||||
}
|
||||
|
||||
const BufferObject *getResident(BufferObject *bo) {
|
||||
BufferObject *ret = nullptr;
|
||||
for (auto it : this->residency) {
|
||||
if (it == bo) {
|
||||
ret = it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct MakeResidentNonResidentResult {
|
||||
bool called;
|
||||
GraphicsAllocation *allocation;
|
||||
};
|
||||
|
||||
MakeResidentNonResidentResult makeNonResidentResult;
|
||||
std::vector<BufferObject *> *getResidencyVector() { return &this->residency; }
|
||||
|
||||
SubmissionAggregator *peekSubmissionAggregator() {
|
||||
return this->submissionAggregator.get();
|
||||
}
|
||||
void overrideSubmissionAggregator(SubmissionAggregator *newSubmissionsAggregator) {
|
||||
this->submissionAggregator.reset(newSubmissionsAggregator);
|
||||
}
|
||||
std::vector<drm_i915_gem_exec_object2> &getExecStorage() {
|
||||
return this->execObjectsStorage;
|
||||
}
|
||||
};
|
||||
TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *tCsr = nullptr;
|
||||
|
||||
class MockBufferObject : public BufferObject {
|
||||
@@ -779,6 +713,7 @@ class DrmCommandStreamEnhancedFixture
|
||||
return new MockBufferObject(this->mock, size);
|
||||
}
|
||||
};
|
||||
|
||||
typedef Test<DrmCommandStreamEnhancedFixture> DrmCommandStreamGemWorkerTests;
|
||||
|
||||
TEST_F(DrmCommandStreamGemWorkerTests, givenDefaultDrmCSRWhenItIsCreatedThenGemCloseWorkerModeIsInactive) {
|
||||
@@ -835,8 +770,6 @@ TEST_F(DrmCommandStreamGemWorkerTests, givenTaskThatRequiresLargeResourceCountWh
|
||||
EXPECT_EQ(11u, this->mock->execBuffer.buffer_count);
|
||||
mm->freeGraphicsMemory(commandBuffer);
|
||||
for (auto graphicsAllocation : graphicsAllocations) {
|
||||
DrmAllocation *drmAlloc = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
EXPECT_FALSE(drmAlloc->getBO()->peekIsResident());
|
||||
mm->freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
EXPECT_EQ(11u, execStorage.size());
|
||||
@@ -863,24 +796,24 @@ TEST_F(DrmCommandStreamGemWorkerTests, GivenTwoAllocationsWhenBackingStorageIsDi
|
||||
auto allocation = static_cast<DrmAllocation *>(mm->allocateGraphicsMemory(1024));
|
||||
auto allocation2 = static_cast<DrmAllocation *>(mm->allocateGraphicsMemory(1024));
|
||||
|
||||
auto bo1 = allocation->getBO();
|
||||
auto bo2 = allocation2->getBO();
|
||||
csr->makeResident(*allocation);
|
||||
csr->makeResident(*allocation2);
|
||||
|
||||
EXPECT_FALSE(bo1->peekIsResident());
|
||||
EXPECT_FALSE(bo2->peekIsResident());
|
||||
EXPECT_TRUE(allocation->isResident(0u));
|
||||
EXPECT_TRUE(allocation2->isResident(0u));
|
||||
|
||||
csr->processResidency(csr->getResidencyAllocations(), *osContext);
|
||||
|
||||
EXPECT_TRUE(bo1->peekIsResident());
|
||||
EXPECT_TRUE(bo2->peekIsResident());
|
||||
EXPECT_TRUE(allocation->isResident(0u));
|
||||
EXPECT_TRUE(allocation2->isResident(0u));
|
||||
|
||||
EXPECT_EQ(tCsr->getResidencyVector()->size(), 2u);
|
||||
|
||||
csr->makeNonResident(*allocation);
|
||||
csr->makeNonResident(*allocation2);
|
||||
EXPECT_FALSE(bo1->peekIsResident());
|
||||
EXPECT_FALSE(bo2->peekIsResident());
|
||||
|
||||
EXPECT_FALSE(allocation->isResident(0u));
|
||||
EXPECT_FALSE(allocation2->isResident(0u));
|
||||
|
||||
EXPECT_EQ(tCsr->getResidencyVector()->size(), 0u);
|
||||
mm->freeGraphicsMemory(allocation);
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
#include "runtime/os_interface/linux/drm_buffer_object.h"
|
||||
#include "runtime/os_interface/linux/drm_command_stream.h"
|
||||
#include "runtime/os_interface/linux/drm_memory_manager.h"
|
||||
#include "runtime/os_interface/linux/os_interface.h"
|
||||
#include "runtime/os_interface/32bit_memory.h"
|
||||
#include "runtime/os_interface/os_context.h"
|
||||
#include "runtime/utilities/tag_allocator.h"
|
||||
|
||||
#include "unit_tests/fixtures/memory_management_fixture.h"
|
||||
@@ -30,6 +32,7 @@
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_device.h"
|
||||
#include "unit_tests/mocks/mock_gmm.h"
|
||||
#include "unit_tests/mocks/linux/mock_drm_command_stream_receiver.h"
|
||||
#include "unit_tests/mocks/linux/mock_drm_memory_manager.h"
|
||||
#include "unit_tests/os_interface/linux/device_command_stream_fixture.h"
|
||||
|
||||
@@ -1557,6 +1560,61 @@ TEST_F(DrmMemoryManagerTest, givenSharedHandleWhenAllocationIsCreatedAndIoctlPri
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatShareTheSameBufferObjectWhenTheyAreMadeResidentThenOnlyOneBoIsPassedToExec) {
|
||||
mock->ioctl_expected.primeFdToHandle = 2;
|
||||
mock->ioctl_expected.gemClose = 1;
|
||||
mock->ioctl_expected.gemWait = 2;
|
||||
|
||||
osHandle sharedHandle = 1u;
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, false);
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, false);
|
||||
|
||||
executionEnvironment->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment->osInterface->get()->setDrm(mock);
|
||||
auto testedCsr = new TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment);
|
||||
executionEnvironment->commandStreamReceivers.push_back(std::unique_ptr<CommandStreamReceiver>(testedCsr));
|
||||
|
||||
testedCsr->makeResident(*graphicsAllocation);
|
||||
testedCsr->makeResident(*graphicsAllocation2);
|
||||
EXPECT_EQ(2u, testedCsr->getResidencyAllocations().size());
|
||||
|
||||
OsContext osContext(executionEnvironment->osInterface.get(), 0u);
|
||||
testedCsr->processResidency(testedCsr->getResidencyAllocations(), osContext);
|
||||
|
||||
EXPECT_EQ(1u, testedCsr->residency.size());
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation2);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatDoesnShareTheSameBufferObjectWhenTheyAreMadeResidentThenTwoBoIsPassedToExec) {
|
||||
mock->ioctl_expected.primeFdToHandle = 2;
|
||||
mock->ioctl_expected.gemClose = 2;
|
||||
mock->ioctl_expected.gemWait = 2;
|
||||
|
||||
osHandle sharedHandle = 1u;
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, false);
|
||||
mock->outputHandle++;
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, false);
|
||||
|
||||
executionEnvironment->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment->osInterface->get()->setDrm(mock);
|
||||
auto testedCsr = new TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>(*executionEnvironment);
|
||||
executionEnvironment->commandStreamReceivers.push_back(std::unique_ptr<CommandStreamReceiver>(testedCsr));
|
||||
|
||||
testedCsr->makeResident(*graphicsAllocation);
|
||||
testedCsr->makeResident(*graphicsAllocation2);
|
||||
EXPECT_EQ(2u, testedCsr->getResidencyAllocations().size());
|
||||
|
||||
OsContext osContext(executionEnvironment->osInterface.get(), 0u);
|
||||
testedCsr->processResidency(testedCsr->getResidencyAllocations(), osContext);
|
||||
|
||||
EXPECT_EQ(2u, testedCsr->residency.size());
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation2);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenCreateAllocationFromNtHandleIsCalledThenReturnNullptr) {
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromNTHandle(reinterpret_cast<void *>(1));
|
||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||
@@ -1808,6 +1866,7 @@ TEST_F(DrmMemoryManagerTest, givenSharedAllocationWithSmallerThenRealSizeWhenCre
|
||||
EXPECT_EQ(1, lseekCalledCount);
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenMemoryManagerSupportingVirutalPaddingWhenItIsRequiredThenNewGraphicsAllocationIsCreated) {
|
||||
mock->ioctl_expected.gemUserptr = 3;
|
||||
mock->ioctl_expected.gemWait = 3;
|
||||
|
||||
Reference in New Issue
Block a user