mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +08:00
KM DAF AubCapture to recapture fill pattern allocations
The commit introduces a recapture of fill pattern allocations on every submit. Change-Id: I634af075348dbc59c7809f58b8495326cab804e1
This commit is contained in:
@@ -53,6 +53,8 @@ cl_int CommandQueueHw<GfxFamily>::enqueueFillBuffer(
|
||||
patternAllocation = memoryManager->allocateGraphicsMemory(alignUp(patternSize, MemoryConstants::cacheLineSize), MemoryConstants::preferredAlignment);
|
||||
}
|
||||
|
||||
patternAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_FILL_PATTERN);
|
||||
|
||||
if (patternSize == 1) {
|
||||
int patternInt = (uint32_t)((*(uint8_t *)pattern << 24) | (*(uint8_t *)pattern << 16) | (*(uint8_t *)pattern << 8) | *(uint8_t *)pattern);
|
||||
memcpy_s(patternAllocation->getUnderlyingBuffer(), sizeof(int), &patternInt, sizeof(int));
|
||||
|
||||
@@ -247,6 +247,8 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemFill(void *svmPtr,
|
||||
patternAllocation = memoryManager->allocateGraphicsMemory(patternSize, MemoryConstants::preferredAlignment);
|
||||
}
|
||||
|
||||
patternAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_FILL_PATTERN);
|
||||
|
||||
if (patternSize == 1) {
|
||||
int patternInt = (uint32_t)((*(uint8_t *)pattern << 24) | (*(uint8_t *)pattern << 16) | (*(uint8_t *)pattern << 8) | *(uint8_t *)pattern);
|
||||
memcpy_s(patternAllocation->getUnderlyingBuffer(), sizeof(int), &patternInt, sizeof(int));
|
||||
|
||||
@@ -58,6 +58,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
||||
ALLOCATION_TYPE_IMAGE,
|
||||
ALLOCATION_TYPE_TAG_BUFFER,
|
||||
ALLOCATION_TYPE_LINEAR_STREAM,
|
||||
ALLOCATION_TYPE_FILL_PATTERN,
|
||||
ALLOCATION_TYPE_NON_AUB_WRITABLE = 0x40000000,
|
||||
ALLOCATION_TYPE_WRITABLE = 0x80000000
|
||||
};
|
||||
|
||||
@@ -219,8 +219,10 @@ void WddmCommandStreamReceiver<GfxFamily>::kmDafLockAllocations(ResidencyContain
|
||||
auto &residencyAllocations = allocationsForResidency ? *allocationsForResidency : getMemoryManager()->getResidencyAllocations();
|
||||
|
||||
for (uint32_t i = 0; i < residencyAllocations.size(); i++) {
|
||||
if (GraphicsAllocation::ALLOCATION_TYPE_LINEAR_STREAM == residencyAllocations[i]->getAllocationType()) {
|
||||
wddm->kmDafLock(static_cast<WddmAllocation *>(residencyAllocations[i]));
|
||||
auto graphicsAllocation = residencyAllocations[i];
|
||||
if ((GraphicsAllocation::ALLOCATION_TYPE_LINEAR_STREAM == graphicsAllocation->getAllocationType()) ||
|
||||
(GraphicsAllocation::ALLOCATION_TYPE_FILL_PATTERN == graphicsAllocation->getAllocationType())) {
|
||||
wddm->kmDafLock(static_cast<WddmAllocation *>(graphicsAllocation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,3 +543,33 @@ HWTEST_F(EnqueueFillBufferCmdTests, patternOfSizeTwoBytesShouldGetPreparedForMid
|
||||
|
||||
EXPECT_EQ(0, memcmp(allocation->getUnderlyingBuffer(), output, size));
|
||||
}
|
||||
|
||||
HWTEST_F(EnqueueFillBufferCmdTests, givenEnqueueFillBufferWhenPatternAllocationIsObtainedThenItsTypeShouldBeSetToFillPattern) {
|
||||
MemoryManager *mmgr = pCmdQ->getDevice().getMemoryManager();
|
||||
ASSERT_TRUE(mmgr->allocationsForReuse.peekIsEmpty());
|
||||
|
||||
auto dstBuffer = std::unique_ptr<Buffer>(BufferHelper<>::create());
|
||||
const uint8_t pattern[1] = {0x55};
|
||||
const size_t patternSize = sizeof(pattern);
|
||||
const size_t offset = 0;
|
||||
const size_t size = patternSize;
|
||||
|
||||
auto retVal = clEnqueueFillBuffer(
|
||||
pCmdQ,
|
||||
dstBuffer.get(),
|
||||
pattern,
|
||||
patternSize,
|
||||
offset,
|
||||
size,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
ASSERT_FALSE(mmgr->allocationsForReuse.peekIsEmpty());
|
||||
|
||||
GraphicsAllocation *patternAllocation = mmgr->allocationsForReuse.peekHead();
|
||||
ASSERT_NE(nullptr, patternAllocation);
|
||||
|
||||
EXPECT_EQ(GraphicsAllocation::ALLOCATION_TYPE_FILL_PATTERN, patternAllocation->getAllocationType());
|
||||
}
|
||||
|
||||
@@ -445,6 +445,31 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemFillDoubleToReuseAllocation_Success) {
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST_F(EnqueueSvmTest, givenEnqueueSVMMemFillWhenPatternAllocationIsObtainedThenItsTypeShouldBeSetToFillPattern) {
|
||||
MemoryManager *mmgr = pCmdQ->getDevice().getMemoryManager();
|
||||
ASSERT_TRUE(mmgr->allocationsForReuse.peekIsEmpty());
|
||||
|
||||
const float pattern[1] = {1.2345f};
|
||||
const size_t patternSize = sizeof(pattern);
|
||||
const size_t size = patternSize;
|
||||
retVal = this->pCmdQ->enqueueSVMMemFill(
|
||||
ptrSVM,
|
||||
pattern,
|
||||
patternSize,
|
||||
size,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
ASSERT_FALSE(mmgr->allocationsForReuse.peekIsEmpty());
|
||||
|
||||
GraphicsAllocation *patternAllocation = mmgr->allocationsForReuse.peekHead();
|
||||
ASSERT_NE(nullptr, patternAllocation);
|
||||
|
||||
EXPECT_EQ(GraphicsAllocation::ALLOCATION_TYPE_FILL_PATTERN, patternAllocation->getAllocationType());
|
||||
}
|
||||
|
||||
TEST_F(EnqueueSvmTest, enqueueTaskWithKernelExecInfo_success) {
|
||||
GraphicsAllocation *pSvmAlloc = context->getSVMAllocsManager()->getSVMAlloc(ptrSVM);
|
||||
EXPECT_NE(nullptr, ptrSVM);
|
||||
|
||||
@@ -389,6 +389,28 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
|
||||
memManager->freeGraphicsMemory(linearStreamAllocation);
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllocationsForResidencyThenFillPatternAllocationsShouldBeKmDafLocked) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
|
||||
auto fillPatternAllocation = memManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
|
||||
ASSERT_NE(nullptr, fillPatternAllocation);
|
||||
fillPatternAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_FILL_PATTERN);
|
||||
ResidencyContainer allocationsForResidency = {fillPatternAllocation};
|
||||
|
||||
wddm->setKmDafEnabled(true);
|
||||
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, &allocationsForResidency);
|
||||
|
||||
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
|
||||
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
|
||||
EXPECT_EQ(fillPatternAllocation, wddm->kmDafLockResult.lockedAllocations[0]);
|
||||
|
||||
memManager->freeGraphicsMemory(commandBuffer);
|
||||
memManager->freeGraphicsMemory(fillPatternAllocation);
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllocationsForResidencyThenNonLinearStreamAllocationShouldNotBeKmDafLocked) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
|
||||
Reference in New Issue
Block a user