mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +08:00
Revert "Store indirect residency at command queue level"
This reverts commit ffad5c6c09.
Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
e00a5e0a1e
commit
643e21631c
@@ -163,6 +163,28 @@ void CommandList::migrateSharedAllocations() {
|
||||
}
|
||||
}
|
||||
|
||||
void CommandList::handleIndirectAllocationResidency() {
|
||||
bool indirectAllocationsAllowed = this->hasIndirectAllocationsAllowed();
|
||||
NEO::Device *neoDevice = this->device->getNEODevice();
|
||||
if (indirectAllocationsAllowed) {
|
||||
auto svmAllocsManager = this->device->getDriverHandle()->getSvmAllocsManager();
|
||||
auto submitAsPack = this->device->getDriverHandle()->getMemoryManager()->allowIndirectAllocationsAsPack(neoDevice->getRootDeviceIndex());
|
||||
if (NEO::DebugManager.flags.MakeIndirectAllocationsResidentAsPack.get() != -1) {
|
||||
submitAsPack = !!NEO::DebugManager.flags.MakeIndirectAllocationsResidentAsPack.get();
|
||||
}
|
||||
|
||||
if (submitAsPack) {
|
||||
svmAllocsManager->makeIndirectAllocationsResident(*(this->csr), this->csr->peekTaskCount() + 1u);
|
||||
} else {
|
||||
UnifiedMemoryControls unifiedMemoryControls = this->getUnifiedMemoryControls();
|
||||
|
||||
svmAllocsManager->addInternalAllocationsToResidencyContainer(neoDevice->getRootDeviceIndex(),
|
||||
this->commandContainer.getResidencyContainer(),
|
||||
unifiedMemoryControls.generateMask());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CommandList::setupTimestampEventForMultiTile(Event *signalEvent) {
|
||||
if (this->partitionCount > 1 &&
|
||||
signalEvent) {
|
||||
|
||||
@@ -217,6 +217,8 @@ struct CommandList : _ze_command_list_handle_t {
|
||||
return indirectAllocationsAllowed;
|
||||
}
|
||||
|
||||
void handleIndirectAllocationResidency();
|
||||
|
||||
NEO::PreemptionMode obtainKernelPreemptionMode(Kernel *kernel);
|
||||
|
||||
std::vector<Kernel *> &getPrintfKernelContainer() {
|
||||
|
||||
@@ -91,10 +91,8 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::executeCommandListImm
|
||||
size_t commandStreamStart = this->cmdListCurrentStartOffset;
|
||||
|
||||
auto lockCSR = this->csr->obtainUniqueOwnership();
|
||||
std::unique_lock<std::recursive_mutex> lockForIndirect;
|
||||
if (this->hasIndirectAllocationsAllowed()) {
|
||||
this->cmdQImmediate->handleIndirectAllocationResidency(this->getUnifiedMemoryControls(), lockForIndirect);
|
||||
}
|
||||
|
||||
this->handleIndirectAllocationResidency();
|
||||
|
||||
this->csr->setRequiredScratchSizes(this->getCommandListPerThreadScratchSize(), this->getCommandListPerThreadPrivateScratchSize());
|
||||
|
||||
|
||||
@@ -256,21 +256,4 @@ NEO::WaitStatus CommandQueueImp::CommandBufferManager::switchBuffers(NEO::Comman
|
||||
return waitStatus;
|
||||
}
|
||||
|
||||
void CommandQueueImp::handleIndirectAllocationResidency(UnifiedMemoryControls unifiedMemoryControls, std::unique_lock<std::recursive_mutex> &lockForIndirect) {
|
||||
NEO::Device *neoDevice = this->device->getNEODevice();
|
||||
auto svmAllocsManager = this->device->getDriverHandle()->getSvmAllocsManager();
|
||||
auto submitAsPack = this->device->getDriverHandle()->getMemoryManager()->allowIndirectAllocationsAsPack(neoDevice->getRootDeviceIndex());
|
||||
if (NEO::DebugManager.flags.MakeIndirectAllocationsResidentAsPack.get() != -1) {
|
||||
submitAsPack = !!NEO::DebugManager.flags.MakeIndirectAllocationsResidentAsPack.get();
|
||||
}
|
||||
|
||||
if (submitAsPack) {
|
||||
svmAllocsManager->makeIndirectAllocationsResident(*(this->csr), this->csr->peekTaskCount() + 1u);
|
||||
} else {
|
||||
lockForIndirect = this->device->getDriverHandle()->getSvmAllocsManager()->obtainOwnership();
|
||||
svmAllocsManager->addInternalAllocationsToResidencyContainer(neoDevice->getRootDeviceIndex(),
|
||||
this->csr->getResidencyAllocations(),
|
||||
unifiedMemoryControls.generateMask());
|
||||
}
|
||||
}
|
||||
} // namespace L0
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
|
||||
struct _ze_command_queue_handle_t {};
|
||||
|
||||
@@ -20,8 +19,6 @@ namespace NEO {
|
||||
class CommandStreamReceiver;
|
||||
}
|
||||
|
||||
struct UnifiedMemoryControls;
|
||||
|
||||
namespace L0 {
|
||||
struct Device;
|
||||
|
||||
@@ -52,8 +49,6 @@ struct CommandQueue : _ze_command_queue_handle_t {
|
||||
return static_cast<CommandQueue *>(handle);
|
||||
}
|
||||
|
||||
virtual void handleIndirectAllocationResidency(UnifiedMemoryControls unifiedMemoryControls, std::unique_lock<std::recursive_mutex> &lockForIndirect) = 0;
|
||||
|
||||
ze_command_queue_handle_t toHandle() { return this; }
|
||||
|
||||
bool peekIsCopyOnlyCommandQueue() const { return this->isCopyOnlyCommandQueue; }
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "shared/source/command_stream/stream_properties.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/unified_memory/unified_memory.h"
|
||||
|
||||
#include "level_zero/core/source/cmdqueue/cmdqueue_imp.h"
|
||||
|
||||
@@ -90,8 +89,6 @@ struct CommandQueueHw : public CommandQueueImp {
|
||||
bool isMigrationRequested{};
|
||||
bool isDirectSubmissionEnabled{};
|
||||
bool isDispatchTaskCountPostSyncRequired{};
|
||||
bool hasIndirectAccess{};
|
||||
UnifiedMemoryControls unifiedMemoryControls;
|
||||
};
|
||||
|
||||
ze_result_t validateCommandListsParams(CommandListExecutionContext &ctx,
|
||||
|
||||
@@ -93,6 +93,7 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
|
||||
}
|
||||
|
||||
this->device->activateMetricGroups();
|
||||
|
||||
if (this->isCopyOnlyCommandQueue) {
|
||||
ret = this->executeCommandListsCopyOnly(ctx, numCommandLists, phCommandLists, hFence);
|
||||
} else {
|
||||
@@ -116,13 +117,9 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandListsRegular(
|
||||
this->setupCmdListsAndContextParams(ctx, phCommandLists, numCommandLists, hFence);
|
||||
ctx.isDirectSubmissionEnabled = this->csr->isDirectSubmissionEnabled();
|
||||
|
||||
std::unique_lock<std::recursive_mutex> lockForIndirect;
|
||||
if (ctx.hasIndirectAccess) {
|
||||
handleIndirectAllocationResidency(ctx.unifiedMemoryControls, lockForIndirect);
|
||||
}
|
||||
|
||||
size_t linearStreamSizeEstimate = this->estimateLinearStreamSizeInitial(ctx, phCommandLists, numCommandLists);
|
||||
|
||||
this->csr->getResidencyAllocations().reserve(ctx.spaceForResidency);
|
||||
this->handleScratchSpaceAndUpdateGSBAStateDirtyFlag(ctx);
|
||||
this->setFrontEndStateProperties(ctx);
|
||||
|
||||
@@ -446,12 +443,6 @@ CommandQueueHw<gfxCoreFamily>::CommandListExecutionContext::CommandListExecution
|
||||
if (commandList->isMemoryPrefetchRequested()) {
|
||||
this->performMemoryPrefetch = true;
|
||||
}
|
||||
hasIndirectAccess |= commandList->hasIndirectAllocationsAllowed();
|
||||
if (commandList->hasIndirectAllocationsAllowed()) {
|
||||
unifiedMemoryControls.indirectDeviceAllocationsAllowed |= commandList->getUnifiedMemoryControls().indirectDeviceAllocationsAllowed;
|
||||
unifiedMemoryControls.indirectHostAllocationsAllowed |= commandList->getUnifiedMemoryControls().indirectHostAllocationsAllowed;
|
||||
unifiedMemoryControls.indirectSharedAllocationsAllowed |= commandList->getUnifiedMemoryControls().indirectSharedAllocationsAllowed;
|
||||
}
|
||||
}
|
||||
this->isDevicePreemptionModeMidThread = device->getDevicePreemptionMode() == NEO::PreemptionMode::MidThread;
|
||||
this->stateSipRequired = (this->isPreemptionModeInitial && this->isDevicePreemptionModeMidThread) ||
|
||||
@@ -531,8 +522,10 @@ void CommandQueueHw<gfxCoreFamily>::setupCmdListsAndContextParams(
|
||||
auto commandList = CommandList::fromHandle(phCommandLists[i]);
|
||||
|
||||
commandList->csr = this->csr;
|
||||
commandList->handleIndirectAllocationResidency();
|
||||
|
||||
ctx.containsAnyRegularCmdList |= commandList->cmdListType == CommandList::CommandListType::TYPE_REGULAR;
|
||||
ctx.spaceForResidency += commandList->commandContainer.getResidencyContainer().size();
|
||||
if (!isCopyOnlyCommandQueue) {
|
||||
ctx.perThreadScratchSpaceSize = std::max(ctx.perThreadScratchSpaceSize, commandList->getCommandListPerThreadScratchSize());
|
||||
ctx.perThreadPrivateScratchSize = std::max(ctx.perThreadPrivateScratchSize, commandList->getCommandListPerThreadPrivateScratchSize());
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
struct UnifiedMemoryControls;
|
||||
|
||||
namespace NEO {
|
||||
class LinearStream;
|
||||
class GraphicsAllocation;
|
||||
@@ -83,7 +81,6 @@ struct CommandQueueImp : public CommandQueue {
|
||||
MOCKABLE_VIRTUAL NEO::WaitStatus reserveLinearStreamSize(size_t size);
|
||||
ze_command_queue_mode_t getSynchronousMode() const;
|
||||
virtual bool getPreemptionCmdProgramming() = 0;
|
||||
void handleIndirectAllocationResidency(UnifiedMemoryControls unifiedMemoryControls, std::unique_lock<std::recursive_mutex> &lockForIndirect) override;
|
||||
|
||||
protected:
|
||||
MOCKABLE_VIRTUAL NEO::SubmissionStatus submitBatchBuffer(size_t offset, NEO::ResidencyContainer &residencyContainer, void *endingCmdPtr,
|
||||
|
||||
@@ -132,7 +132,6 @@ template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
struct MockCommandListImmediate : public CommandListCoreFamilyImmediate<gfxCoreFamily> {
|
||||
using CommandListCoreFamilyImmediate<gfxCoreFamily>::requiredStreamState;
|
||||
using CommandListCoreFamilyImmediate<gfxCoreFamily>::containsAnyKernel;
|
||||
using CommandListCoreFamilyImmediate<gfxCoreFamily>::indirectAllocationsAllowed;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace ult {
|
||||
template <>
|
||||
struct WhiteBox<::L0::DriverHandle> : public ::L0::DriverHandleImp {
|
||||
using ::L0::DriverHandleImp::enableProgramDebugging;
|
||||
using ::L0::DriverHandleImp::svmAllocsManager;
|
||||
};
|
||||
|
||||
using DriverHandle = WhiteBox<::L0::DriverHandle>;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/mocks/mock_command_stream_receiver.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
@@ -648,52 +647,5 @@ TEST(CommandList, whenAsMutableIsCalledNullptrIsReturned) {
|
||||
EXPECT_EQ(nullptr, cmdList.asMutable());
|
||||
}
|
||||
|
||||
class MockCommandQueueIndirectAccess : public Mock<CommandQueue> {
|
||||
public:
|
||||
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::recursive_mutex> &lockForIndirect) override {
|
||||
handleIndirectAllocationResidencyCalledTimes++;
|
||||
}
|
||||
uint32_t handleIndirectAllocationResidencyCalledTimes = 0;
|
||||
};
|
||||
|
||||
HWTEST2_F(CommandListTest, givenCmdListWithIndirectAccessWhenExecutingCommandListImmediateWithFlushTaskThenHandleIndirectAccessCalled, IsAtLeastSkl) {
|
||||
ze_command_queue_desc_t desc = {};
|
||||
desc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS;
|
||||
|
||||
ze_result_t returnValue;
|
||||
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::RenderCompute, returnValue));
|
||||
auto &commandListImmediate = static_cast<MockCommandListImmediate<gfxCoreFamily> &>(*commandList);
|
||||
|
||||
MockCommandStreamReceiver mockCommandStreamReceiver(*neoDevice->executionEnvironment, neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield());
|
||||
MockCommandQueueIndirectAccess mockCommandQueue(device, &mockCommandStreamReceiver, &desc);
|
||||
|
||||
auto oldCommandQueue = commandList->cmdQImmediate;
|
||||
commandList->cmdQImmediate = &mockCommandQueue;
|
||||
commandListImmediate.indirectAllocationsAllowed = true;
|
||||
commandListImmediate.executeCommandListImmediateWithFlushTask(false);
|
||||
EXPECT_EQ(mockCommandQueue.handleIndirectAllocationResidencyCalledTimes, 1u);
|
||||
commandList->cmdQImmediate = oldCommandQueue;
|
||||
}
|
||||
|
||||
HWTEST2_F(CommandListTest, givenCmdListWithNoIndirectAccessWhenExecutingCommandListImmediateWithFlushTaskThenHandleIndirectAccessNotCalled, IsAtLeastSkl) {
|
||||
ze_command_queue_desc_t desc = {};
|
||||
desc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS;
|
||||
|
||||
ze_result_t returnValue;
|
||||
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::RenderCompute, returnValue));
|
||||
auto &commandListImmediate = static_cast<MockCommandListImmediate<gfxCoreFamily> &>(*commandList);
|
||||
|
||||
MockCommandStreamReceiver mockCommandStreamReceiver(*neoDevice->executionEnvironment, neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield());
|
||||
MockCommandQueueIndirectAccess mockCommandQueue(device, &mockCommandStreamReceiver, &desc);
|
||||
|
||||
auto oldCommandQueue = commandList->cmdQImmediate;
|
||||
commandList->cmdQImmediate = &mockCommandQueue;
|
||||
commandListImmediate.indirectAllocationsAllowed = false;
|
||||
commandListImmediate.executeCommandListImmediateWithFlushTask(false);
|
||||
EXPECT_EQ(mockCommandQueue.handleIndirectAllocationResidencyCalledTimes, 0u);
|
||||
commandList->cmdQImmediate = oldCommandQueue;
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "level_zero/core/test/unit_tests/fixtures/module_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_memory_manager.h"
|
||||
|
||||
namespace L0 {
|
||||
@@ -1816,126 +1815,5 @@ TEST_F(CommandQueueCreate, givenCreatedCommandQueueWhenGettingMultiReturnPointFl
|
||||
commandQueue->destroy();
|
||||
}
|
||||
|
||||
struct SVMAllocsManagerMock : public NEO::SVMAllocsManager {
|
||||
using SVMAllocsManager::mtx;
|
||||
SVMAllocsManagerMock(MemoryManager *memoryManager) : NEO::SVMAllocsManager(memoryManager, false) {}
|
||||
void makeIndirectAllocationsResident(CommandStreamReceiver &commandStreamReceiver, uint32_t taskCount) override {
|
||||
makeIndirectAllocationsResidentCalledTimes++;
|
||||
}
|
||||
void addInternalAllocationsToResidencyContainer(uint32_t rootDeviceIndex,
|
||||
ResidencyContainer &residencyContainer,
|
||||
uint32_t requestedTypesMask) override {
|
||||
addInternalAllocationsToResidencyContainerCalledTimes++;
|
||||
passedContainer = residencyContainer.data();
|
||||
}
|
||||
uint32_t makeIndirectAllocationsResidentCalledTimes = 0;
|
||||
uint32_t addInternalAllocationsToResidencyContainerCalledTimes = 0;
|
||||
GraphicsAllocation **passedContainer;
|
||||
};
|
||||
|
||||
TEST_F(CommandQueueCreate, givenCommandQueueWhenHandleIndirectAllocationResidencyCalledAndSubmiPackEnabledThenMakeIndirectAllocResidentCalled) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.MakeIndirectAllocationsResidentAsPack.set(1);
|
||||
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::recursive_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(mockSvmAllocsManager->makeIndirectAllocationsResidentCalledTimes, 1u);
|
||||
EXPECT_EQ(mockSvmAllocsManager->addInternalAllocationsToResidencyContainerCalledTimes, 0u);
|
||||
reinterpret_cast<WhiteBox<::L0::DriverHandle> *>(device->getDriverHandle())->svmAllocsManager = prevSvmAllocsManager;
|
||||
commandQueue->destroy();
|
||||
}
|
||||
|
||||
TEST_F(CommandQueueCreate, givenCommandQueueWhenHandleIndirectAllocationResidencyCalledAndSubmiPackDisabeldThenAddInternalAllocationsToResidencyContainer) {
|
||||
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::recursive_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(mockSvmAllocsManager->makeIndirectAllocationsResidentCalledTimes, 0u);
|
||||
EXPECT_EQ(mockSvmAllocsManager->addInternalAllocationsToResidencyContainerCalledTimes, 1u);
|
||||
reinterpret_cast<WhiteBox<::L0::DriverHandle> *>(device->getDriverHandle())->svmAllocsManager = prevSvmAllocsManager;
|
||||
lock.unlock();
|
||||
commandQueue->destroy();
|
||||
}
|
||||
|
||||
TEST_F(CommandQueueCreate, givenCommandQueueWhenHandleIndirectAllocationResidencyCalledAndSubmiPackDisabeldThenSVMAllocsMtxIsLocked) {
|
||||
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::recursive_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);
|
||||
std::thread th([&] {
|
||||
EXPECT_FALSE(mockSvmAllocsManager->mtx.try_lock());
|
||||
});
|
||||
th.join();
|
||||
reinterpret_cast<WhiteBox<::L0::DriverHandle> *>(device->getDriverHandle())->svmAllocsManager = prevSvmAllocsManager;
|
||||
lock.unlock();
|
||||
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::recursive_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 L0
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
#include "level_zero/core/source/cmdqueue/cmdqueue_hw.h"
|
||||
#include "level_zero/core/source/cmdqueue/cmdqueue_hw.inl"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/module_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h"
|
||||
@@ -388,6 +386,68 @@ HWTEST2_F(CommandQueueCommandsMultiTile, givenCommandQueueOnMultiTileWhenWalkerP
|
||||
}
|
||||
|
||||
using CommandQueueIndirectAllocations = Test<ModuleFixture>;
|
||||
HWTEST_F(CommandQueueIndirectAllocations, givenCommandQueueWhenExecutingCommandListsThenExpectedIndirectAllocationsAddedToResidencyContainer) {
|
||||
const ze_command_queue_desc_t desc = {};
|
||||
|
||||
MockCsrHw2<FamilyType> csr(*neoDevice->getExecutionEnvironment(), 0, neoDevice->getDeviceBitfield());
|
||||
csr.initializeTagAllocation();
|
||||
csr.createKernelArgsBufferAllocation();
|
||||
csr.setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||
if (device->getNEODevice()->getPreemptionMode() == PreemptionMode::MidThread || device->getNEODevice()->isDebuggerActive()) {
|
||||
csr.createPreemptionAllocation();
|
||||
}
|
||||
|
||||
ze_result_t returnValue;
|
||||
L0::CommandQueue *commandQueue = CommandQueue::create(productFamily,
|
||||
device,
|
||||
&csr,
|
||||
&desc,
|
||||
false,
|
||||
false,
|
||||
returnValue);
|
||||
ASSERT_NE(nullptr, commandQueue);
|
||||
|
||||
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::Compute, 0u, returnValue));
|
||||
|
||||
void *deviceAlloc = nullptr;
|
||||
ze_device_mem_alloc_desc_t deviceDesc = {};
|
||||
auto result = context->allocDeviceMem(device->toHandle(), &deviceDesc, 16384u, 4096u, &deviceAlloc);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
auto gpuAlloc = device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(deviceAlloc)->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
|
||||
ASSERT_NE(nullptr, gpuAlloc);
|
||||
|
||||
createKernel();
|
||||
kernel->unifiedMemoryControls.indirectDeviceAllocationsAllowed = true;
|
||||
EXPECT_TRUE(kernel->getUnifiedMemoryControls().indirectDeviceAllocationsAllowed);
|
||||
|
||||
ze_group_count_t groupCount{1, 1, 1};
|
||||
CmdListKernelLaunchParams launchParams = {};
|
||||
result = commandList->appendLaunchKernel(kernel->toHandle(),
|
||||
&groupCount,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
launchParams);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
auto itorEvent = std::find(std::begin(commandList->commandContainer.getResidencyContainer()),
|
||||
std::end(commandList->commandContainer.getResidencyContainer()),
|
||||
gpuAlloc);
|
||||
EXPECT_EQ(itorEvent, std::end(commandList->commandContainer.getResidencyContainer()));
|
||||
|
||||
auto commandListHandle = commandList->toHandle();
|
||||
result = commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
itorEvent = std::find(std::begin(commandList->commandContainer.getResidencyContainer()),
|
||||
std::end(commandList->commandContainer.getResidencyContainer()),
|
||||
gpuAlloc);
|
||||
EXPECT_NE(itorEvent, std::end(commandList->commandContainer.getResidencyContainer()));
|
||||
|
||||
device->getDriverHandle()->getSvmAllocsManager()->freeSVMAlloc(deviceAlloc);
|
||||
commandQueue->destroy();
|
||||
}
|
||||
|
||||
HWTEST_F(CommandQueueIndirectAllocations, givenDebugModeToTreatIndirectAllocationsAsOnePackWhenIndirectAccessIsUsedThenWholePackIsMadeResident) {
|
||||
DebugManagerStateRestore restorer;
|
||||
@@ -716,63 +776,6 @@ HWTEST2_F(EngineInstancedDeviceExecuteTests, givenEngineInstancedDeviceWhenExecu
|
||||
|
||||
commandQueue->destroy();
|
||||
}
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
class MockCommandQueueHandleIndirectAllocs : public MockCommandQueueHw<gfxCoreFamily> {
|
||||
public:
|
||||
using typename MockCommandQueueHw<gfxCoreFamily>::CommandListExecutionContext;
|
||||
using MockCommandQueueHw<gfxCoreFamily>::executeCommandListsRegular;
|
||||
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::recursive_mutex> &lockForIndirect) override {
|
||||
handleIndirectAllocationResidencyCalledTimes++;
|
||||
}
|
||||
uint32_t handleIndirectAllocationResidencyCalledTimes = 0;
|
||||
};
|
||||
|
||||
HWTEST2_F(CommandQueueIndirectAllocations, givenCtxWithIndirectAccessWhenExecutingCommandListImmediateWithFlushTaskThenHandleIndirectAccessCalled, IsAtLeastSkl) {
|
||||
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};
|
||||
|
||||
ze_result_t returnValue;
|
||||
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::Compute, 0u, returnValue));
|
||||
ctx.hasIndirectAccess = true;
|
||||
ctx.isDispatchTaskCountPostSyncRequired = false;
|
||||
auto cmdListHandle = commandList.get()->toHandle();
|
||||
commandQueue->executeCommandListsRegular(ctx, 0, &cmdListHandle, nullptr);
|
||||
EXPECT_EQ(commandQueue->handleIndirectAllocationResidencyCalledTimes, 1u);
|
||||
commandQueue->destroy();
|
||||
}
|
||||
|
||||
HWTEST2_F(CommandQueueIndirectAllocations, givenCtxWitNohIndirectAccessWhenExecutingCommandListImmediateWithFlushTaskThenHandleIndirectAccessNotCalled, IsAtLeastSkl) {
|
||||
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};
|
||||
|
||||
ze_result_t returnValue;
|
||||
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::Compute, 0u, returnValue));
|
||||
ctx.hasIndirectAccess = false;
|
||||
ctx.isDispatchTaskCountPostSyncRequired = false;
|
||||
auto cmdListHandle = commandList.get()->toHandle();
|
||||
commandQueue->executeCommandListsRegular(ctx, 0, &cmdListHandle, nullptr);
|
||||
EXPECT_EQ(commandQueue->handleIndirectAllocationResidencyCalledTimes, 0u);
|
||||
commandQueue->destroy();
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
Reference in New Issue
Block a user