Skip to content

Commit cc6a94b

Browse files
Fixed TBX with AUB dump mode without AubStream
Related-To: NEO-3150 Change-Id: I9ee7fc3c44f3021c61db7c27c01522cbe7d7445d Signed-off-by: Milczarek, Slawomir <[email protected]>
1 parent 0c9995d commit cc6a94b

File tree

7 files changed

+35
-6
lines changed

7 files changed

+35
-6
lines changed

runtime/command_queue/cpu_data_transfer_handler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferPropertie
125125
if (!unmapInfo.readOnly) {
126126
auto graphicsAllocation = transferProperties.memObj->getGraphicsAllocation();
127127
graphicsAllocation->setAubWritable(true);
128+
graphicsAllocation->setTbxWritable(true);
128129
}
129130
break;
130131
case CL_COMMAND_READ_BUFFER:

runtime/command_stream/aub_command_stream_receiver_hw_base.inl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,10 @@ void AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(uint64_t gpuAddress, voi
614614

615615
template <typename GfxFamily>
616616
bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxAllocation) {
617+
if (!gfxAllocation.isAubWritable()) {
618+
return false;
619+
}
620+
617621
bool ownsLock = !gfxAllocation.isLocked();
618622

619623
uint64_t gpuAddress;

runtime/command_stream/command_stream_receiver_simulated_common_hw.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ bool CommandStreamReceiverSimulatedCommonHw<GfxFamily>::getParametersForWriteMem
102102
size = gmm->gmmResourceInfo->getSizeAllocation();
103103
}
104104

105-
if ((size == 0) || !graphicsAllocation.isAubWritable())
105+
if (size == 0)
106106
return false;
107107

108108
if (cpuAddress == nullptr) {

runtime/command_stream/tbx_command_stream_receiver_hw.inl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ void TbxCommandStreamReceiverHw<GfxFamily>::writeMemory(uint64_t gpuAddress, voi
365365

366366
template <typename GfxFamily>
367367
bool TbxCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxAllocation) {
368+
if (!gfxAllocation.isTbxWritable()) {
369+
return false;
370+
}
371+
368372
uint64_t gpuAddress;
369373
void *cpuAddress;
370374
size_t size;
@@ -379,7 +383,7 @@ bool TbxCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
379383
}
380384

381385
if (AubHelper::isOneTimeAubWritableAllocationType(gfxAllocation.getAllocationType())) {
382-
gfxAllocation.setAubWritable(false);
386+
gfxAllocation.setTbxWritable(false);
383387
}
384388

385389
return true;
@@ -411,7 +415,7 @@ template <typename GfxFamily>
411415
void TbxCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer &allocationsForResidency) {
412416
for (auto &gfxAllocation : allocationsForResidency) {
413417
if (!writeMemory(*gfxAllocation)) {
414-
DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) || !gfxAllocation->isAubWritable()));
418+
DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) || !gfxAllocation->isTbxWritable()));
415419
}
416420
gfxAllocation->updateResidencyTaskCount(this->taskCount + 1, this->osContext->getContextId());
417421
}

runtime/memory_manager/graphics_allocation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
133133

134134
void setAubWritable(bool writable) { aubInfo.aubWritable = writable; }
135135
bool isAubWritable() const { return aubInfo.aubWritable; }
136+
void setTbxWritable(bool writable) { aubInfo.tbxWritable = writable; }
137+
bool isTbxWritable() const { return aubInfo.tbxWritable; }
136138
void setAllocDumpable(bool dumpable) { aubInfo.allocDumpable = dumpable; }
137139
bool isAllocDumpable() const { return aubInfo.allocDumpable; }
138140
bool isMemObjectsAllocationWithWritableFlags() const { return aubInfo.memObjectsAllocationWithWritableFlags; }
@@ -210,6 +212,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
210212
};
211213
struct AubInfo {
212214
bool aubWritable = true;
215+
bool tbxWritable = true;
213216
bool allocDumpable = false;
214217
bool memObjectsAllocationWithWritableFlags = false;
215218
};

unit_tests/command_queue/enqueue_unmap_memobject_tests.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ TEST_F(EnqueueUnmapMemObjTest, UnmapMemObjWaitEvent) {
190190
clReleaseEvent(retEvent);
191191
}
192192

193-
HWTEST_F(EnqueueUnmapMemObjTest, givenEnqueueUnmapMemObjectWhenNonAubWritableBufferObjectMappedToHostPtrForWritingThenItShouldBeResetToAubWritable) {
193+
HWTEST_F(EnqueueUnmapMemObjTest, givenEnqueueUnmapMemObjectWhenNonAubWritableBufferObjectMappedToHostPtrForWritingThenItShouldBeResetToAubAndTbxWritable) {
194194
auto buffer = std::unique_ptr<Buffer>(BufferHelper<>::create());
195195
ASSERT_NE(nullptr, buffer);
196196
buffer->getGraphicsAllocation()->setAubWritable(false);
197+
buffer->getGraphicsAllocation()->setTbxWritable(false);
197198

198199
auto mappedForWritingPtr = pCmdQ->enqueueMapBuffer(buffer.get(), CL_TRUE, CL_MAP_WRITE, 0, 8, 0, nullptr, nullptr, retVal);
199200
ASSERT_NE(nullptr, mappedForWritingPtr);
@@ -207,4 +208,5 @@ HWTEST_F(EnqueueUnmapMemObjTest, givenEnqueueUnmapMemObjectWhenNonAubWritableBuf
207208
ASSERT_EQ(CL_SUCCESS, retVal);
208209

209210
EXPECT_TRUE(buffer->getGraphicsAllocation()->isAubWritable());
211+
EXPECT_TRUE(buffer->getGraphicsAllocation()->isTbxWritable());
210212
}

unit_tests/command_stream/tbx_command_stream_tests.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,24 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenWriteMemoryIsCa
217217
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER});
218218
ASSERT_NE(nullptr, graphicsAllocation);
219219

220-
EXPECT_TRUE(graphicsAllocation->isAubWritable());
220+
EXPECT_TRUE(graphicsAllocation->isTbxWritable());
221221
EXPECT_TRUE(tbxCsr->writeMemory(*graphicsAllocation));
222-
EXPECT_FALSE(graphicsAllocation->isAubWritable());
222+
EXPECT_FALSE(graphicsAllocation->isTbxWritable());
223+
224+
memoryManager->freeGraphicsMemory(graphicsAllocation);
225+
}
226+
227+
HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenWriteMemoryIsCalledWithGraphicsAllocationThatIsOnlyOneTimeWriteableButAlreadyWrittenThenGraphicsAllocationIsNotUpdated) {
228+
TbxCommandStreamReceiverHw<FamilyType> *tbxCsr = (TbxCommandStreamReceiverHw<FamilyType> *)pCommandStreamReceiver;
229+
TbxMemoryManager *memoryManager = tbxCsr->getMemoryManager();
230+
ASSERT_NE(nullptr, memoryManager);
231+
232+
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER});
233+
ASSERT_NE(nullptr, graphicsAllocation);
234+
235+
graphicsAllocation->setTbxWritable(false);
236+
EXPECT_FALSE(tbxCsr->writeMemory(*graphicsAllocation));
237+
EXPECT_FALSE(graphicsAllocation->isTbxWritable());
223238

224239
memoryManager->freeGraphicsMemory(graphicsAllocation);
225240
}

0 commit comments

Comments
 (0)