Disable GEM_WAIT when new residency model available

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2021-04-29 08:58:16 +00:00
committed by Compute-Runtime-Automation
parent 3dbe37c423
commit 8e1e213bcf
23 changed files with 119 additions and 45 deletions

View File

@@ -393,7 +393,8 @@ class CommandQueueHw : public CommandQueue {
TimestampPacketDependencies &timestampPacketDependencies,
EventsRequest &eventsRequest,
EventBuilder &eventBuilder,
uint32_t taskLevel);
uint32_t taskLevel,
CsrDependencies &csrDeps);
void processDispatchForCacheFlush(Surface **surfaces,
size_t numSurfaces,
LinearStream *commandStream,

View File

@@ -280,13 +280,13 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
flushDependenciesForNonKernelCommand, &blitPropertiesContainer);
if (!blockQueue) {
csrDeps.makeResident(getGpgpuCommandStreamReceiver());
if (parentKernel) {
processDeviceEnqueue(devQueueHw, multiDispatchInfo, hwTimeStamps, blocking);
}
if (enqueueProperties.operation == EnqueueProperties::Operation::GpuKernel) {
csrDeps.makeResident(getGpgpuCommandStreamReceiver());
completionStamp = enqueueNonBlocked<commandType>(
surfacesForResidency,
numSurfaceForResidency,
@@ -320,7 +320,8 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
timestampPacketDependencies,
eventsRequest,
eventBuilder,
taskLevel);
taskLevel,
csrDeps);
} else {
UNRECOVERABLE_IF(enqueueProperties.operation != EnqueueProperties::Operation::EnqueueWithoutSubmission);
@@ -974,13 +975,16 @@ CompletionStamp CommandQueueHw<GfxFamily>::enqueueCommandWithoutKernel(
TimestampPacketDependencies &timestampPacketDependencies,
EventsRequest &eventsRequest,
EventBuilder &eventBuilder,
uint32_t taskLevel) {
uint32_t taskLevel,
CsrDependencies &csrDeps) {
CompletionStamp completionStamp = {this->taskCount, this->taskLevel, this->flushStamp->peekStamp()};
bool flushGpgpuCsr = true;
if ((enqueueProperties.operation == EnqueueProperties::Operation::Blit) && !isGpgpuSubmissionForBcsRequired(false)) {
flushGpgpuCsr = false;
} else {
csrDeps.makeResident(getGpgpuCommandStreamReceiver());
}
if (eventBuilder.getEvent() && isProfilingEnabled()) {
@@ -1143,9 +1147,7 @@ void CommandQueueHw<GfxFamily>::enqueueBlit(const MultiDispatchInfo &multiDispat
const EnqueueProperties enqueueProperties(true, false, false, false, &blitPropertiesContainer);
if (!blockQueue) {
csrDeps.makeResident(getGpgpuCommandStreamReceiver());
completionStamp = enqueueCommandWithoutKernel(nullptr, 0, gpgpuCommandStream, gpgpuCommandStreamStart, blocking, enqueueProperties, timestampPacketDependencies, eventsRequest, eventBuilder, taskLevel);
completionStamp = enqueueCommandWithoutKernel(nullptr, 0, gpgpuCommandStream, gpgpuCommandStreamStart, blocking, enqueueProperties, timestampPacketDependencies, eventsRequest, eventBuilder, taskLevel, csrDeps);
if (eventBuilder.getEvent()) {
eventBuilder.getEvent()->flushStamp->replaceStampObject(this->flushStamp->getStampReference());

View File

@@ -43,7 +43,7 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
MOCKABLE_VIRTUAL void processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override;
void makeNonResident(GraphicsAllocation &gfxAllocation) override;
bool waitForFlushStamp(FlushStamp &flushStampToWait) override;
bool isAnyDirectSubmissionActive() override;
bool isNewResidencyModelActive() override;
DrmMemoryManager *getMemoryManager() const;
GmmPageTableMngr *createPageTableManager() override;

View File

@@ -82,12 +82,14 @@ bool DrmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer, Reside
memoryOperationsInterface->mergeWithResidencyContainer(this->osContext, allocationsForResidency);
if (this->directSubmission.get()) {
if (this->drm->isVmBindAvailable()) {
memoryOperationsInterface->makeResidentWithinOsContext(this->osContext, ArrayRef<GraphicsAllocation *>(&batchBuffer.commandBufferAllocation, 1), true);
}
if (this->directSubmission.get()) {
return this->directSubmission->dispatchCommandBuffer(batchBuffer, *this->flushStamp.get());
}
if (this->blitterDirectSubmission.get()) {
memoryOperationsInterface->makeResidentWithinOsContext(this->osContext, ArrayRef<GraphicsAllocation *>(&batchBuffer.commandBufferAllocation, 1), true);
return this->blitterDirectSubmission->dispatchCommandBuffer(batchBuffer, *this->flushStamp.get());
}
@@ -200,8 +202,8 @@ bool DrmCommandStreamReceiver<GfxFamily>::waitForFlushStamp(FlushStamp &flushSta
}
template <typename GfxFamily>
bool DrmCommandStreamReceiver<GfxFamily>::isAnyDirectSubmissionActive() {
return this->drm->isDirectSubmissionActive();
bool DrmCommandStreamReceiver<GfxFamily>::isNewResidencyModelActive() {
return this->drm->isVmBindAvailable();
}
} // namespace NEO

View File

@@ -50,10 +50,11 @@ HWTEST_F(EnqueueHandlerTest, GivenCommandStreamWithoutKernelWhenCommandEnqueuedT
Surface *surfaces[] = {surface.get()};
auto blocking = true;
TimestampPacketDependencies timestampPacketDependencies;
CsrDependencies csrDeps;
EnqueueProperties enqueueProperties(false, false, false, true, nullptr);
mockCmdQ->enqueueCommandWithoutKernel(surfaces, 1, &mockCmdQ->getCS(0), 0, blocking, enqueueProperties, timestampPacketDependencies,
eventsRequest, eventBuilder, 0);
eventsRequest, eventBuilder, 0, csrDeps);
EXPECT_EQ(allocation->getTaskCount(mockCmdQ->getGpgpuCommandStreamReceiver().getOsContext().getContextId()), 1u);
}
@@ -87,13 +88,14 @@ HWTEST_F(EnqueueHandlerTimestampEnabledTest, givenProflingAndTimeStampPacketsEna
Surface *surfaces[] = {surface.get()};
auto blocking = true;
TimestampPacketDependencies timestampPacketDependencies;
CsrDependencies csrDeps;
EnqueueProperties enqueueProperties(false, false, false, true, nullptr);
EXPECT_EQ(ev->submitTimeStamp.CPUTimeinNS, 0u);
EXPECT_EQ(ev->submitTimeStamp.GPUTimeStamp, 0u);
mockCmdQ->enqueueCommandWithoutKernel(surfaces, 1, &mockCmdQ->getCS(0), 0, blocking, enqueueProperties, timestampPacketDependencies,
eventsRequest, eventBuilder, 0);
eventsRequest, eventBuilder, 0, csrDeps);
EXPECT_NE(ev->submitTimeStamp.CPUTimeinNS, 0u);
EXPECT_NE(ev->submitTimeStamp.GPUTimeStamp, 0u);
@@ -117,13 +119,14 @@ HWTEST_F(EnqueueHandlerTimestampDisabledTest, givenProflingEnabledTimeStampPacke
Surface *surfaces[] = {surface.get()};
auto blocking = true;
TimestampPacketDependencies timestampPacketDependencies;
CsrDependencies csrDeps;
EnqueueProperties enqueueProperties(false, false, false, true, nullptr);
EXPECT_EQ(ev->submitTimeStamp.CPUTimeinNS, 0u);
EXPECT_EQ(ev->submitTimeStamp.GPUTimeStamp, 0u);
mockCmdQ->enqueueCommandWithoutKernel(surfaces, 1, &mockCmdQ->getCS(0), 0, blocking, enqueueProperties, timestampPacketDependencies,
eventsRequest, eventBuilder, 0);
eventsRequest, eventBuilder, 0, csrDeps);
EXPECT_NE(ev->submitTimeStamp.CPUTimeinNS, 0u);
EXPECT_NE(ev->submitTimeStamp.GPUTimeStamp, 0u);
@@ -195,12 +198,13 @@ HWTEST_F(DispatchFlagsTests, whenEnqueueCommandWithoutKernelThenPassCorrectDispa
auto blocking = true;
TimestampPacketDependencies timestampPacketDependencies;
CsrDependencies csrDeps;
EventsRequest eventsRequest(0, nullptr, nullptr);
EventBuilder eventBuilder;
EnqueueProperties enqueueProperties(false, false, false, true, nullptr);
mockCmdQ->enqueueCommandWithoutKernel(nullptr, 0, &mockCmdQ->getCS(0), 0, blocking, enqueueProperties, timestampPacketDependencies,
eventsRequest, eventBuilder, 0);
eventsRequest, eventBuilder, 0, csrDeps);
EXPECT_EQ(blocking, mockCsr->passedDispatchFlags.blocking);
EXPECT_FALSE(mockCsr->passedDispatchFlags.implicitFlush);
@@ -220,6 +224,7 @@ HWTEST_F(DispatchFlagsTests, whenEnqueueCommandWithoutKernelThenPassCorrectThrot
auto mockCsr = static_cast<CsrType *>(&mockCmdQ->getGpgpuCommandStreamReceiver());
TimestampPacketDependencies timestampPacketDependencies;
CsrDependencies csrDeps;
EventsRequest eventsRequest(0, nullptr, nullptr);
EventBuilder eventBuilder;
@@ -227,7 +232,7 @@ HWTEST_F(DispatchFlagsTests, whenEnqueueCommandWithoutKernelThenPassCorrectThrot
bool blocking = true;
mockCmdQ->enqueueCommandWithoutKernel(nullptr, 0, &mockCmdQ->getCS(0), 0, blocking, enqueueProperties, timestampPacketDependencies,
eventsRequest, eventBuilder, 0);
eventsRequest, eventBuilder, 0, csrDeps);
EXPECT_EQ(mockCmdQ->throttle, mockCsr->passedDispatchFlags.throttle);
}
@@ -254,6 +259,7 @@ HWTEST_F(DispatchFlagsTests, givenBlitEnqueueWhenDispatchingCommandsWithoutKerne
builtinOpParams.dstPtr = reinterpret_cast<void *>(0x1234);
MultiDispatchInfo multiDispatchInfo;
multiDispatchInfo.setBuiltinOpParams(builtinOpParams);
CsrDependencies csrDeps;
mockCmdQ->obtainNewTimestampPacketNodes(1, timestampPacketDependencies.previousEnqueueNodes, true, true);
@@ -266,7 +272,7 @@ HWTEST_F(DispatchFlagsTests, givenBlitEnqueueWhenDispatchingCommandsWithoutKerne
EnqueueProperties enqueueProperties(true, false, false, false, &blitPropertiesContainer);
mockCmdQ->enqueueCommandWithoutKernel(nullptr, 0, &mockCmdQ->getCS(0), 0, blocking, enqueueProperties, timestampPacketDependencies,
eventsRequest, eventBuilder, 0);
eventsRequest, eventBuilder, 0, csrDeps);
EXPECT_TRUE(mockCsr->passedDispatchFlags.implicitFlush);
EXPECT_TRUE(mockCsr->passedDispatchFlags.guardCommandBufferWithPipeControl);
@@ -306,15 +312,16 @@ HWTEST_F(DispatchFlagsTests, givenN1EnabledWhenDispatchingWithoutKernelTheAllowO
BlitPropertiesContainer blitPropertiesContainer;
blitPropertiesContainer.push_back(blitProperties);
EnqueueProperties enqueueProperties(true, false, false, false, &blitPropertiesContainer);
CsrDependencies csrDeps;
mockCsr->nTo1SubmissionModelEnabled = false;
mockCmdQ->enqueueCommandWithoutKernel(nullptr, 0, &mockCmdQ->getCS(0), 0, blocked, enqueueProperties, timestampPacketDependencies,
eventsRequest, eventBuilder, 0);
eventsRequest, eventBuilder, 0, csrDeps);
EXPECT_FALSE(mockCsr->passedDispatchFlags.outOfOrderExecutionAllowed);
mockCsr->nTo1SubmissionModelEnabled = true;
mockCmdQ->enqueueCommandWithoutKernel(nullptr, 0, &mockCmdQ->getCS(0), 0, blocked, enqueueProperties, timestampPacketDependencies,
eventsRequest, eventBuilder, 0);
eventsRequest, eventBuilder, 0, csrDeps);
EXPECT_TRUE(mockCsr->passedDispatchFlags.outOfOrderExecutionAllowed);
}

View File

@@ -318,7 +318,7 @@ TEST_F(KmdNotifyTests, givenTaskCountDiffGreaterThanMinimumToCheckAcLineAndDisab
EXPECT_EQ(1u, helper.updateAcLineStatusCalled);
}
TEST_F(KmdNotifyTests, givenEnableDirectSubmissionWhenObtainTimeoutParamsThenFalseIsReturned) {
TEST_F(KmdNotifyTests, givenNewResidencyModelAvailableWhenObtainTimeoutParamsThenFalseIsReturned) {
MockKmdNotifyHelper helper(&(hwInfo->capabilityTable.kmdNotifyProperties));
int64_t timeout = 0;

View File

@@ -730,6 +730,27 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenAllocateGraphicsMemor
memoryManager.freeGraphicsMemory(imageAllocation);
}
TEST(OsAgnosticMemoryManager, givenDestroyedTagAllocationWhenWaitForCompletiionThenWaitForTaskCountIsNotCalled) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
auto memoryManager = new OsAgnosticMemoryManager(executionEnvironment);
DeviceBitfield deviceBitfield(1);
std::unique_ptr<CommandStreamReceiver> csr(createCommandStream(executionEnvironment, 0u, deviceBitfield));
executionEnvironment.memoryManager.reset(memoryManager);
auto osContext = memoryManager->createAndRegisterOsContext(csr.get(),
HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*defaultHwInfo)[0],
deviceBitfield,
PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo),
false);
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{0, MemoryConstants::pageSize});
allocation->updateTaskCount(10, osContext->getContextId());
EXPECT_GT(allocation->getTaskCount(osContext->getContextId()), csr->peekTaskCount());
memoryManager->waitForEnginesCompletion(*allocation);
memoryManager->freeGraphicsMemory(allocation);
}
TEST(OsAgnosticMemoryManager, givenEnabledLocalMemoryWhenAllocateGraphicsMemoryForImageIsCalledThenUseLocalMemoryIsNotSet) {
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
MockMemoryManager memoryManager(false, true, *executionEnvironment);

View File

@@ -111,8 +111,8 @@ TEST_F(DrmBufferObjectTest, GivenInvalidTilingWhenSettingTilingThenCallFails) {
EXPECT_FALSE(ret);
}
TEST_F(DrmBufferObjectTest, givenDirectSubmissionActiveWhenCallWaitThenNoIoctlIsCalled) {
mock->setDirectSubmissionActive(true);
TEST_F(DrmBufferObjectTest, givenBindAvailableWhenCallWaitThenNoIoctlIsCalled) {
mock->bindAvailable = true;
mock->ioctl_expected.total = 0;
auto ret = bo->wait(-1);
EXPECT_FALSE(ret);

View File

@@ -1383,6 +1383,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamDirectSubmissionTest, givenEnabledDirectSubmi
}
HWTEST_TEMPLATED_F(DrmCommandStreamDirectSubmissionTest, givenEnabledDirectSubmissionWhenFlushThenCommandBufferAllocationIsResident) {
mock->bindAvailable = true;
auto &cs = csr->getCS();
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
CommandStreamReceiverHw<FamilyType>::alignToCacheLine(cs);
@@ -1421,6 +1422,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamBlitterDirectSubmissionTest, givenEnabledDire
}
HWTEST_TEMPLATED_F(DrmCommandStreamBlitterDirectSubmissionTest, givenEnabledDirectSubmissionOnBlitterWhenFlushThenCommandBufferAllocationIsResident) {
mock->bindAvailable = true;
auto &cs = csr->getCS();
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
CommandStreamReceiverHw<FamilyType>::alignToCacheLine(cs);

View File

@@ -90,6 +90,24 @@ TEST_F(DrmMemoryManagerTest, givenDebugVariableWhenCreatingDrmMemoryManagerThenS
}
}
TEST_F(DrmMemoryManagerTest, whenNewResidencyModelAvailableThenGemCloseWorkerInactive) {
auto drm = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->getDrm());
drm->bindAvailable = true;
memoryManager->disableGemCloseWorkerForNewResidencyModel();
for (const auto &engine : memoryManager->getRegisteredEngines()) {
auto engineRootDeviceIndex = engine.commandStreamReceiver->getRootDeviceIndex();
auto rootDeviceDrm = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[engineRootDeviceIndex]->osInterface->get()->getDrm());
auto csr = static_cast<TestedDrmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *>(engine.commandStreamReceiver);
EXPECT_TRUE(rootDeviceDrm->isVmBindAvailable());
EXPECT_EQ(csr->peekGemCloseWorkerOperationMode(), gemCloseWorkerMode::gemCloseWorkerInactive);
}
this->dontTestIoctlInTearDown = true;
}
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenCheckForKmdMigrationThenCorrectValueIsReturned) {
DebugManagerStateRestore restorer;
auto drm = static_cast<DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->getDrm());
@@ -135,6 +153,8 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenCheckForKmdMigrationThenCo
EXPECT_FALSE(retVal);
}
this->dontTestIoctlInTearDown = true;
}
TEST_F(DrmMemoryManagerTest, GivenGraphicsAllocationWhenAddAndRemoveAllocationToHostPtrManagerThenfragmentHasCorrectValues) {

View File

@@ -44,6 +44,7 @@ class DrmMemoryManagerBasic : public ::testing::Test {
class DrmMemoryManagerFixture : public MemoryManagementFixture {
public:
DrmMockCustom *mock = nullptr;
bool dontTestIoctlInTearDown = false;
const uint32_t rootDeviceIndex = 1u;
const uint32_t numRootDevices = 2u;
TestedDrmMemoryManager *memoryManager = nullptr;
@@ -103,6 +104,9 @@ class DrmMemoryManagerFixture : public MemoryManagementFixture {
mock->ioctl_expected.gemWait += additionalDestroyDeviceIoctls.gemWait.load();
mock->ioctl_expected.gemClose += additionalDestroyDeviceIoctls.gemClose.load();
delete device;
if (dontTestIoctlInTearDown) {
mock->reset();
}
mock->testIoctls();
executionEnvironment->decRefInternal();
MemoryManagementFixture::TearDown();

View File

@@ -119,7 +119,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
return blitterDirectSubmission.get() != nullptr;
}
virtual bool isAnyDirectSubmissionActive() { return false; }
virtual bool isNewResidencyModelActive() { return false; }
bool initDirectSubmission(Device &device, OsContext &osContext) override;
GraphicsAllocation *getClearColorAllocation() override;

View File

@@ -854,7 +854,7 @@ inline void CommandStreamReceiverHw<GfxFamily>::waitForTaskCountWithKmdNotifyFal
int64_t waitTimeout = 0;
bool enableTimeout = false;
enableTimeout = kmdNotifyHelper->obtainTimeoutParams(waitTimeout, useQuickKmdSleep, *getTagAddress(), taskCountToWait, flushStampToWait, forcePowerSavingMode, this->isAnyDirectSubmissionActive());
enableTimeout = kmdNotifyHelper->obtainTimeoutParams(waitTimeout, useQuickKmdSleep, *getTagAddress(), taskCountToWait, flushStampToWait, forcePowerSavingMode, this->isNewResidencyModelActive());
PRINT_DEBUG_STRING(DebugManager.flags.LogWaitingForCompletion.get(), stdout,
"\nWaiting for task count %u at location %p. Current value: %u\n",

View File

@@ -31,9 +31,6 @@ DrmDirectSubmission<GfxFamily, Dispatcher>::DrmDirectSubmission(Device &device,
if (DebugManager.flags.DirectSubmissionDisableMonitorFence.get() != -1) {
this->disableMonitorFence = DebugManager.flags.DirectSubmissionDisableMonitorFence.get();
}
auto osContextLinux = static_cast<OsContextLinux *>(&this->osContext);
osContextLinux->getDrm().setDirectSubmissionActive(true);
};
template <typename GfxFamily, typename Dispatcher>

View File

@@ -19,12 +19,12 @@ bool KmdNotifyHelper::obtainTimeoutParams(int64_t &timeoutValueOutput,
uint32_t taskCountToWait,
FlushStamp flushStampToWait,
bool forcePowerSavingMode,
bool directSubmissionActive) {
bool newResidencyModelActive) {
if (flushStampToWait == 0) {
return false;
}
if (directSubmissionActive) {
if (newResidencyModelActive) {
return false;
}

View File

@@ -42,7 +42,7 @@ class KmdNotifyHelper {
uint32_t taskCountToWait,
FlushStamp flushStampToWait,
bool forcePowerSavingMode,
bool directSubmissionActive);
bool newResidencyModelActive);
bool quickKmdSleepForSporadicWaitsEnabled() const { return properties->enableQuickKmdSleepForSporadicWaits; }
MOCKABLE_VIRTUAL void updateLastWaitForCompletionTimestamp();

View File

@@ -621,6 +621,7 @@ void MemoryManager::waitForEnginesCompletion(GraphicsAllocation &graphicsAllocat
auto osContextId = engine.osContext->getContextId();
auto allocationTaskCount = graphicsAllocation.getTaskCount(osContextId);
if (graphicsAllocation.isUsedByOsContext(osContextId) &&
engine.commandStreamReceiver->getTagAllocation() != nullptr &&
allocationTaskCount > *engine.commandStreamReceiver->getTagAddress()) {
engine.commandStreamReceiver->waitForCompletionWithTimeout(false, TimeoutControls::maxTimeout, allocationTaskCount);
}

View File

@@ -197,6 +197,8 @@ class MemoryManager {
virtual void registerSysMemAlloc(GraphicsAllocation *allocation){};
virtual void registerLocalMemAlloc(GraphicsAllocation *allocation, uint32_t rootDeviceIndex){};
virtual void disableGemCloseWorkerForNewResidencyModel(){};
protected:
bool getAllocationData(AllocationData &allocationData, const AllocationProperties &properties, const void *hostPtr, const StorageInfo &storageInfo);
static void overrideAllocationData(AllocationData &allocationData, const AllocationProperties &properties);

View File

@@ -13,6 +13,7 @@
#include "shared/source/device/root_device.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/memory_manager/memory_manager.h"
#include "shared/source/os_interface/aub_memory_operations_handler.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/source/os_interface/os_interface.h"
@@ -153,6 +154,9 @@ std::vector<std::unique_ptr<Device>> DeviceFactory::createDevices(ExecutionEnvir
devices.push_back(std::move(device));
}
}
executionEnvironment.memoryManager->disableGemCloseWorkerForNewResidencyModel();
return devices;
}

View File

@@ -71,7 +71,7 @@ bool BufferObject::close() {
}
int BufferObject::wait(int64_t timeoutNs) {
if (this->drm->isDirectSubmissionActive()) {
if (this->drm->isVmBindAvailable()) {
return 0;
}
@@ -250,6 +250,11 @@ int BufferObject::validateHostPtr(BufferObject *const boToPin[], size_t numberOf
if (osContext->isDirectSubmissionActive()) {
retVal = bindBOsWithinContext(boToPin, numberOfBos, osContext, vmHandleId);
} else {
if (this->drm->isVmBindAvailable()) {
auto thisBo = this;
bindBOsWithinContext(&thisBo, 1u, osContext, vmHandleId);
bindBOsWithinContext(boToPin, numberOfBos, osContext, vmHandleId);
}
StackVec<drm_i915_gem_exec_object2, maxFragmentsCount + 1> execObject(numberOfBos + 1);
retVal = this->exec(4u, 0u, 0u, false, osContext, vmHandleId, drmContextId, boToPin, numberOfBos, &execObject[0]);
}

View File

@@ -728,7 +728,11 @@ void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation)
}
void DrmMemoryManager::handleFenceCompletion(GraphicsAllocation *allocation) {
if (this->getDrm(allocation->getRootDeviceIndex()).isVmBindAvailable()) {
waitForEnginesCompletion(*allocation);
} else {
static_cast<DrmAllocation *>(allocation)->getBO()->wait(-1);
}
}
GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromExistingStorage(AllocationProperties &properties, void *ptr, MultiGraphicsAllocation &multiGraphicsAllocation) {
@@ -994,6 +998,17 @@ void DrmMemoryManager::unregisterAllocation(GraphicsAllocation *allocation) {
localMemAllocs[allocation->getRootDeviceIndex()].end());
}
void DrmMemoryManager::disableGemCloseWorkerForNewResidencyModel() {
for (auto &engine : this->registeredEngines) {
auto rootDeviceIndex = engine.commandStreamReceiver->getRootDeviceIndex();
auto &drm = this->getDrm(rootDeviceIndex);
if (drm.isVmBindAvailable()) {
engine.commandStreamReceiver->initializeDefaultsForInternalEngine();
}
}
}
void DrmMemoryManager::registerAllocationInOs(GraphicsAllocation *allocation) {
if (allocation && getDrm(allocation->getRootDeviceIndex()).resourceRegistrationEnabled()) {
auto drmAllocation = static_cast<DrmAllocation *>(allocation);

View File

@@ -71,6 +71,8 @@ class DrmMemoryManager : public MemoryManager {
void registerLocalMemAlloc(GraphicsAllocation *allocation, uint32_t rootDeviceIndex) override;
void unregisterAllocation(GraphicsAllocation *allocation);
void disableGemCloseWorkerForNewResidencyModel() override;
protected:
BufferObject *findAndReferenceSharedBufferObject(int boHandle);
void eraseSharedBufferObject(BufferObject *bo);

View File

@@ -98,17 +98,6 @@ HWTEST_F(DrmDirectSubmissionTest, whenCreateDirectSubmissionThenValidObjectIsRet
EXPECT_NE(directSubmission.get(), nullptr);
}
HWTEST_F(DrmDirectSubmissionTest, givenDrmDirectSubmissionWhenDestructObjectThenIoctlIsCalled) {
auto drmDirectSubmission = std::make_unique<MockDrmDirectSubmission<FamilyType, RenderDispatcher<FamilyType>>>(*device.get(),
*osContext.get());
auto drm = static_cast<DrmMock *>(executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->getDrm());
drmDirectSubmission->initialize(true);
drm->ioctlCallsCount = 0u;
drmDirectSubmission.reset();
EXPECT_EQ(drm->ioctlCallsCount, 3u);
}
HWTEST_F(DrmDirectSubmissionTest, givenDisabledMonitorFenceWhenDispatchSwitchRingBufferThenDispatchPipeControl) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using Dispatcher = RenderDispatcher<FamilyType>;