fix: stop direct submission on platform destruction
Related-To: NEO-8072 Signed-off-by: Igor Venevtsev <igor.venevtsev@intel.com>
This commit is contained in:
parent
1418300d31
commit
c2c622d695
|
@ -44,6 +44,7 @@ Platform::~Platform() {
|
||||||
|
|
||||||
for (auto clDevice : this->clDevices) {
|
for (auto clDevice : this->clDevices) {
|
||||||
clDevice->getDevice().getRootDeviceEnvironmentRef().debugger.reset(nullptr);
|
clDevice->getDevice().getRootDeviceEnvironmentRef().debugger.reset(nullptr);
|
||||||
|
clDevice->getDevice().stopDirectSubmission();
|
||||||
clDevice->decRefInternal();
|
clDevice->decRefInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,28 @@ TEST_F(PlatformTest, WhenGetDeviceIsCalledThenExpectedValuesAreReturned) {
|
||||||
EXPECT_EQ(nullptr, pPlatform->getClDevice(numDevices));
|
EXPECT_EQ(nullptr, pPlatform->getClDevice(numDevices));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(PlatformTest, WhenPlatformIsDestroyedThenDirectSubmissionIsTerminated) {
|
||||||
|
VariableBackup<decltype(DeviceFactory::createRootDeviceFunc)> createFuncBackup{&DeviceFactory::createRootDeviceFunc};
|
||||||
|
DeviceFactory::createRootDeviceFunc = [](ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex) -> std::unique_ptr<Device> {
|
||||||
|
return std::unique_ptr<Device>(MockDevice::create<MockDevice>(&executionEnvironment, rootDeviceIndex));
|
||||||
|
};
|
||||||
|
|
||||||
|
pPlatform->initializeWithNewDevices();
|
||||||
|
|
||||||
|
auto clDevice = pPlatform->getClDevice(0);
|
||||||
|
EXPECT_NE(nullptr, clDevice);
|
||||||
|
|
||||||
|
auto mockDevice = static_cast<MockDevice *>(&clDevice->getDevice());
|
||||||
|
EXPECT_FALSE(mockDevice->stopDirectSubmissionCalled);
|
||||||
|
|
||||||
|
clDevice->incRefInternal();
|
||||||
|
|
||||||
|
pPlatform = nullptr;
|
||||||
|
EXPECT_TRUE(mockDevice->stopDirectSubmissionCalled);
|
||||||
|
|
||||||
|
clDevice->decRefInternal();
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(PlatformTest, WhenGetClDevicesIsCalledThenExpectedValuesAreReturned) {
|
TEST_F(PlatformTest, WhenGetClDevicesIsCalledThenExpectedValuesAreReturned) {
|
||||||
EXPECT_EQ(nullptr, pPlatform->getClDevices());
|
EXPECT_EQ(nullptr, pPlatform->getClDevices());
|
||||||
|
|
||||||
|
|
|
@ -865,6 +865,15 @@ const ReleaseHelper *Device::getReleaseHelper() const {
|
||||||
return getRootDeviceEnvironment().getReleaseHelper();
|
return getRootDeviceEnvironment().getReleaseHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Device::stopDirectSubmission() {
|
||||||
|
for (auto &engine : allEngines) {
|
||||||
|
auto csr = engine.commandStreamReceiver;
|
||||||
|
if (csr->isAnyDirectSubmissionEnabled()) {
|
||||||
|
csr->stopDirectSubmission();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Device::allocateRTDispatchGlobals(uint32_t maxBvhLevels) {
|
void Device::allocateRTDispatchGlobals(uint32_t maxBvhLevels) {
|
||||||
UNRECOVERABLE_IF(rtDispatchGlobalsInfos.size() < maxBvhLevels + 1);
|
UNRECOVERABLE_IF(rtDispatchGlobalsInfos.size() < maxBvhLevels + 1);
|
||||||
UNRECOVERABLE_IF(rtDispatchGlobalsInfos[maxBvhLevels] != nullptr);
|
UNRECOVERABLE_IF(rtDispatchGlobalsInfos[maxBvhLevels] != nullptr);
|
||||||
|
|
|
@ -165,6 +165,7 @@ class Device : public ReferenceTrackedObject<Device> {
|
||||||
|
|
||||||
uint32_t getNumberOfRegularContextsPerEngine() const { return numberOfRegularContextsPerEngine; }
|
uint32_t getNumberOfRegularContextsPerEngine() const { return numberOfRegularContextsPerEngine; }
|
||||||
bool isMultiRegularContextSelectionAllowed(aub_stream::EngineType engineType, EngineUsage engineUsage) const;
|
bool isMultiRegularContextSelectionAllowed(aub_stream::EngineType engineType, EngineUsage engineUsage) const;
|
||||||
|
MOCKABLE_VIRTUAL void stopDirectSubmission();
|
||||||
|
|
||||||
std::atomic<uint32_t> debugExecutionCounter = 0;
|
std::atomic<uint32_t> debugExecutionCounter = 0;
|
||||||
|
|
||||||
|
|
|
@ -404,6 +404,11 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
|
||||||
return *flushReturnValue;
|
return *flushReturnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stopDirectSubmission() override {
|
||||||
|
stopDirectSubmissionCalled = true;
|
||||||
|
BaseClass::stopDirectSubmission();
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> aubCommentMessages;
|
std::vector<std::string> aubCommentMessages;
|
||||||
|
|
||||||
BatchBuffer latestFlushedBatchBuffer = {};
|
BatchBuffer latestFlushedBatchBuffer = {};
|
||||||
|
@ -458,6 +463,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
|
||||||
bool forceReturnGpuHang = false;
|
bool forceReturnGpuHang = false;
|
||||||
bool callBaseIsKmdWaitOnTaskCountAllowed = false;
|
bool callBaseIsKmdWaitOnTaskCountAllowed = false;
|
||||||
bool isKmdWaitOnTaskCountAllowedValue = false;
|
bool isKmdWaitOnTaskCountAllowedValue = false;
|
||||||
|
bool stopDirectSubmissionCalled = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|
|
@ -162,6 +162,11 @@ class MockDevice : public RootDevice {
|
||||||
void setRTDispatchGlobalsForceAllocation() {
|
void setRTDispatchGlobalsForceAllocation() {
|
||||||
rtDispatchGlobalsForceAllocation = true;
|
rtDispatchGlobalsForceAllocation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stopDirectSubmission() override {
|
||||||
|
stopDirectSubmissionCalled = true;
|
||||||
|
Device::stopDirectSubmission();
|
||||||
|
}
|
||||||
static ExecutionEnvironment *prepareExecutionEnvironment(const HardwareInfo *pHwInfo);
|
static ExecutionEnvironment *prepareExecutionEnvironment(const HardwareInfo *pHwInfo);
|
||||||
static decltype(&createCommandStream) createCommandStreamReceiverFunc;
|
static decltype(&createCommandStream) createCommandStreamReceiverFunc;
|
||||||
|
|
||||||
|
@ -172,6 +177,7 @@ class MockDevice : public RootDevice {
|
||||||
bool verifyAdapterLuidReturnValue = true;
|
bool verifyAdapterLuidReturnValue = true;
|
||||||
size_t maxParameterSizeFromIGC = 0u;
|
size_t maxParameterSizeFromIGC = 0u;
|
||||||
bool rtDispatchGlobalsForceAllocation = true;
|
bool rtDispatchGlobalsForceAllocation = true;
|
||||||
|
bool stopDirectSubmissionCalled = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
|
|
@ -97,6 +97,48 @@ HWTEST_F(DirectSubmissionTest, givenBlitterDirectSubmissionWhenStopThenRingIsNot
|
||||||
csr.blitterDirectSubmission.release();
|
csr.blitterDirectSubmission.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWTEST_F(DirectSubmissionTest, givenDeviceStopDirectSubmissionCalledThenCsrStopDirecttSubmissionCalled) {
|
||||||
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||||
|
ultHwConfig.csrBaseCallDirectSubmissionAvailable = true;
|
||||||
|
ultHwConfig.csrBaseCallBlitterDirectSubmissionAvailable = true;
|
||||||
|
|
||||||
|
MockDirectSubmissionHw<FamilyType, RenderDispatcher<FamilyType>> directSubmission(*pDevice->getDefaultEngine().commandStreamReceiver);
|
||||||
|
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||||
|
csr.directSubmission.reset(&directSubmission);
|
||||||
|
|
||||||
|
bool ret = directSubmission.initialize(true, false);
|
||||||
|
EXPECT_TRUE(ret);
|
||||||
|
|
||||||
|
EXPECT_FALSE(csr.stopDirectSubmissionCalled);
|
||||||
|
pDevice->stopDirectSubmission();
|
||||||
|
EXPECT_TRUE(csr.stopDirectSubmissionCalled);
|
||||||
|
|
||||||
|
csr.directSubmission.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
HWTEST_F(DirectSubmissionTest, givenDeviceStopDirectSubmissionCalledThenBcsStopDirecttSubmissionCalled) {
|
||||||
|
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||||
|
ultHwConfig.csrBaseCallDirectSubmissionAvailable = true;
|
||||||
|
ultHwConfig.csrBaseCallBlitterDirectSubmissionAvailable = true;
|
||||||
|
|
||||||
|
MockDirectSubmissionHw<FamilyType, BlitterDispatcher<FamilyType>> directSubmission(*pDevice->getDefaultEngine().commandStreamReceiver);
|
||||||
|
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||||
|
std::unique_ptr<OsContext> osContext(OsContext::create(pDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.get(), pDevice->getRootDeviceIndex(), 0,
|
||||||
|
EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::Regular},
|
||||||
|
PreemptionMode::ThreadGroup, pDevice->getDeviceBitfield())));
|
||||||
|
csr.blitterDirectSubmission.reset(&directSubmission);
|
||||||
|
csr.setupContext(*osContext);
|
||||||
|
|
||||||
|
bool ret = directSubmission.initialize(true, false);
|
||||||
|
EXPECT_TRUE(ret);
|
||||||
|
|
||||||
|
EXPECT_FALSE(csr.stopDirectSubmissionCalled);
|
||||||
|
pDevice->stopDirectSubmission();
|
||||||
|
EXPECT_TRUE(csr.stopDirectSubmissionCalled);
|
||||||
|
|
||||||
|
csr.blitterDirectSubmission.release();
|
||||||
|
}
|
||||||
|
|
||||||
HWTEST_F(DirectSubmissionTest, givenDirectSubmissionWhenMakingResourcesResidentThenCorrectContextIsUsed) {
|
HWTEST_F(DirectSubmissionTest, givenDirectSubmissionWhenMakingResourcesResidentThenCorrectContextIsUsed) {
|
||||||
auto mockMemoryOperations = std::make_unique<MockMemoryOperations>();
|
auto mockMemoryOperations = std::make_unique<MockMemoryOperations>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue