fix: add synchronization for updating tag and updating residency in GA

Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
Maciej Plewka
2023-11-23 20:10:41 +00:00
committed by Compute-Runtime-Automation
parent f465cf5f27
commit 1a364f5c98
3 changed files with 30 additions and 0 deletions

View File

@@ -131,6 +131,7 @@ void WddmDirectSubmission<GfxFamily, Dispatcher>::handleStopRingBuffer() {
template <typename GfxFamily, typename Dispatcher>
void WddmDirectSubmission<GfxFamily, Dispatcher>::handleSwitchRingBuffers(ResidencyContainer *allocationsForResidency) {
if (this->disableMonitorFence) {
auto lock = osContextWin->getResidencyController().acquireLock();
updateTagValueImpl();
updateMonitorFenceValueForResidencyList(allocationsForResidency);
}

View File

@@ -12,6 +12,7 @@ namespace NEO {
class MockWddmResidencyController : public WddmResidencyController {
public:
using WddmResidencyController::lastTrimFenceValue;
using WddmResidencyController::lock;
using WddmResidencyController::trimCallbackHandle;
using WddmResidencyController::trimCandidateList;
using WddmResidencyController::trimCandidatesCount;

View File

@@ -1021,4 +1021,32 @@ HWTEST_F(WddmDirectSubmissionTest, givenDirectSubmissionWhenSwitchingRingBuffers
MockWddmDirectSubmission<FamilyType, Dispatcher> wddmDirectSubmission(*device->getDefaultEngine().commandStreamReceiver);
wddmDirectSubmission.handleSwitchRingBuffers(nullptr);
EXPECT_EQ(wddmDirectSubmission.updateMonitorFenceValueForResidencyListCalled, 1u);
}
template <typename GfxFamily, typename Dispatcher>
struct MyMockWddmDirectSubmission : public MockWddmDirectSubmission<GfxFamily, Dispatcher> {
using BaseClass = MockWddmDirectSubmission<GfxFamily, Dispatcher>;
using BaseClass::MockWddmDirectSubmission;
void updateMonitorFenceValueForResidencyList(ResidencyContainer *allocationsForResidency) override {
lockInTesting = true;
while (lockInTesting)
;
BaseClass::updateMonitorFenceValueForResidencyList(allocationsForResidency);
}
std::atomic<bool> lockInTesting = false;
};
HWTEST_F(WddmDirectSubmissionTest, givenDirectSubmissionWhenSwitchingRingBuffersThenUpdateResidencyCalledWithinLock) {
using Dispatcher = RenderDispatcher<FamilyType>;
MyMockWddmDirectSubmission<FamilyType, Dispatcher> wddmDirectSubmission(*device->getDefaultEngine().commandStreamReceiver);
std::thread th([&]() {
wddmDirectSubmission.handleSwitchRingBuffers(nullptr);
});
while (!wddmDirectSubmission.lockInTesting)
;
auto tryLock = reinterpret_cast<MockWddmResidencyController *>(&(wddmDirectSubmission.osContextWin->getResidencyController()))->lock.try_lock();
EXPECT_FALSE(tryLock);
wddmDirectSubmission.lockInTesting = false;
th.join();
}