Skip to content

Commit 910871a

Browse files
add multi-tile support for completion diagnostic
Related-To: NEO-6871 Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
1 parent db178a9 commit 910871a

File tree

4 files changed

+71
-10
lines changed

4 files changed

+71
-10
lines changed

shared/source/command_stream/command_stream_receiver.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ void CommandStreamReceiver::cleanupResources() {
323323
}
324324

325325
WaitStatus CommandStreamReceiver::waitForCompletionWithTimeout(const WaitParams &params, uint32_t taskCountToWait) {
326+
bool printWaitForCompletion = DebugManager.flags.LogWaitingForCompletion.get();
327+
if (printWaitForCompletion) {
328+
printTagAddressContent(taskCountToWait, params.waitTimeout, true);
329+
}
330+
326331
uint32_t latestSentTaskCount = this->latestFlushedTaskCount;
327332
if (latestSentTaskCount < taskCountToWait) {
328333
if (!this->flushBatchedSubmissions()) {
@@ -331,7 +336,11 @@ WaitStatus CommandStreamReceiver::waitForCompletionWithTimeout(const WaitParams
331336
}
332337
}
333338

334-
return baseWaitFunction(getTagAddress(), params, taskCountToWait);
339+
auto retCode = baseWaitFunction(getTagAddress(), params, taskCountToWait);
340+
if (printWaitForCompletion) {
341+
printTagAddressContent(taskCountToWait, params.waitTimeout, false);
342+
}
343+
return retCode;
335344
}
336345

337346
WaitStatus CommandStreamReceiver::baseWaitFunction(volatile uint32_t *pollAddress, const WaitParams &params, uint32_t taskCountToWait) {
@@ -865,4 +874,21 @@ bool CommandStreamReceiver::createPerDssBackedBuffer(Device &device) {
865874
return perDssBackedBuffer != nullptr;
866875
}
867876

877+
void CommandStreamReceiver::printTagAddressContent(uint32_t taskCountToWait, int64_t waitTimeout, bool start) {
878+
auto postSyncAddress = getTagAddress();
879+
if (start) {
880+
PRINT_DEBUG_STRING(true, stdout,
881+
"\nWaiting for task count %u at location %p with timeout %llx. Current value:",
882+
taskCountToWait, postSyncAddress, waitTimeout);
883+
} else {
884+
PRINT_DEBUG_STRING(true, stdout,
885+
"%s", "\nWaiting completed. Current value:");
886+
}
887+
for (uint32_t i = 0; i < activePartitions; i++) {
888+
PRINT_DEBUG_STRING(true, stdout, " %u", *postSyncAddress);
889+
postSyncAddress = ptrOffset(postSyncAddress, this->postSyncWriteOffset);
890+
}
891+
PRINT_DEBUG_STRING(true, stdout, "%s", "\n");
892+
}
893+
868894
} // namespace NEO

shared/source/command_stream/command_stream_receiver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ class CommandStreamReceiver {
342342
void checkForNewResources(uint32_t submittedTaskCount, uint32_t allocationTaskCount, GraphicsAllocation &gfxAllocation);
343343
bool checkImplicitFlushForGpuIdle();
344344
void downloadTagAllocation(uint32_t taskCountToWait);
345+
void printTagAddressContent(uint32_t taskCountToWait, int64_t waitTimeout, bool start);
345346
MOCKABLE_VIRTUAL std::unique_lock<MutexType> obtainHostPtrSurfaceCreationLock();
346347

347348
std::unique_ptr<FlushStampTracker> flushStamp;

shared/source/command_stream/command_stream_receiver_hw_base.inl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -871,10 +871,6 @@ inline WaitStatus CommandStreamReceiverHw<GfxFamily>::waitForTaskCountWithKmdNot
871871
const auto params = kmdNotifyHelper->obtainTimeoutParams(useQuickKmdSleep, *getTagAddress(), taskCountToWait, flushStampToWait, throttle, this->isKmdWaitModeActive(),
872872
this->isAnyDirectSubmissionEnabled());
873873

874-
PRINT_DEBUG_STRING(DebugManager.flags.LogWaitingForCompletion.get(), stdout,
875-
"\nWaiting for task count %u at location %p. Current value: %u\n",
876-
taskCountToWait, getTagAddress(), *getTagAddress());
877-
878874
auto status = waitForCompletionWithTimeout(params, taskCountToWait);
879875
if (status == WaitStatus::NotReady) {
880876
waitForFlushStamp(flushStampToWait);
@@ -887,15 +883,13 @@ inline WaitStatus CommandStreamReceiverHw<GfxFamily>::waitForTaskCountWithKmdNot
887883
return status;
888884
}
889885

890-
UNRECOVERABLE_IF(*getTagAddress() < taskCountToWait);
886+
for (uint32_t i = 0; i < this->activePartitions; i++) {
887+
UNRECOVERABLE_IF(*(ptrOffset(getTagAddress(), (i * this->postSyncWriteOffset))) < taskCountToWait);
888+
}
891889

892890
if (kmdNotifyHelper->quickKmdSleepForSporadicWaitsEnabled()) {
893891
kmdNotifyHelper->updateLastWaitForCompletionTimestamp();
894892
}
895-
896-
PRINT_DEBUG_STRING(DebugManager.flags.LogWaitingForCompletion.get(), stdout,
897-
"\nWaiting completed. Current value: %u\n", *getTagAddress());
898-
899893
return WaitStatus::Ready;
900894
}
901895

shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,3 +2001,43 @@ TEST(CreateWorkPartitionAllocationTest, givenEnabledBlitterWhenInitializingWorkP
20012001
EXPECT_TRUE(retVal);
20022002
EXPECT_EQ(0u, memoryManager->copyMemoryToAllocationBanksCalled);
20032003
}
2004+
2005+
HWTEST_F(CommandStreamReceiverTest, givenMultipleActivePartitionsWhenWaitLogIsEnabledThenPrintTagValueForAllPartitions) {
2006+
DebugManagerStateRestore restorer;
2007+
DebugManager.flags.LogWaitingForCompletion.set(true);
2008+
2009+
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
2010+
csr.activePartitions = 2;
2011+
2012+
volatile uint32_t *tagAddress = csr.tagAddress;
2013+
constexpr uint32_t tagValue = 2;
2014+
*tagAddress = tagValue;
2015+
tagAddress = ptrOffset(tagAddress, csr.postSyncWriteOffset);
2016+
*tagAddress = tagValue;
2017+
2018+
WaitParams waitParams;
2019+
waitParams.waitTimeout = std::numeric_limits<int64_t>::max();
2020+
constexpr uint32_t taskCount = 1;
2021+
2022+
testing::internal::CaptureStdout();
2023+
2024+
WaitStatus status = csr.waitForCompletionWithTimeout(waitParams, taskCount);
2025+
EXPECT_EQ(WaitStatus::Ready, status);
2026+
2027+
std::string output = testing::internal::GetCapturedStdout();
2028+
2029+
std::stringstream expectedOutput;
2030+
2031+
expectedOutput << std::endl
2032+
<< "Waiting for task count " << taskCount
2033+
<< " at location " << const_cast<uint32_t *>(csr.tagAddress)
2034+
<< " with timeout " << std::hex << waitParams.waitTimeout
2035+
<< ". Current value: " << std::dec << tagValue
2036+
<< " " << tagValue
2037+
<< std::endl
2038+
<< std::endl
2039+
<< "Waiting completed. Current value: " << tagValue
2040+
<< " " << tagValue << std::endl;
2041+
2042+
EXPECT_STREQ(expectedOutput.str().c_str(), output.c_str());
2043+
}

0 commit comments

Comments
 (0)