mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Make migration for indirect allocations
Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4f9498476d
commit
8a9ea9afd7
@@ -144,19 +144,6 @@ NEO::PreemptionMode CommandList::obtainKernelPreemptionMode(Kernel *kernel) {
|
|||||||
return NEO::PreemptionHelper::taskPreemptionMode(device->getDevicePreemptionMode(), flags);
|
return NEO::PreemptionHelper::taskPreemptionMode(device->getDevicePreemptionMode(), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandList::makeResidentAndMigrate(bool performMigration) {
|
|
||||||
for (auto alloc : commandContainer.getResidencyContainer()) {
|
|
||||||
csr->makeResident(*alloc);
|
|
||||||
|
|
||||||
if (performMigration &&
|
|
||||||
(alloc->getAllocationType() == NEO::AllocationType::SVM_GPU ||
|
|
||||||
alloc->getAllocationType() == NEO::AllocationType::SVM_CPU)) {
|
|
||||||
auto pageFaultManager = device->getDriverHandle()->getMemoryManager()->getPageFaultManager();
|
|
||||||
pageFaultManager->moveAllocationToGpuDomain(reinterpret_cast<void *>(alloc->getGpuAddress()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandList::migrateSharedAllocations() {
|
void CommandList::migrateSharedAllocations() {
|
||||||
auto deviceImp = static_cast<DeviceImp *>(device);
|
auto deviceImp = static_cast<DeviceImp *>(device);
|
||||||
DriverHandleImp *driverHandleImp = static_cast<DriverHandleImp *>(deviceImp->getDriverHandle());
|
DriverHandleImp *driverHandleImp = static_cast<DriverHandleImp *>(deviceImp->getDriverHandle());
|
||||||
|
|||||||
@@ -278,7 +278,6 @@ struct CommandList : _ze_command_list_handle_t {
|
|||||||
return static_cast<uint32_t>(returnPoints.size());
|
return static_cast<uint32_t>(returnPoints.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void makeResidentAndMigrate(bool);
|
|
||||||
void migrateSharedAllocations();
|
void migrateSharedAllocations();
|
||||||
|
|
||||||
bool getSystolicModeSupport() const {
|
bool getSystolicModeSupport() const {
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::executeCommandListImm
|
|||||||
|
|
||||||
std::unique_lock<std::mutex> lockForIndirect;
|
std::unique_lock<std::mutex> lockForIndirect;
|
||||||
if (this->hasIndirectAllocationsAllowed()) {
|
if (this->hasIndirectAllocationsAllowed()) {
|
||||||
this->cmdQImmediate->handleIndirectAllocationResidency(this->getUnifiedMemoryControls(), lockForIndirect);
|
this->cmdQImmediate->handleIndirectAllocationResidency(this->getUnifiedMemoryControls(), lockForIndirect, performMigration);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->csr->setRequiredScratchSizes(this->getCommandListPerThreadScratchSize(), this->getCommandListPerThreadPrivateScratchSize());
|
this->csr->setRequiredScratchSizes(this->getCommandListPerThreadScratchSize(), this->getCommandListPerThreadPrivateScratchSize());
|
||||||
@@ -123,7 +123,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::executeCommandListImm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->makeResidentAndMigrate(performMigration);
|
this->cmdQImmediate->makeResidentAndMigrate(performMigration, this->commandContainer.getResidencyContainer());
|
||||||
|
|
||||||
if (performMigration) {
|
if (performMigration) {
|
||||||
this->migrateSharedAllocations();
|
this->migrateSharedAllocations();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "shared/source/command_container/cmdcontainer.h"
|
||||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||||
#include "shared/source/command_stream/csr_definitions.h"
|
#include "shared/source/command_stream/csr_definitions.h"
|
||||||
#include "shared/source/command_stream/linear_stream.h"
|
#include "shared/source/command_stream/linear_stream.h"
|
||||||
@@ -264,7 +265,7 @@ NEO::WaitStatus CommandQueueImp::CommandBufferManager::switchBuffers(NEO::Comman
|
|||||||
return waitStatus;
|
return waitStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandQueueImp::handleIndirectAllocationResidency(UnifiedMemoryControls unifiedMemoryControls, std::unique_lock<std::mutex> &lockForIndirect) {
|
void CommandQueueImp::handleIndirectAllocationResidency(UnifiedMemoryControls unifiedMemoryControls, std::unique_lock<std::mutex> &lockForIndirect, bool performMigration) {
|
||||||
NEO::Device *neoDevice = this->device->getNEODevice();
|
NEO::Device *neoDevice = this->device->getNEODevice();
|
||||||
auto svmAllocsManager = this->device->getDriverHandle()->getSvmAllocsManager();
|
auto svmAllocsManager = this->device->getDriverHandle()->getSvmAllocsManager();
|
||||||
auto submitAsPack = this->device->getDriverHandle()->getMemoryManager()->allowIndirectAllocationsAsPack(neoDevice->getRootDeviceIndex());
|
auto submitAsPack = this->device->getDriverHandle()->getMemoryManager()->allowIndirectAllocationsAsPack(neoDevice->getRootDeviceIndex());
|
||||||
@@ -276,9 +277,23 @@ void CommandQueueImp::handleIndirectAllocationResidency(UnifiedMemoryControls un
|
|||||||
svmAllocsManager->makeIndirectAllocationsResident(*(this->csr), this->csr->peekTaskCount() + 1u);
|
svmAllocsManager->makeIndirectAllocationsResident(*(this->csr), this->csr->peekTaskCount() + 1u);
|
||||||
} else {
|
} else {
|
||||||
lockForIndirect = this->device->getDriverHandle()->getSvmAllocsManager()->obtainOwnership();
|
lockForIndirect = this->device->getDriverHandle()->getSvmAllocsManager()->obtainOwnership();
|
||||||
|
NEO::ResidencyContainer residencyAllocations;
|
||||||
svmAllocsManager->addInternalAllocationsToResidencyContainer(neoDevice->getRootDeviceIndex(),
|
svmAllocsManager->addInternalAllocationsToResidencyContainer(neoDevice->getRootDeviceIndex(),
|
||||||
this->csr->getResidencyAllocations(),
|
residencyAllocations,
|
||||||
unifiedMemoryControls.generateMask());
|
unifiedMemoryControls.generateMask());
|
||||||
|
makeResidentAndMigrate(performMigration, residencyAllocations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandQueueImp::makeResidentAndMigrate(bool performMigration, const NEO::ResidencyContainer &residencyContainer) {
|
||||||
|
for (auto alloc : residencyContainer) {
|
||||||
|
csr->makeResident(*alloc);
|
||||||
|
if (performMigration &&
|
||||||
|
(alloc->getAllocationType() == NEO::AllocationType::SVM_GPU ||
|
||||||
|
alloc->getAllocationType() == NEO::AllocationType::SVM_CPU)) {
|
||||||
|
auto pageFaultManager = device->getDriverHandle()->getMemoryManager()->getPageFaultManager();
|
||||||
|
pageFaultManager->moveAllocationToGpuDomain(reinterpret_cast<void *>(alloc->getGpuAddress()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,15 @@
|
|||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
struct _ze_command_queue_handle_t {};
|
struct _ze_command_queue_handle_t {};
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
class CommandStreamReceiver;
|
class CommandStreamReceiver;
|
||||||
}
|
class GraphicsAllocation;
|
||||||
|
using ResidencyContainer = std::vector<GraphicsAllocation *>;
|
||||||
|
} // namespace NEO
|
||||||
|
|
||||||
struct UnifiedMemoryControls;
|
struct UnifiedMemoryControls;
|
||||||
|
|
||||||
@@ -52,7 +55,8 @@ struct CommandQueue : _ze_command_queue_handle_t {
|
|||||||
return static_cast<CommandQueue *>(handle);
|
return static_cast<CommandQueue *>(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void handleIndirectAllocationResidency(UnifiedMemoryControls unifiedMemoryControls, std::unique_lock<std::mutex> &lockForIndirect) = 0;
|
virtual void handleIndirectAllocationResidency(UnifiedMemoryControls unifiedMemoryControls, std::unique_lock<std::mutex> &lockForIndirect, bool performMigration) = 0;
|
||||||
|
virtual void makeResidentAndMigrate(bool performMigration, const NEO::ResidencyContainer &residencyContainer) = 0;
|
||||||
|
|
||||||
ze_command_queue_handle_t toHandle() { return this; }
|
ze_command_queue_handle_t toHandle() { return this; }
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandListsRegular(
|
|||||||
|
|
||||||
std::unique_lock<std::mutex> lockForIndirect;
|
std::unique_lock<std::mutex> lockForIndirect;
|
||||||
if (ctx.hasIndirectAccess) {
|
if (ctx.hasIndirectAccess) {
|
||||||
handleIndirectAllocationResidency(ctx.unifiedMemoryControls, lockForIndirect);
|
handleIndirectAllocationResidency(ctx.unifiedMemoryControls, lockForIndirect, ctx.isMigrationRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t linearStreamSizeEstimate = this->estimateLinearStreamSizeInitial(ctx, phCommandLists, numCommandLists);
|
size_t linearStreamSizeEstimate = this->estimateLinearStreamSizeInitial(ctx, phCommandLists, numCommandLists);
|
||||||
@@ -563,7 +563,7 @@ void CommandQueueHw<gfxCoreFamily>::setupCmdListsAndContextParams(
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->partitionCount = std::max(this->partitionCount, commandList->partitionCount);
|
this->partitionCount = std::max(this->partitionCount, commandList->partitionCount);
|
||||||
commandList->makeResidentAndMigrate(ctx.isMigrationRequested);
|
makeResidentAndMigrate(ctx.isMigrationRequested, commandList->commandContainer.getResidencyContainer());
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.isDispatchTaskCountPostSyncRequired = isDispatchTaskCountPostSyncRequired(hFence, ctx.containsAnyRegularCmdList);
|
ctx.isDispatchTaskCountPostSyncRequired = isDispatchTaskCountPostSyncRequired(hFence, ctx.containsAnyRegularCmdList);
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ struct CommandQueueImp : public CommandQueue {
|
|||||||
MOCKABLE_VIRTUAL NEO::WaitStatus reserveLinearStreamSize(size_t size);
|
MOCKABLE_VIRTUAL NEO::WaitStatus reserveLinearStreamSize(size_t size);
|
||||||
ze_command_queue_mode_t getSynchronousMode() const;
|
ze_command_queue_mode_t getSynchronousMode() const;
|
||||||
virtual bool getPreemptionCmdProgramming() = 0;
|
virtual bool getPreemptionCmdProgramming() = 0;
|
||||||
void handleIndirectAllocationResidency(UnifiedMemoryControls unifiedMemoryControls, std::unique_lock<std::mutex> &lockForIndirect) override;
|
void handleIndirectAllocationResidency(UnifiedMemoryControls unifiedMemoryControls, std::unique_lock<std::mutex> &lockForIndirect, bool performMigration) override;
|
||||||
|
void makeResidentAndMigrate(bool performMigration, const NEO::ResidencyContainer &residencyContainer) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MOCKABLE_VIRTUAL NEO::SubmissionStatus submitBatchBuffer(size_t offset, NEO::ResidencyContainer &residencyContainer, void *endingCmdPtr,
|
MOCKABLE_VIRTUAL NEO::SubmissionStatus submitBatchBuffer(size_t offset, NEO::ResidencyContainer &residencyContainer, void *endingCmdPtr,
|
||||||
|
|||||||
@@ -718,7 +718,7 @@ TEST(CommandList, whenAsMutableIsCalledNullptrIsReturned) {
|
|||||||
class MockCommandQueueIndirectAccess : public Mock<CommandQueue> {
|
class MockCommandQueueIndirectAccess : public Mock<CommandQueue> {
|
||||||
public:
|
public:
|
||||||
MockCommandQueueIndirectAccess(L0::Device *device, NEO::CommandStreamReceiver *csr, const ze_command_queue_desc_t *desc) : Mock(device, csr, desc) {}
|
MockCommandQueueIndirectAccess(L0::Device *device, NEO::CommandStreamReceiver *csr, const ze_command_queue_desc_t *desc) : Mock(device, csr, desc) {}
|
||||||
void handleIndirectAllocationResidency(UnifiedMemoryControls unifiedMemoryControls, std::unique_lock<std::mutex> &lockForIndirect) override {
|
void handleIndirectAllocationResidency(UnifiedMemoryControls unifiedMemoryControls, std::unique_lock<std::mutex> &lockForIndirect, bool performMigration) override {
|
||||||
handleIndirectAllocationResidencyCalledTimes++;
|
handleIndirectAllocationResidencyCalledTimes++;
|
||||||
}
|
}
|
||||||
uint32_t handleIndirectAllocationResidencyCalledTimes = 0;
|
uint32_t handleIndirectAllocationResidencyCalledTimes = 0;
|
||||||
|
|||||||
@@ -527,6 +527,10 @@ HWTEST2_F(CmdlistAppendLaunchKernelTests,
|
|||||||
commandList->device = device;
|
commandList->device = device;
|
||||||
commandList->cmdListType = CommandList::CommandListType::TYPE_IMMEDIATE;
|
commandList->cmdListType = CommandList::CommandListType::TYPE_IMMEDIATE;
|
||||||
commandList->csr = device->getNEODevice()->getDefaultEngine().commandStreamReceiver;
|
commandList->csr = device->getNEODevice()->getDefaultEngine().commandStreamReceiver;
|
||||||
|
ze_command_queue_desc_t desc = {};
|
||||||
|
desc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS;
|
||||||
|
MockCommandQueueHw<gfxCoreFamily> mockCommandQueue(device, device->getNEODevice()->getDefaultEngine().commandStreamReceiver, &desc);
|
||||||
|
commandList->cmdQImmediate = &mockCommandQueue;
|
||||||
|
|
||||||
ze_group_count_t groupCount = {3, 2, 1};
|
ze_group_count_t groupCount = {3, 2, 1};
|
||||||
CmdListKernelLaunchParams launchParams = {};
|
CmdListKernelLaunchParams launchParams = {};
|
||||||
@@ -537,6 +541,7 @@ HWTEST2_F(CmdlistAppendLaunchKernelTests,
|
|||||||
|
|
||||||
auto ultCsr = reinterpret_cast<NEO::UltCommandStreamReceiver<FamilyType> *>(device->getNEODevice()->getDefaultEngine().commandStreamReceiver);
|
auto ultCsr = reinterpret_cast<NEO::UltCommandStreamReceiver<FamilyType> *>(device->getNEODevice()->getDefaultEngine().commandStreamReceiver);
|
||||||
EXPECT_EQ(scratchPerThreadSize, ultCsr->requiredScratchSize);
|
EXPECT_EQ(scratchPerThreadSize, ultCsr->requiredScratchSize);
|
||||||
|
commandList->cmdQImmediate = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
HWTEST2_F(CmdlistAppendLaunchKernelTests,
|
HWTEST2_F(CmdlistAppendLaunchKernelTests,
|
||||||
@@ -710,6 +715,10 @@ HWTEST2_F(CmdlistAppendLaunchKernelTests,
|
|||||||
commandList->device = device;
|
commandList->device = device;
|
||||||
commandList->cmdListType = CommandList::CommandListType::TYPE_IMMEDIATE;
|
commandList->cmdListType = CommandList::CommandListType::TYPE_IMMEDIATE;
|
||||||
commandList->csr = device->getNEODevice()->getDefaultEngine().commandStreamReceiver;
|
commandList->csr = device->getNEODevice()->getDefaultEngine().commandStreamReceiver;
|
||||||
|
ze_command_queue_desc_t desc = {};
|
||||||
|
desc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS;
|
||||||
|
MockCommandQueueHw<gfxCoreFamily> mockCommandQueue(device, device->getNEODevice()->getDefaultEngine().commandStreamReceiver, &desc);
|
||||||
|
commandList->cmdQImmediate = &mockCommandQueue;
|
||||||
|
|
||||||
ze_group_count_t groupCount = {3, 2, 1};
|
ze_group_count_t groupCount = {3, 2, 1};
|
||||||
CmdListKernelLaunchParams launchParams = {};
|
CmdListKernelLaunchParams launchParams = {};
|
||||||
@@ -722,6 +731,7 @@ HWTEST2_F(CmdlistAppendLaunchKernelTests,
|
|||||||
auto ultCsr = reinterpret_cast<NEO::UltCommandStreamReceiver<FamilyType> *>(device->getNEODevice()->getDefaultEngine().commandStreamReceiver);
|
auto ultCsr = reinterpret_cast<NEO::UltCommandStreamReceiver<FamilyType> *>(device->getNEODevice()->getDefaultEngine().commandStreamReceiver);
|
||||||
EXPECT_EQ(scratchPerThreadSize, ultCsr->requiredScratchSize);
|
EXPECT_EQ(scratchPerThreadSize, ultCsr->requiredScratchSize);
|
||||||
EXPECT_EQ(privateScratchPerThreadSize, ultCsr->requiredPrivateScratchSize);
|
EXPECT_EQ(privateScratchPerThreadSize, ultCsr->requiredPrivateScratchSize);
|
||||||
|
commandList->cmdQImmediate = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
using MultiReturnCommandListTest = Test<MultiReturnCommandListFixture>;
|
using MultiReturnCommandListTest = Test<MultiReturnCommandListFixture>;
|
||||||
|
|||||||
@@ -1886,7 +1886,7 @@ TEST_F(CommandQueueCreate, givenCommandQueueWhenHandleIndirectAllocationResidenc
|
|||||||
auto mockSvmAllocsManager = std::make_unique<SVMAllocsManagerMock>(device->getDriverHandle()->getMemoryManager());
|
auto mockSvmAllocsManager = std::make_unique<SVMAllocsManagerMock>(device->getDriverHandle()->getMemoryManager());
|
||||||
reinterpret_cast<WhiteBox<::L0::DriverHandle> *>(device->getDriverHandle())->svmAllocsManager = mockSvmAllocsManager.get();
|
reinterpret_cast<WhiteBox<::L0::DriverHandle> *>(device->getDriverHandle())->svmAllocsManager = mockSvmAllocsManager.get();
|
||||||
|
|
||||||
commandQueue->handleIndirectAllocationResidency({true, true, true}, lock);
|
commandQueue->handleIndirectAllocationResidency({true, true, true}, lock, false);
|
||||||
EXPECT_EQ(mockSvmAllocsManager->makeIndirectAllocationsResidentCalledTimes, 1u);
|
EXPECT_EQ(mockSvmAllocsManager->makeIndirectAllocationsResidentCalledTimes, 1u);
|
||||||
EXPECT_EQ(mockSvmAllocsManager->addInternalAllocationsToResidencyContainerCalledTimes, 0u);
|
EXPECT_EQ(mockSvmAllocsManager->addInternalAllocationsToResidencyContainerCalledTimes, 0u);
|
||||||
reinterpret_cast<WhiteBox<::L0::DriverHandle> *>(device->getDriverHandle())->svmAllocsManager = prevSvmAllocsManager;
|
reinterpret_cast<WhiteBox<::L0::DriverHandle> *>(device->getDriverHandle())->svmAllocsManager = prevSvmAllocsManager;
|
||||||
@@ -1911,7 +1911,7 @@ TEST_F(CommandQueueCreate, givenCommandQueueWhenHandleIndirectAllocationResidenc
|
|||||||
auto mockSvmAllocsManager = std::make_unique<SVMAllocsManagerMock>(device->getDriverHandle()->getMemoryManager());
|
auto mockSvmAllocsManager = std::make_unique<SVMAllocsManagerMock>(device->getDriverHandle()->getMemoryManager());
|
||||||
reinterpret_cast<WhiteBox<::L0::DriverHandle> *>(device->getDriverHandle())->svmAllocsManager = mockSvmAllocsManager.get();
|
reinterpret_cast<WhiteBox<::L0::DriverHandle> *>(device->getDriverHandle())->svmAllocsManager = mockSvmAllocsManager.get();
|
||||||
|
|
||||||
commandQueue->handleIndirectAllocationResidency({true, true, true}, lock);
|
commandQueue->handleIndirectAllocationResidency({true, true, true}, lock, false);
|
||||||
EXPECT_EQ(mockSvmAllocsManager->makeIndirectAllocationsResidentCalledTimes, 0u);
|
EXPECT_EQ(mockSvmAllocsManager->makeIndirectAllocationsResidentCalledTimes, 0u);
|
||||||
EXPECT_EQ(mockSvmAllocsManager->addInternalAllocationsToResidencyContainerCalledTimes, 1u);
|
EXPECT_EQ(mockSvmAllocsManager->addInternalAllocationsToResidencyContainerCalledTimes, 1u);
|
||||||
reinterpret_cast<WhiteBox<::L0::DriverHandle> *>(device->getDriverHandle())->svmAllocsManager = prevSvmAllocsManager;
|
reinterpret_cast<WhiteBox<::L0::DriverHandle> *>(device->getDriverHandle())->svmAllocsManager = prevSvmAllocsManager;
|
||||||
@@ -1937,7 +1937,7 @@ TEST_F(CommandQueueCreate, givenCommandQueueWhenHandleIndirectAllocationResidenc
|
|||||||
auto mockSvmAllocsManager = std::make_unique<SVMAllocsManagerMock>(device->getDriverHandle()->getMemoryManager());
|
auto mockSvmAllocsManager = std::make_unique<SVMAllocsManagerMock>(device->getDriverHandle()->getMemoryManager());
|
||||||
reinterpret_cast<WhiteBox<::L0::DriverHandle> *>(device->getDriverHandle())->svmAllocsManager = mockSvmAllocsManager.get();
|
reinterpret_cast<WhiteBox<::L0::DriverHandle> *>(device->getDriverHandle())->svmAllocsManager = mockSvmAllocsManager.get();
|
||||||
|
|
||||||
commandQueue->handleIndirectAllocationResidency({true, true, true}, lock);
|
commandQueue->handleIndirectAllocationResidency({true, true, true}, lock, false);
|
||||||
std::thread th([&] {
|
std::thread th([&] {
|
||||||
EXPECT_FALSE(mockSvmAllocsManager->mtxForIndirectAccess.try_lock());
|
EXPECT_FALSE(mockSvmAllocsManager->mtxForIndirectAccess.try_lock());
|
||||||
});
|
});
|
||||||
@@ -1947,30 +1947,5 @@ TEST_F(CommandQueueCreate, givenCommandQueueWhenHandleIndirectAllocationResidenc
|
|||||||
commandQueue->destroy();
|
commandQueue->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CommandQueueCreate, givenCommandQueueWhenHandleIndirectAllocationResidencyCalledAndSubmiPackDisabeldThenResidencyContainerFromCsrIsUsed) {
|
|
||||||
DebugManagerStateRestore restore;
|
|
||||||
DebugManager.flags.MakeIndirectAllocationsResidentAsPack.set(0);
|
|
||||||
const ze_command_queue_desc_t desc{};
|
|
||||||
ze_result_t returnValue;
|
|
||||||
|
|
||||||
auto prevSvmAllocsManager = device->getDriverHandle()->getSvmAllocsManager();
|
|
||||||
auto commandQueue = whiteboxCast(CommandQueue::create(productFamily,
|
|
||||||
device,
|
|
||||||
neoDevice->getDefaultEngine().commandStreamReceiver,
|
|
||||||
&desc,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
returnValue));
|
|
||||||
std::unique_lock<std::mutex> lock;
|
|
||||||
auto mockSvmAllocsManager = std::make_unique<SVMAllocsManagerMock>(device->getDriverHandle()->getMemoryManager());
|
|
||||||
reinterpret_cast<WhiteBox<::L0::DriverHandle> *>(device->getDriverHandle())->svmAllocsManager = mockSvmAllocsManager.get();
|
|
||||||
|
|
||||||
commandQueue->handleIndirectAllocationResidency({true, true, true}, lock);
|
|
||||||
EXPECT_EQ(commandQueue->csr->getResidencyAllocations().data(), mockSvmAllocsManager->passedContainer);
|
|
||||||
reinterpret_cast<WhiteBox<::L0::DriverHandle> *>(device->getDriverHandle())->svmAllocsManager = prevSvmAllocsManager;
|
|
||||||
lock.unlock();
|
|
||||||
commandQueue->destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ult
|
} // namespace ult
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "shared/test/common/libult/ult_command_stream_receiver.h"
|
#include "shared/test/common/libult/ult_command_stream_receiver.h"
|
||||||
#include "shared/test/common/mocks/mock_bindless_heaps_helper.h"
|
#include "shared/test/common/mocks/mock_bindless_heaps_helper.h"
|
||||||
#include "shared/test/common/mocks/mock_command_stream_receiver.h"
|
#include "shared/test/common/mocks/mock_command_stream_receiver.h"
|
||||||
|
#include "shared/test/common/mocks/mock_cpu_page_fault_manager.h"
|
||||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||||
#include "shared/test/common/test_macros/hw_test.h"
|
#include "shared/test/common/test_macros/hw_test.h"
|
||||||
@@ -769,10 +770,15 @@ class MockCommandQueueHandleIndirectAllocs : public MockCommandQueueHw<gfxCoreFa
|
|||||||
using typename MockCommandQueueHw<gfxCoreFamily>::CommandListExecutionContext;
|
using typename MockCommandQueueHw<gfxCoreFamily>::CommandListExecutionContext;
|
||||||
using MockCommandQueueHw<gfxCoreFamily>::executeCommandListsRegular;
|
using MockCommandQueueHw<gfxCoreFamily>::executeCommandListsRegular;
|
||||||
MockCommandQueueHandleIndirectAllocs(L0::Device *device, NEO::CommandStreamReceiver *csr, const ze_command_queue_desc_t *desc) : MockCommandQueueHw<gfxCoreFamily>(device, csr, desc) {}
|
MockCommandQueueHandleIndirectAllocs(L0::Device *device, NEO::CommandStreamReceiver *csr, const ze_command_queue_desc_t *desc) : MockCommandQueueHw<gfxCoreFamily>(device, csr, desc) {}
|
||||||
void handleIndirectAllocationResidency(UnifiedMemoryControls unifiedMemoryControls, std::unique_lock<std::mutex> &lockForIndirect) override {
|
void handleIndirectAllocationResidency(UnifiedMemoryControls unifiedMemoryControls, std::unique_lock<std::mutex> &lockForIndirect, bool performMigration) override {
|
||||||
handleIndirectAllocationResidencyCalledTimes++;
|
handleIndirectAllocationResidencyCalledTimes++;
|
||||||
|
MockCommandQueueHw<gfxCoreFamily>::handleIndirectAllocationResidency(unifiedMemoryControls, lockForIndirect, performMigration);
|
||||||
|
}
|
||||||
|
void makeResidentAndMigrate(bool performMigration, const NEO::ResidencyContainer &residencyContainer) override {
|
||||||
|
makeResidentAndMigrateCalledTimes++;
|
||||||
}
|
}
|
||||||
uint32_t handleIndirectAllocationResidencyCalledTimes = 0;
|
uint32_t handleIndirectAllocationResidencyCalledTimes = 0;
|
||||||
|
uint32_t makeResidentAndMigrateCalledTimes = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
HWTEST2_F(CommandQueueIndirectAllocations, givenCtxWithIndirectAccessWhenExecutingCommandListImmediateWithFlushTaskThenHandleIndirectAccessCalled, IsAtLeastSkl) {
|
HWTEST2_F(CommandQueueIndirectAllocations, givenCtxWithIndirectAccessWhenExecutingCommandListImmediateWithFlushTaskThenHandleIndirectAccessCalled, IsAtLeastSkl) {
|
||||||
@@ -820,5 +826,166 @@ HWTEST2_F(CommandQueueIndirectAllocations, givenCtxWitNohIndirectAccessWhenExecu
|
|||||||
EXPECT_EQ(commandQueue->handleIndirectAllocationResidencyCalledTimes, 0u);
|
EXPECT_EQ(commandQueue->handleIndirectAllocationResidencyCalledTimes, 0u);
|
||||||
commandQueue->destroy();
|
commandQueue->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWTEST2_F(CommandQueueIndirectAllocations, givenCommandQueueWhenHandleIndirectAllocationResidencyCalledAndSubmitPackDiasabledThenMakeResidentAndMigrateCalled, IsAtLeastSkl) {
|
||||||
|
DebugManagerStateRestore restore;
|
||||||
|
DebugManager.flags.MakeIndirectAllocationsResidentAsPack.set(0);
|
||||||
|
|
||||||
|
ze_command_queue_desc_t desc = {};
|
||||||
|
auto csr = neoDevice->getDefaultEngine().commandStreamReceiver;
|
||||||
|
auto commandQueue = new MockCommandQueueHandleIndirectAllocs<gfxCoreFamily>(device, csr, &desc);
|
||||||
|
commandQueue->initialize(false, false);
|
||||||
|
auto ctx = typename MockCommandQueueHandleIndirectAllocs<gfxCoreFamily>::CommandListExecutionContext{nullptr,
|
||||||
|
0,
|
||||||
|
csr->getPreemptionMode(),
|
||||||
|
device,
|
||||||
|
false,
|
||||||
|
csr->isProgramActivePartitionConfigRequired(),
|
||||||
|
false};
|
||||||
|
std::unique_lock<std::mutex> lock;
|
||||||
|
|
||||||
|
commandQueue->handleIndirectAllocationResidency({true, true, true}, lock, false);
|
||||||
|
EXPECT_EQ(commandQueue->makeResidentAndMigrateCalledTimes, 1u);
|
||||||
|
commandQueue->destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
using CommandQueueTest = Test<DeviceFixture>;
|
||||||
|
|
||||||
|
HWTEST_F(CommandQueueTest, givenCommandQueueWhenMakeResidentAndMigrateWithEmptyResidencyContainerThenMakeResidentWasNotCalled) {
|
||||||
|
MockCommandStreamReceiver csr(*neoDevice->getExecutionEnvironment(), 0, neoDevice->getDeviceBitfield());
|
||||||
|
csr.setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||||
|
|
||||||
|
ze_result_t returnValue;
|
||||||
|
ze_command_queue_desc_t desc = {};
|
||||||
|
L0::CommandQueue *commandQueue = CommandQueue::create(productFamily,
|
||||||
|
device,
|
||||||
|
&csr,
|
||||||
|
&desc,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
returnValue);
|
||||||
|
ResidencyContainer container;
|
||||||
|
commandQueue->makeResidentAndMigrate(false, container);
|
||||||
|
EXPECT_EQ(csr.makeResidentCalledTimes, 0u);
|
||||||
|
commandQueue->destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
HWTEST_F(CommandQueueTest, givenCommandQueueWhenMakeResidentAndMigrateWithTwoAllocsInContainerThenMakeResidentCalledTwice) {
|
||||||
|
MockCommandStreamReceiver csr(*neoDevice->getExecutionEnvironment(), 0, neoDevice->getDeviceBitfield());
|
||||||
|
csr.setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||||
|
|
||||||
|
ze_result_t returnValue;
|
||||||
|
ze_command_queue_desc_t desc = {};
|
||||||
|
L0::CommandQueue *commandQueue = CommandQueue::create(productFamily,
|
||||||
|
device,
|
||||||
|
&csr,
|
||||||
|
&desc,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
returnValue);
|
||||||
|
ResidencyContainer container;
|
||||||
|
MockGraphicsAllocation mockGA1;
|
||||||
|
MockGraphicsAllocation mockGA2;
|
||||||
|
container.push_back(&mockGA1);
|
||||||
|
container.push_back(&mockGA2);
|
||||||
|
commandQueue->makeResidentAndMigrate(false, container);
|
||||||
|
EXPECT_EQ(csr.makeResidentCalledTimes, 2u);
|
||||||
|
commandQueue->destroy();
|
||||||
|
}
|
||||||
|
HWTEST_F(CommandQueueTest, givenCommandQueueWhenPerformMigrationIsFalseThenTransferToGpuWasNotCalled) {
|
||||||
|
auto mockPageFaultManager = new MockPageFaultManager();
|
||||||
|
static_cast<MockMemoryManager *>(neoDevice->getExecutionEnvironment()->memoryManager.get())->pageFaultManager.reset(mockPageFaultManager);
|
||||||
|
MockCommandStreamReceiver csr(*neoDevice->getExecutionEnvironment(), 0, neoDevice->getDeviceBitfield());
|
||||||
|
csr.setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||||
|
|
||||||
|
ze_result_t returnValue;
|
||||||
|
ze_command_queue_desc_t desc = {};
|
||||||
|
L0::CommandQueue *commandQueue = CommandQueue::create(productFamily,
|
||||||
|
device,
|
||||||
|
&csr,
|
||||||
|
&desc,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
returnValue);
|
||||||
|
ResidencyContainer container;
|
||||||
|
MockGraphicsAllocation mockGA;
|
||||||
|
container.push_back(&mockGA);
|
||||||
|
commandQueue->makeResidentAndMigrate(false, container);
|
||||||
|
EXPECT_EQ(mockPageFaultManager->transferToGpuCalled, 0);
|
||||||
|
commandQueue->destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
HWTEST_F(CommandQueueTest, givenCommandQueueWhenPerformMigrationIsTrueAndAllocationTypeIsSvmGpuThenTransferToGpuWasCalled) {
|
||||||
|
auto mockPageFaultManager = new MockPageFaultManager();
|
||||||
|
static_cast<MockMemoryManager *>(neoDevice->getExecutionEnvironment()->memoryManager.get())->pageFaultManager.reset(mockPageFaultManager);
|
||||||
|
MockCommandStreamReceiver csr(*neoDevice->getExecutionEnvironment(), 0, neoDevice->getDeviceBitfield());
|
||||||
|
csr.setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||||
|
|
||||||
|
ze_result_t returnValue;
|
||||||
|
ze_command_queue_desc_t desc = {};
|
||||||
|
L0::CommandQueue *commandQueue = CommandQueue::create(productFamily,
|
||||||
|
device,
|
||||||
|
&csr,
|
||||||
|
&desc,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
returnValue);
|
||||||
|
ResidencyContainer container;
|
||||||
|
MockGraphicsAllocation mockGA;
|
||||||
|
mockGA.allocationType = NEO::AllocationType::SVM_GPU;
|
||||||
|
container.push_back(&mockGA);
|
||||||
|
commandQueue->makeResidentAndMigrate(true, container);
|
||||||
|
EXPECT_EQ(mockPageFaultManager->moveAllocationToGpuDomainCalled, 1);
|
||||||
|
commandQueue->destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
HWTEST_F(CommandQueueTest, givenCommandQueueWhenPerformMigrationIsTrueAndAllocationTypeIsSvmCpuThenTransferToGpuWasCalled) {
|
||||||
|
auto mockPageFaultManager = new MockPageFaultManager();
|
||||||
|
static_cast<MockMemoryManager *>(neoDevice->getExecutionEnvironment()->memoryManager.get())->pageFaultManager.reset(mockPageFaultManager);
|
||||||
|
MockCommandStreamReceiver csr(*neoDevice->getExecutionEnvironment(), 0, neoDevice->getDeviceBitfield());
|
||||||
|
csr.setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||||
|
|
||||||
|
ze_result_t returnValue;
|
||||||
|
ze_command_queue_desc_t desc = {};
|
||||||
|
L0::CommandQueue *commandQueue = CommandQueue::create(productFamily,
|
||||||
|
device,
|
||||||
|
&csr,
|
||||||
|
&desc,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
returnValue);
|
||||||
|
ResidencyContainer container;
|
||||||
|
MockGraphicsAllocation mockGA;
|
||||||
|
mockGA.allocationType = NEO::AllocationType::SVM_CPU;
|
||||||
|
container.push_back(&mockGA);
|
||||||
|
commandQueue->makeResidentAndMigrate(true, container);
|
||||||
|
EXPECT_EQ(mockPageFaultManager->moveAllocationToGpuDomainCalled, 1);
|
||||||
|
commandQueue->destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
HWTEST_F(CommandQueueTest, givenCommandQueueWhenPerformMigrationIsTrueAndAllocationTypeIsNoSvmTypeThenTransferToGpuWasNotCalled) {
|
||||||
|
auto mockPageFaultManager = new MockPageFaultManager();
|
||||||
|
static_cast<MockMemoryManager *>(neoDevice->getExecutionEnvironment()->memoryManager.get())->pageFaultManager.reset(mockPageFaultManager);
|
||||||
|
MockCommandStreamReceiver csr(*neoDevice->getExecutionEnvironment(), 0, neoDevice->getDeviceBitfield());
|
||||||
|
csr.setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||||
|
|
||||||
|
ze_result_t returnValue;
|
||||||
|
ze_command_queue_desc_t desc = {};
|
||||||
|
L0::CommandQueue *commandQueue = CommandQueue::create(productFamily,
|
||||||
|
device,
|
||||||
|
&csr,
|
||||||
|
&desc,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
returnValue);
|
||||||
|
ResidencyContainer container;
|
||||||
|
MockGraphicsAllocation mockGA;
|
||||||
|
mockGA.allocationType = NEO::AllocationType::TAG_BUFFER;
|
||||||
|
container.push_back(&mockGA);
|
||||||
|
commandQueue->makeResidentAndMigrate(true, container);
|
||||||
|
EXPECT_EQ(mockPageFaultManager->moveAllocationToGpuDomainCalled, 0);
|
||||||
|
commandQueue->destroy();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ult
|
} // namespace ult
|
||||||
} // namespace L0
|
} // namespace L0
|
||||||
|
|||||||
Reference in New Issue
Block a user