Move MI_FLUSH_DW programming to helper method

Change-Id: Ic459b531df265b6f7f92bbaaf80e4514364627f4
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
Related-To: NEO-3020
This commit is contained in:
Dunajski, Bartosz 2019-06-11 08:31:38 +02:00 committed by sys_ocldev
parent 226500a6ac
commit 825e381ae0
5 changed files with 34 additions and 5 deletions

View File

@ -742,11 +742,7 @@ void CommandStreamReceiverHw<GfxFamily>::blitBuffer(Buffer &dstBuffer, Buffer &s
BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBuffer(dstBuffer, srcBuffer, commandStream, dstOffset, srcOffset, copySize);
auto miFlushDwCmd = reinterpret_cast<MI_FLUSH_DW *>(commandStream.getSpace(sizeof(MI_FLUSH_DW)));
*miFlushDwCmd = GfxFamily::cmdInitMiFlushDw;
miFlushDwCmd->setPostSyncOperation(MI_FLUSH_DW::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA_QWORD);
miFlushDwCmd->setDestinationAddress(tagAllocation->getGpuAddress());
miFlushDwCmd->setImmediateData(newTaskCount);
KernelCommandsHelper<GfxFamily>::programMiFlushDw(commandStream, tagAllocation->getGpuAddress(), newTaskCount);
auto batchBufferEnd = reinterpret_cast<MI_BATCH_BUFFER_END *>(commandStream.getSpace(sizeof(MI_BATCH_BUFFER_END)));
*batchBufferEnd = GfxFamily::cmdInitBatchBufferEnd;

View File

@ -200,6 +200,8 @@ struct KernelCommandsHelper : public PerThreadDataHelper {
uint32_t &interfaceDescriptorIndex);
static void programMiSemaphoreWait(LinearStream &commandStream, uint64_t compareAddress, uint32_t compareData);
static void programMiFlushDw(LinearStream &commandStream, uint64_t immediateDataGpuAddress, uint64_t immediateData);
static void appendMiFlushDw(typename GfxFamily::MI_FLUSH_DW *miFlushDwCmd);
static MI_ATOMIC *programMiAtomic(LinearStream &commandStream, uint64_t writeAddress, typename MI_ATOMIC::ATOMIC_OPCODES opcode, typename MI_ATOMIC::DATA_SIZE dataSize);
static void programCacheFlushAfterWalkerCommand(LinearStream *commandStream, const CommandQueue &commandQueue, const Kernel *kernel, uint64_t postSyncAddress, uint64_t postSyncData);

View File

@ -421,4 +421,15 @@ bool KernelCommandsHelper<GfxFamily>::kernelUsesLocalIds(const Kernel &kernel) {
kernel.getKernelInfo().patchInfo.threadPayload->LocalIDZPresent);
}
template <typename GfxFamily>
void KernelCommandsHelper<GfxFamily>::programMiFlushDw(LinearStream &commandStream, uint64_t immediateDataGpuAddress, uint64_t immediateData) {
using MI_FLUSH_DW = typename GfxFamily::MI_FLUSH_DW;
auto miFlushDwCmd = commandStream.getSpaceForCmd<MI_FLUSH_DW>();
*miFlushDwCmd = GfxFamily::cmdInitMiFlushDw;
miFlushDwCmd->setPostSyncOperation(MI_FLUSH_DW::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA_QWORD);
miFlushDwCmd->setDestinationAddress(immediateDataGpuAddress);
miFlushDwCmd->setImmediateData(immediateData);
appendMiFlushDw(miFlushDwCmd);
}
} // namespace NEO

View File

@ -170,4 +170,7 @@ void KernelCommandsHelper<GfxFamily>::programCacheFlushAfterWalkerCommand(Linear
pipeControl->setCommandStreamerStallEnable(true);
pipeControl->setDcFlushEnable(true);
}
template <typename GfxFamily>
void KernelCommandsHelper<GfxFamily>::appendMiFlushDw(typename GfxFamily::MI_FLUSH_DW *miFlushDwCmd) {}
} // namespace NEO

View File

@ -1359,6 +1359,23 @@ TEST_F(KernelCommandsTest, givenCacheFlushAfterWalkerEnabledWhenPlatformNotSuppo
EXPECT_EQ(0U, allocationsForCacheFlush.size());
}
HWTEST_F(KernelCommandsTest, givenImmDataWriteWhenProgrammingMiFlushDwThenSetAllRequiredFields) {
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
uint8_t buffer[2 * sizeof(MI_FLUSH_DW)] = {};
LinearStream linearStream(buffer, sizeof(buffer));
uint64_t gpuAddress = 0x1230000;
uint64_t immData = 456;
KernelCommandsHelper<FamilyType>::programMiFlushDw(linearStream, gpuAddress, immData);
auto miFlushDwCmd = reinterpret_cast<MI_FLUSH_DW *>(buffer);
EXPECT_EQ(sizeof(MI_FLUSH_DW), linearStream.getUsed());
EXPECT_EQ(MI_FLUSH_DW::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA_QWORD, miFlushDwCmd->getPostSyncOperation());
EXPECT_EQ(gpuAddress, miFlushDwCmd->getDestinationAddress());
EXPECT_EQ(immData, miFlushDwCmd->getImmediateData());
}
using KernelCacheFlushTests = Test<HelloWorldFixture<HelloWorldFixtureFactory>>;
HWTEST_F(KernelCacheFlushTests, givenLocallyUncachedBufferWhenGettingAllocationsForFlushThenEmptyVectorIsReturned) {