mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 08:53:55 +08:00
Pass maxOsContextCount to BufferObject
Change-Id: I9e64718a5a64096c8fdc50f3b84d3843701ff602 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
53cb6a127d
commit
739c1c6c99
@@ -14,9 +14,10 @@ namespace NEO {
|
|||||||
class MockBufferObject : public BufferObject {
|
class MockBufferObject : public BufferObject {
|
||||||
public:
|
public:
|
||||||
using BufferObject::bindInfo;
|
using BufferObject::bindInfo;
|
||||||
|
using BufferObject::BufferObject;
|
||||||
using BufferObject::handle;
|
using BufferObject::handle;
|
||||||
|
|
||||||
MockBufferObject(Drm *drm) : BufferObject(drm, 0, 0) {
|
MockBufferObject(Drm *drm) : BufferObject(drm, 0, 0, 1) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ using namespace NEO;
|
|||||||
|
|
||||||
class TestedBufferObject : public BufferObject {
|
class TestedBufferObject : public BufferObject {
|
||||||
public:
|
public:
|
||||||
TestedBufferObject(Drm *drm) : BufferObject(drm, 1, 0) {
|
TestedBufferObject(Drm *drm) : BufferObject(drm, 1, 0, 1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void tileBy(uint32_t mode) {
|
void tileBy(uint32_t mode) {
|
||||||
@@ -188,7 +188,7 @@ TEST(DrmBufferObjectSimpleTest, givenInvalidBoWhenPinIsCalledThenErrorIsReturned
|
|||||||
|
|
||||||
TEST(DrmBufferObjectSimpleTest, givenBufferObjectWhenConstructedWithASizeThenTheSizeIsInitialized) {
|
TEST(DrmBufferObjectSimpleTest, givenBufferObjectWhenConstructedWithASizeThenTheSizeIsInitialized) {
|
||||||
std::unique_ptr<DrmMockCustom> drmMock(new DrmMockCustom);
|
std::unique_ptr<DrmMockCustom> drmMock(new DrmMockCustom);
|
||||||
std::unique_ptr<BufferObject> bo(new BufferObject(drmMock.get(), 1, 0x1000));
|
std::unique_ptr<BufferObject> bo(new BufferObject(drmMock.get(), 1, 0x1000, 1));
|
||||||
|
|
||||||
EXPECT_EQ(0x1000u, bo->peekSize());
|
EXPECT_EQ(0x1000u, bo->peekSize());
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ TEST_F(DrmBufferObjectTest, givenDeleterWhenBufferObjectIsCreatedAndDeletedThenC
|
|||||||
mock->ioctl_expected.reset();
|
mock->ioctl_expected.reset();
|
||||||
|
|
||||||
{
|
{
|
||||||
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(new BufferObject(mock.get(), 1, 0x1000));
|
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(new BufferObject(mock.get(), 1, 0x1000, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_EQ(1, mock->ioctl_cnt.gemClose);
|
EXPECT_EQ(1, mock->ioctl_cnt.gemClose);
|
||||||
@@ -245,9 +245,9 @@ TEST(DrmBufferObject, givenPerContextVmRequiredWhenBoCreatedThenBindInfoIsInitia
|
|||||||
device->getExecutionEnvironment()->calculateMaxOsContextCount();
|
device->getExecutionEnvironment()->calculateMaxOsContextCount();
|
||||||
DrmMock drm(*(device->getExecutionEnvironment()->rootDeviceEnvironments[0].get()));
|
DrmMock drm(*(device->getExecutionEnvironment()->rootDeviceEnvironments[0].get()));
|
||||||
EXPECT_TRUE(drm.isPerContextVMRequired());
|
EXPECT_TRUE(drm.isPerContextVMRequired());
|
||||||
MockBufferObject bo(&drm);
|
|
||||||
|
|
||||||
auto osContextCount = device->getExecutionEnvironment()->memoryManager->getRegisteredEnginesCount();
|
auto osContextCount = device->getExecutionEnvironment()->memoryManager->getRegisteredEnginesCount();
|
||||||
|
MockBufferObject bo(&drm, 0, 0, osContextCount);
|
||||||
|
|
||||||
EXPECT_EQ(osContextCount, bo.bindInfo.size());
|
EXPECT_EQ(osContextCount, bo.bindInfo.size());
|
||||||
|
|
||||||
for (auto &iter : bo.bindInfo) {
|
for (auto &iter : bo.bindInfo) {
|
||||||
@@ -273,9 +273,9 @@ TEST(DrmBufferObject, givenPerContextVmRequiredWhenBoBoundAndUnboundThenCorrectB
|
|||||||
|
|
||||||
std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0));
|
std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0));
|
||||||
|
|
||||||
MockBufferObject bo(drm);
|
|
||||||
|
|
||||||
auto osContextCount = device->getExecutionEnvironment()->memoryManager->getRegisteredEnginesCount();
|
auto osContextCount = device->getExecutionEnvironment()->memoryManager->getRegisteredEnginesCount();
|
||||||
|
MockBufferObject bo(drm, 0, 0, osContextCount);
|
||||||
|
|
||||||
EXPECT_EQ(osContextCount, bo.bindInfo.size());
|
EXPECT_EQ(osContextCount, bo.bindInfo.size());
|
||||||
|
|
||||||
auto contextId = device->getExecutionEnvironment()->memoryManager->getRegisteredEnginesCount() / 2;
|
auto contextId = device->getExecutionEnvironment()->memoryManager->getRegisteredEnginesCount() / 2;
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ class DrmCommandStreamEnhancedTemplate : public ::testing::Test {
|
|||||||
friend DrmCommandStreamEnhancedTemplate<T>;
|
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, 16u) {
|
||||||
this->size = alignUp(size, 4096);
|
this->size = alignUp(size, 4096);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ TEST_F(DrmGemCloseWorkerTests, gemClose) {
|
|||||||
this->drmMock->gem_close_expected = 1;
|
this->drmMock->gem_close_expected = 1;
|
||||||
|
|
||||||
auto worker = new DrmGemCloseWorker(*mm);
|
auto worker = new DrmGemCloseWorker(*mm);
|
||||||
auto bo = new BufferObject(this->drmMock, 1, 0);
|
auto bo = new BufferObject(this->drmMock, 1, 0, 1);
|
||||||
|
|
||||||
worker->push(bo);
|
worker->push(bo);
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ TEST_F(DrmGemCloseWorkerTests, gemCloseExit) {
|
|||||||
this->drmMock->gem_close_expected = -1;
|
this->drmMock->gem_close_expected = -1;
|
||||||
|
|
||||||
auto worker = new DrmGemCloseWorker(*mm);
|
auto worker = new DrmGemCloseWorker(*mm);
|
||||||
auto bo = new BufferObject(this->drmMock, 1, 0);
|
auto bo = new BufferObject(this->drmMock, 1, 0, 1);
|
||||||
|
|
||||||
worker->push(bo);
|
worker->push(bo);
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ TEST_F(DrmGemCloseWorkerTests, close) {
|
|||||||
this->drmMock->gem_close_expected = -1;
|
this->drmMock->gem_close_expected = -1;
|
||||||
|
|
||||||
auto worker = new DrmGemCloseWorker(*mm);
|
auto worker = new DrmGemCloseWorker(*mm);
|
||||||
auto bo = new BufferObject(this->drmMock, 1, 0);
|
auto bo = new BufferObject(this->drmMock, 1, 0, 1);
|
||||||
|
|
||||||
worker->push(bo);
|
worker->push(bo);
|
||||||
worker->close(false);
|
worker->close(false);
|
||||||
@@ -153,7 +153,7 @@ TEST_F(DrmGemCloseWorkerTests, givenAllocationWhenAskedForUnreferenceWithForceFl
|
|||||||
this->drmMock->gem_close_expected = 1;
|
this->drmMock->gem_close_expected = 1;
|
||||||
|
|
||||||
auto worker = new DrmGemCloseWorker(*mm);
|
auto worker = new DrmGemCloseWorker(*mm);
|
||||||
auto bo = new BufferObject(this->drmMock, 1, 0);
|
auto bo = new BufferObject(this->drmMock, 1, 0, 1);
|
||||||
|
|
||||||
bo->reference();
|
bo->reference();
|
||||||
worker->push(bo);
|
worker->push(bo);
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenGetLocalMemoryIsCalledThen
|
|||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
|
||||||
BufferObject *createBufferObjectInMemoryRegion(Drm *drm, uint64_t gpuAddress, size_t size, uint32_t memoryBanks);
|
BufferObject *createBufferObjectInMemoryRegion(Drm *drm, uint64_t gpuAddress, size_t size, uint32_t memoryBanks, size_t maxOsContextCount);
|
||||||
|
|
||||||
class DrmMemoryManagerLocalMemoryTest : public ::testing::Test {
|
class DrmMemoryManagerLocalMemoryTest : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
@@ -166,7 +166,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenDrmMemoryManagerWhenCreateBufferObj
|
|||||||
auto gpuAddress = 0x1234u;
|
auto gpuAddress = 0x1234u;
|
||||||
auto size = MemoryConstants::pageSize64k;
|
auto size = MemoryConstants::pageSize64k;
|
||||||
|
|
||||||
auto bo = std::unique_ptr<BufferObject>(createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), gpuAddress, size, (1 << (MemoryBanks::Bank0 - 1))));
|
auto bo = std::unique_ptr<BufferObject>(createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), gpuAddress, size, (1 << (MemoryBanks::Bank0 - 1)), 1));
|
||||||
ASSERT_NE(nullptr, bo);
|
ASSERT_NE(nullptr, bo);
|
||||||
|
|
||||||
EXPECT_EQ(1u, mock->ioctlCallsCount);
|
EXPECT_EQ(1u, mock->ioctlCallsCount);
|
||||||
@@ -195,7 +195,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenDrmMemoryManagerWhenCreateBufferObj
|
|||||||
auto gpuAddress = 0x1234u;
|
auto gpuAddress = 0x1234u;
|
||||||
auto size = MemoryConstants::pageSize;
|
auto size = MemoryConstants::pageSize;
|
||||||
|
|
||||||
auto bo = std::unique_ptr<BufferObject>(createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), gpuAddress, size, MemoryBanks::MainBank));
|
auto bo = std::unique_ptr<BufferObject>(createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), gpuAddress, size, MemoryBanks::MainBank, 1));
|
||||||
EXPECT_EQ(nullptr, bo);
|
EXPECT_EQ(nullptr, bo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenDrmMemoryManagerWhenCreateBufferObj
|
|||||||
auto gpuAddress = 0x1234u;
|
auto gpuAddress = 0x1234u;
|
||||||
auto size = MemoryConstants::pageSize;
|
auto size = MemoryConstants::pageSize;
|
||||||
|
|
||||||
auto bo = std::unique_ptr<BufferObject>(createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), gpuAddress, size, MemoryBanks::MainBank));
|
auto bo = std::unique_ptr<BufferObject>(createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), gpuAddress, size, MemoryBanks::MainBank, 1));
|
||||||
EXPECT_EQ(nullptr, bo);
|
EXPECT_EQ(nullptr, bo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenDrmMemoryManagerWhenCreateBufferObj
|
|||||||
auto gpuAddress = 0x1234u;
|
auto gpuAddress = 0x1234u;
|
||||||
auto size = 0u;
|
auto size = 0u;
|
||||||
|
|
||||||
auto bo = std::unique_ptr<BufferObject>(createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), gpuAddress, size, MemoryBanks::MainBank));
|
auto bo = std::unique_ptr<BufferObject>(createBufferObjectInMemoryRegion(&memoryManager->getDrm(0), gpuAddress, size, MemoryBanks::MainBank, 1));
|
||||||
EXPECT_EQ(nullptr, bo);
|
EXPECT_EQ(nullptr, bo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -643,7 +643,7 @@ TEST_F(DrmMemoryManagerLocalMemoryTest, givenDrmMemoryManagerWithLocalMemoryWhen
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerLocalMemoryWithCustomMockTest, givenDrmMemoryManagerWithLocalMemoryWhenLockResourceIsCalledOnBufferObjectThenReturnPtr) {
|
TEST_F(DrmMemoryManagerLocalMemoryWithCustomMockTest, givenDrmMemoryManagerWithLocalMemoryWhenLockResourceIsCalledOnBufferObjectThenReturnPtr) {
|
||||||
BufferObject bo(mock, 1, 1024);
|
BufferObject bo(mock, 1, 1024, 0);
|
||||||
|
|
||||||
DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, 0u, MemoryPool::LocalMemory);
|
DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, 0u, MemoryPool::LocalMemory);
|
||||||
EXPECT_EQ(&bo, drmAllocation.getBO());
|
EXPECT_EQ(&bo, drmAllocation.getBO());
|
||||||
@@ -657,7 +657,7 @@ TEST_F(DrmMemoryManagerLocalMemoryWithCustomMockTest, givenDrmMemoryManagerWithL
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerLocalMemoryWithCustomMockTest, givenDrmMemoryManagerWithLocalMemoryWhenLockResourceIsCalledOnWriteCombinedAllocationThenReturnPtrAlignedTo64Kb) {
|
TEST_F(DrmMemoryManagerLocalMemoryWithCustomMockTest, givenDrmMemoryManagerWithLocalMemoryWhenLockResourceIsCalledOnWriteCombinedAllocationThenReturnPtrAlignedTo64Kb) {
|
||||||
BufferObject bo(mock, 1, 1024);
|
BufferObject bo(mock, 1, 1024, 0);
|
||||||
|
|
||||||
DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::WRITE_COMBINED, &bo, nullptr, 0u, 0u, MemoryPool::LocalMemory);
|
DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::WRITE_COMBINED, &bo, nullptr, 0u, 0u, MemoryPool::LocalMemory);
|
||||||
EXPECT_EQ(&bo, drmAllocation.getBO());
|
EXPECT_EQ(&bo, drmAllocation.getBO());
|
||||||
@@ -851,7 +851,7 @@ TEST_F(DrmMemoryManagerTestDg1, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAll
|
|||||||
this->ioctlResExt = {mockDg1->ioctl_cnt.total, -1};
|
this->ioctlResExt = {mockDg1->ioctl_cnt.total, -1};
|
||||||
mockDg1->ioctl_res_ext = &ioctlResExt;
|
mockDg1->ioctl_res_ext = &ioctlResExt;
|
||||||
|
|
||||||
BufferObject bo(mockDg1, 1, 0);
|
BufferObject bo(mockDg1, 1, 0, 0);
|
||||||
DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, 0u, MemoryPool::LocalMemory);
|
DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, 0u, MemoryPool::LocalMemory);
|
||||||
EXPECT_NE(nullptr, drmAllocation.getBO());
|
EXPECT_NE(nullptr, drmAllocation.getBO());
|
||||||
|
|
||||||
|
|||||||
@@ -2383,7 +2383,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledButFails
|
|||||||
|
|
||||||
DrmMockCustom drmMock;
|
DrmMockCustom drmMock;
|
||||||
struct BufferObjectMock : public BufferObject {
|
struct BufferObjectMock : public BufferObject {
|
||||||
BufferObjectMock(Drm *drm) : BufferObject(drm, 1, 0) {}
|
BufferObjectMock(Drm *drm) : BufferObject(drm, 1, 0, 1) {}
|
||||||
};
|
};
|
||||||
BufferObjectMock bo(&drmMock);
|
BufferObjectMock bo(&drmMock);
|
||||||
DrmAllocation drmAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull);
|
DrmAllocation drmAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull);
|
||||||
@@ -2416,7 +2416,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenUnlockResourceIsCalledOnAl
|
|||||||
|
|
||||||
DrmMockCustom drmMock;
|
DrmMockCustom drmMock;
|
||||||
struct BufferObjectMock : public BufferObject {
|
struct BufferObjectMock : public BufferObject {
|
||||||
BufferObjectMock(Drm *drm) : BufferObject(drm, 1, 0) {}
|
BufferObjectMock(Drm *drm) : BufferObject(drm, 1, 0, 1) {}
|
||||||
};
|
};
|
||||||
auto bo = new BufferObjectMock(&drmMock);
|
auto bo = new BufferObjectMock(&drmMock);
|
||||||
auto drmAllocation = new DrmAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, bo, nullptr, 0u, (osHandle)0u, MemoryPool::LocalMemory);
|
auto drmAllocation = new DrmAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, bo, nullptr, 0u, (osHandle)0u, MemoryPool::LocalMemory);
|
||||||
@@ -2443,7 +2443,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetDomainCpuIsCalledButFai
|
|||||||
|
|
||||||
DrmMockCustom drmMock;
|
DrmMockCustom drmMock;
|
||||||
struct BufferObjectMock : public BufferObject {
|
struct BufferObjectMock : public BufferObject {
|
||||||
BufferObjectMock(Drm *drm) : BufferObject(drm, 1, 0) {}
|
BufferObjectMock(Drm *drm) : BufferObject(drm, 1, 0, 1) {}
|
||||||
};
|
};
|
||||||
BufferObjectMock bo(&drmMock);
|
BufferObjectMock bo(&drmMock);
|
||||||
DrmAllocation drmAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull);
|
DrmAllocation drmAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull);
|
||||||
@@ -2459,7 +2459,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetDomainCpuIsCalledOnAllo
|
|||||||
|
|
||||||
DrmMockCustom drmMock;
|
DrmMockCustom drmMock;
|
||||||
struct BufferObjectMock : public BufferObject {
|
struct BufferObjectMock : public BufferObject {
|
||||||
BufferObjectMock(Drm *drm) : BufferObject(drm, 1, 0) {}
|
BufferObjectMock(Drm *drm) : BufferObject(drm, 1, 0, 1) {}
|
||||||
};
|
};
|
||||||
BufferObjectMock bo(&drmMock);
|
BufferObjectMock bo(&drmMock);
|
||||||
DrmAllocation drmAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull);
|
DrmAllocation drmAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull);
|
||||||
@@ -2981,7 +2981,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDisabledForcePinAndEna
|
|||||||
|
|
||||||
class PinBufferObject : public BufferObject {
|
class PinBufferObject : public BufferObject {
|
||||||
public:
|
public:
|
||||||
PinBufferObject(Drm *drm) : BufferObject(drm, 1, 0) {
|
PinBufferObject(Drm *drm) : BufferObject(drm, 1, 0, 1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int pin(BufferObject *const boToPin[], size_t numberOfBos, OsContext *osContext, uint32_t vmHandleId, uint32_t drmContextId) override {
|
int pin(BufferObject *const boToPin[], size_t numberOfBos, OsContext *osContext, uint32_t vmHandleId, uint32_t drmContextId) override {
|
||||||
|
|||||||
@@ -30,14 +30,14 @@
|
|||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
|
||||||
BufferObject::BufferObject(Drm *drm, int handle, size_t size) : drm(drm), refCount(1), handle(handle), size(size), isReused(false) {
|
BufferObject::BufferObject(Drm *drm, int handle, size_t size, size_t maxOsContextCount) : drm(drm), refCount(1), handle(handle), size(size), isReused(false) {
|
||||||
this->tiling_mode = I915_TILING_NONE;
|
this->tiling_mode = I915_TILING_NONE;
|
||||||
this->lockedAddress = nullptr;
|
this->lockedAddress = nullptr;
|
||||||
|
|
||||||
perContextVmsUsed = drm->isPerContextVMRequired();
|
perContextVmsUsed = drm->isPerContextVMRequired();
|
||||||
|
|
||||||
if (perContextVmsUsed) {
|
if (perContextVmsUsed) {
|
||||||
bindInfo.resize(MemoryManager::maxOsContextCount);
|
bindInfo.resize(maxOsContextCount);
|
||||||
for (auto &iter : bindInfo) {
|
for (auto &iter : bindInfo) {
|
||||||
iter.fill(false);
|
iter.fill(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class BufferObject {
|
|||||||
friend DrmMemoryManager;
|
friend DrmMemoryManager;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BufferObject(Drm *drm, int handle, size_t size);
|
BufferObject(Drm *drm, int handle, size_t size, size_t maxOsContextCount);
|
||||||
MOCKABLE_VIRTUAL ~BufferObject(){};
|
MOCKABLE_VIRTUAL ~BufferObject(){};
|
||||||
|
|
||||||
struct Deleter {
|
struct Deleter {
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ NEO::BufferObject *DrmMemoryManager::allocUserptr(uintptr_t address, size_t size
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto res = new (std::nothrow) BufferObject(&getDrm(rootDeviceIndex), userptr.handle, size);
|
auto res = new (std::nothrow) BufferObject(&getDrm(rootDeviceIndex), userptr.handle, size, maxOsContextCount);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
DEBUG_BREAK_IF(true);
|
DEBUG_BREAK_IF(true);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -349,7 +349,7 @@ GraphicsAllocation *DrmMemoryManager::allocateShareableMemory(const AllocationDa
|
|||||||
DEBUG_BREAK_IF(ret != 0);
|
DEBUG_BREAK_IF(ret != 0);
|
||||||
((void)(ret));
|
((void)(ret));
|
||||||
|
|
||||||
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(new BufferObject(&getDrm(allocationData.rootDeviceIndex), create.handle, bufferSize));
|
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(new BufferObject(&getDrm(allocationData.rootDeviceIndex), create.handle, bufferSize, maxOsContextCount));
|
||||||
bo->gpuAddress = gpuRange;
|
bo->gpuAddress = gpuRange;
|
||||||
|
|
||||||
auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), nullptr, gpuRange, bufferSize, MemoryPool::SystemCpuInaccessible);
|
auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), nullptr, gpuRange, bufferSize, MemoryPool::SystemCpuInaccessible);
|
||||||
@@ -378,7 +378,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A
|
|||||||
DEBUG_BREAK_IF(ret != 0);
|
DEBUG_BREAK_IF(ret != 0);
|
||||||
UNUSED_VARIABLE(ret);
|
UNUSED_VARIABLE(ret);
|
||||||
|
|
||||||
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(new (std::nothrow) BufferObject(&getDrm(allocationData.rootDeviceIndex), create.handle, allocationData.imgInfo->size));
|
std::unique_ptr<BufferObject, BufferObject::Deleter> bo(new (std::nothrow) BufferObject(&getDrm(allocationData.rootDeviceIndex), create.handle, allocationData.imgInfo->size, maxOsContextCount));
|
||||||
if (!bo) {
|
if (!bo) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -484,7 +484,7 @@ BufferObject *DrmMemoryManager::createSharedBufferObject(int boHandle, size_t si
|
|||||||
|
|
||||||
gpuRange = acquireGpuRange(size, requireSpecificBitness, rootDeviceIndex, isLocalMemorySupported(rootDeviceIndex));
|
gpuRange = acquireGpuRange(size, requireSpecificBitness, rootDeviceIndex, isLocalMemorySupported(rootDeviceIndex));
|
||||||
|
|
||||||
auto bo = new (std::nothrow) BufferObject(&getDrm(rootDeviceIndex), boHandle, size);
|
auto bo = new (std::nothrow) BufferObject(&getDrm(rootDeviceIndex), boHandle, size, maxOsContextCount);
|
||||||
if (!bo) {
|
if (!bo) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
|
||||||
BufferObject *createBufferObjectInMemoryRegion(Drm *drm, uint64_t gpuAddress, size_t size, uint32_t memoryBanks) {
|
BufferObject *createBufferObjectInMemoryRegion(Drm *drm, uint64_t gpuAddress, size_t size, uint32_t memoryBanks, size_t maxOsContextCount) {
|
||||||
auto memoryInfo = static_cast<MemoryInfoImpl *>(drm->getMemoryInfo());
|
auto memoryInfo = static_cast<MemoryInfoImpl *>(drm->getMemoryInfo());
|
||||||
if (!memoryInfo) {
|
if (!memoryInfo) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -50,7 +50,7 @@ BufferObject *createBufferObjectInMemoryRegion(Drm *drm, uint64_t gpuAddress, si
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto bo = new (std::nothrow) BufferObject(drm, createExt.handle, size);
|
auto bo = new (std::nothrow) BufferObject(drm, createExt.handle, size, maxOsContextCount);
|
||||||
if (!bo) {
|
if (!bo) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ uint64_t getGpuAddress(GraphicsAllocation::AllocationType allocType, GfxPartitio
|
|||||||
return gpuAddress;
|
return gpuAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool createDrmAllocation(Drm *drm, DrmAllocation *allocation, uint64_t gpuAddress) {
|
bool createDrmAllocation(Drm *drm, DrmAllocation *allocation, uint64_t gpuAddress, size_t maxOsContextCount) {
|
||||||
std::array<std::unique_ptr<BufferObject>, EngineLimits::maxHandleCount> bos{};
|
std::array<std::unique_ptr<BufferObject>, EngineLimits::maxHandleCount> bos{};
|
||||||
auto &storageInfo = allocation->storageInfo;
|
auto &storageInfo = allocation->storageInfo;
|
||||||
auto boAddress = gpuAddress;
|
auto boAddress = gpuAddress;
|
||||||
@@ -95,7 +95,7 @@ bool createDrmAllocation(Drm *drm, DrmAllocation *allocation, uint64_t gpuAddres
|
|||||||
memoryBanks &= 1u << handleId;
|
memoryBanks &= 1u << handleId;
|
||||||
}
|
}
|
||||||
auto boSize = alignUp(allocation->getGmm(handleId)->gmmResourceInfo->getSizeAllocation(), MemoryConstants::pageSize64k);
|
auto boSize = alignUp(allocation->getGmm(handleId)->gmmResourceInfo->getSizeAllocation(), MemoryConstants::pageSize64k);
|
||||||
bos[handleId] = std::unique_ptr<BufferObject>(createBufferObjectInMemoryRegion(drm, boAddress, boSize, memoryBanks));
|
bos[handleId] = std::unique_ptr<BufferObject>(createBufferObjectInMemoryRegion(drm, boAddress, boSize, memoryBanks, maxOsContextCount));
|
||||||
if (nullptr == bos[handleId]) {
|
if (nullptr == bos[handleId]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
|
|||||||
allocation->setFlushL3Required(allocationData.flags.flushL3);
|
allocation->setFlushL3Required(allocationData.flags.flushL3);
|
||||||
allocation->setReservedAddressRange(reinterpret_cast<void *>(gpuAddress), sizeAllocated);
|
allocation->setReservedAddressRange(reinterpret_cast<void *>(gpuAddress), sizeAllocated);
|
||||||
|
|
||||||
if (!createDrmAllocation(&getDrm(allocationData.rootDeviceIndex), allocation.get(), gpuAddress)) {
|
if (!createDrmAllocation(&getDrm(allocationData.rootDeviceIndex), allocation.get(), gpuAddress, maxOsContextCount)) {
|
||||||
for (auto handleId = 0u; handleId < allocationData.storageInfo.getNumBanks(); handleId++) {
|
for (auto handleId = 0u; handleId < allocationData.storageInfo.getNumBanks(); handleId++) {
|
||||||
delete allocation->getGmm(handleId);
|
delete allocation->getGmm(handleId);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user