Skip to content

Commit b0e055e

Browse files
Debug flag to print blit dispatch details
Change-Id: I1eb033449a49485b459249f634589e546492d99f Signed-off-by: Bartosz Dunajski <[email protected]>
1 parent 225e7f0 commit b0e055e

File tree

5 files changed

+44
-2
lines changed

5 files changed

+44
-2
lines changed

opencl/test/unit_test/mem_obj/buffer_bcs_tests.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include "opencl/test/unit_test/test_macros/test_checks_ocl.h"
2424
#include "test.h"
2525

26+
#include <cinttypes>
27+
2628
using namespace NEO;
2729

2830
struct BcsBufferTests : public ::testing::Test {
@@ -239,6 +241,38 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenBcsSupportedWhenEnqueueBufferOperationIs
239241
EXPECT_EQ(14u, bcsCsr->blitBufferCalled);
240242
}
241243

244+
HWTEST_TEMPLATED_F(BcsBufferTests, givenDebugFlagSetWhenDispatchingBlitCommandsThenPrintDispatchDetails) {
245+
DebugManager.flags.PrintBlitDispatchDetails.set(true);
246+
247+
uint32_t maxBlitWidth = static_cast<uint32_t>(BlitterConstants::maxBlitWidth);
248+
uint32_t copySize = maxBlitWidth + 5;
249+
250+
auto myHostPtr = std::make_unique<uint8_t[]>(copySize);
251+
uint64_t hostPtrAddr = castToUint64(myHostPtr.get());
252+
253+
auto bufferForBlt = clUniquePtr(Buffer::create(bcsMockContext.get(), CL_MEM_READ_WRITE, copySize, nullptr, retVal));
254+
bufferForBlt->forceDisallowCPUCopy = true;
255+
256+
uint64_t bufferGpuAddr = bufferForBlt->getGraphicsAllocation(0)->getGpuAddress();
257+
258+
testing::internal::CaptureStdout();
259+
260+
commandQueue->enqueueWriteBuffer(bufferForBlt.get(), CL_TRUE, 0, copySize, myHostPtr.get(), nullptr, 0, nullptr, nullptr);
261+
262+
std::string output = testing::internal::GetCapturedStdout();
263+
EXPECT_NE(0u, output.size());
264+
265+
char expectedStr[512] = {};
266+
snprintf(expectedStr, 512, "\nBlit dispatch with AuxTranslationDirection %u \
267+
\nBlit command. width: %u, height: %u, srcAddr: %#" SCNx64 ", dstAddr: %#" SCNx64 " \
268+
\nBlit command. width: %u, height: %u, srcAddr: %#" SCNx64 ", dstAddr: %#" SCNx64 " ",
269+
static_cast<uint32_t>(AuxTranslationDirection::None),
270+
maxBlitWidth, 1, hostPtrAddr, bufferGpuAddr,
271+
(copySize - maxBlitWidth), 1, ptrOffset(hostPtrAddr, maxBlitWidth), ptrOffset(bufferGpuAddr, maxBlitWidth));
272+
273+
EXPECT_THAT(output, testing::HasSubstr(std::string(expectedStr)));
274+
}
275+
242276
HWTEST_TEMPLATED_F(BcsBufferTests, givenBcsSupportedWhenQueueIsBlockedThenDispatchBlitWhenUnblocked) {
243277
auto bcsCsr = static_cast<UltCommandStreamReceiver<FamilyType> *>(commandQueue->getBcsCommandStreamReceiver());
244278

opencl/test/unit_test/test_files/igdrcl.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,5 @@ PauseOnGpuMode = -1
200200
PrintTagAllocationAddress = 0
201201
DoNotFlushCaches = false
202202
UseBindlessMode = -1
203-
MediaVfeStateMaxSubSlices = -1
203+
MediaVfeStateMaxSubSlices = -1
204+
PrintBlitDispatchDetails = 0

shared/source/debug_settings/debug_variables_base.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ DECLARE_DEBUG_VARIABLE(bool, PrintBOCreateDestroyResult, false, "tracks the resu
111111
DECLARE_DEBUG_VARIABLE(bool, PrintBOBindingResult, false, "tracks the result of binding and unbinding of BOs")
112112
DECLARE_DEBUG_VARIABLE(bool, PrintTagAllocationAddress, false, "Print tag allocation address for each engine")
113113
DECLARE_DEBUG_VARIABLE(bool, ProvideVerboseImplicitFlush, false, "provides verbose messages about implicit flush mechanism")
114+
DECLARE_DEBUG_VARIABLE(bool, PrintBlitDispatchDetails, false, "Print blit dispatch details")
114115

115116
/*PERFORMANCE FLAGS*/
116117
DECLARE_DEBUG_VARIABLE(bool, DisableZeroCopyForBuffers, false, "When active all buffer allocations will not share memory with CPU.")

shared/source/helpers/aux_translation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace NEO {
1313

14-
enum class AuxTranslationDirection {
14+
enum class AuxTranslationDirection : uint32_t {
1515
None,
1616
AuxToNonAux,
1717
NonAuxToAux

shared/source/helpers/blit_commands_helper_base.inl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBufferPerRow(const Bl
139139
uint64_t width = 1;
140140
uint64_t height = 1;
141141

142+
PRINT_DEBUG_STRING(DebugManager.flags.PrintBlitDispatchDetails.get(), stdout,
143+
"\nBlit dispatch with AuxTranslationDirection %u ", static_cast<uint32_t>(blitProperties.auxTranslationDirection));
144+
142145
for (uint64_t slice = 0; slice < blitProperties.copySize.z; slice++) {
143146
for (uint64_t row = 0; row < blitProperties.copySize.y; row++) {
144147
uint64_t offset = 0;
@@ -165,6 +168,9 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBufferPerRow(const Bl
165168
auto dstAddr = calculateBlitCommandDestinationBaseAddress(blitProperties, offset, row, slice);
166169
auto srcAddr = calculateBlitCommandSourceBaseAddress(blitProperties, offset, row, slice);
167170

171+
PRINT_DEBUG_STRING(DebugManager.flags.PrintBlitDispatchDetails.get(), stdout,
172+
"\nBlit command. width: %u, height: %u, srcAddr: %#llx, dstAddr: %#llx ", width, height, srcAddr, dstAddr);
173+
168174
bltCmd.setDestinationBaseAddress(dstAddr);
169175
bltCmd.setSourceBaseAddress(srcAddr);
170176

0 commit comments

Comments
 (0)