Move clean leftover memory logic to separate function

Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
Kamil Kopryk
2022-09-15 14:56:56 +00:00
committed by Compute-Runtime-Automation
parent 8eaa9d690e
commit b694a639a3
2 changed files with 21 additions and 8 deletions

View File

@@ -157,6 +157,9 @@ struct CommandQueueHw : public CommandQueueImp {
inline void dispatchTaskCountPostSyncRegular(bool isDispatchTaskCountPostSyncRequired, NEO::LinearStream &commandStream);
inline void dispatchTaskCountPostSyncByMiFlushDw(bool isDispatchTaskCountPostSyncRequired, NEO::LinearStream &commandStream);
NEO::SubmissionStatus prepareAndSubmitBatchBuffer(CommandListExecutionContext &ctx, NEO::LinearStream &innerCommandStream);
inline bool isCleanLeftoverMemoryRequired();
inline void cleanLeftoverMemory(NEO::LinearStream &outerCommandStream, NEO::LinearStream &innerCommandStream);
inline void updateTaskCountAndPostSync(bool isDispatchTaskCountPostSyncRequired);
inline ze_result_t waitForCommandQueueCompletionAndCleanHeapContainer();
inline ze_result_t handleSubmissionAndCompletionResults(NEO::SubmissionStatus submitRet, ze_result_t completionRet);

View File

@@ -1018,14 +1018,8 @@ NEO::SubmissionStatus CommandQueueHw<gfxCoreFamily>::prepareAndSubmitBatchBuffer
*(MI_BATCH_BUFFER_END *)buffer = GfxFamily::cmdInitBatchBufferEnd;
}
if (ctx.isNEODebuggerActive(this->device) || NEO::DebugManager.flags.EnableSWTags.get()) {
auto leftoverSpace = outerCommandStream.getUsed() - innerCommandStream.getUsed();
leftoverSpace -= ptrDiff(innerCommandStream.getCpuBase(), outerCommandStream.getCpuBase());
if (leftoverSpace > 0) {
auto memory = innerCommandStream.getSpace(leftoverSpace);
memset(memory, 0, leftoverSpace);
}
if (ctx.isNEODebuggerActive(this->device) || NEO::DebugManager.flags.EnableSWTags.get() || isCleanLeftoverMemoryRequired()) {
cleanLeftoverMemory(outerCommandStream, innerCommandStream);
} else if (this->alignedChildStreamPadding) {
void *paddingPtr = innerCommandStream.getSpace(this->alignedChildStreamPadding);
memset(paddingPtr, 0, this->alignedChildStreamPadding);
@@ -1037,6 +1031,22 @@ NEO::SubmissionStatus CommandQueueHw<gfxCoreFamily>::prepareAndSubmitBatchBuffer
ctx.anyCommandListWithCooperativeKernels);
}
template <GFXCORE_FAMILY gfxCoreFamily>
bool CommandQueueHw<gfxCoreFamily>::isCleanLeftoverMemoryRequired() {
return false;
}
template <GFXCORE_FAMILY gfxCoreFamily>
void CommandQueueHw<gfxCoreFamily>::cleanLeftoverMemory(NEO::LinearStream &outerCommandStream, NEO::LinearStream &innerCommandStream) {
auto leftoverSpace = outerCommandStream.getUsed() - innerCommandStream.getUsed();
leftoverSpace -= ptrDiff(innerCommandStream.getCpuBase(), outerCommandStream.getCpuBase());
if (leftoverSpace > 0) {
auto memory = innerCommandStream.getSpace(leftoverSpace);
memset(memory, 0, leftoverSpace);
}
}
template <GFXCORE_FAMILY gfxCoreFamily>
void CommandQueueHw<gfxCoreFamily>::updateTaskCountAndPostSync(bool isDispatchTaskCountPostSyncRequired) {