@@ -19,7 +19,7 @@ template <GFXCORE_FAMILY gfxCoreFamily>
1919void CommandListCoreFamilyImmediate<gfxCoreFamily>::checkAvailableSpace() {
2020 if (this ->commandContainer .getCommandStream ()->getAvailableSpace () < maxImmediateCommandSize) {
2121 this ->commandContainer .allocateNextCommandBuffer ();
22- cmdListBBEndOffset = 0 ;
22+ this -> cmdListCurrentStartOffset = 0 ;
2323 }
2424}
2525
@@ -61,7 +61,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::executeCommandListImm
6161 this ->commandContainer .removeDuplicatesFromResidencyContainer ();
6262
6363 auto commandStream = this ->commandContainer .getCommandStream ();
64- size_t commandStreamStart = cmdListBBEndOffset ;
64+ size_t commandStreamStart = this -> cmdListCurrentStartOffset ;
6565
6666 auto lockCSR = this ->csr ->obtainUniqueOwnership ();
6767
@@ -99,7 +99,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::executeCommandListImm
9999 this ->csr ->getInternalAllocationStorage ()->cleanAllocationList (completionStamp.taskCount , NEO::AllocationUsage::TEMPORARY_ALLOCATION);
100100 }
101101
102- cmdListBBEndOffset = commandStream->getUsed ();
102+ this -> cmdListCurrentStartOffset = commandStream->getUsed ();
103103
104104 this ->commandContainer .getResidencyContainer ().clear ();
105105
@@ -116,14 +116,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendLaunchKernel(
116116 }
117117 auto ret = CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernel (hKernel, pThreadGroupDimensions,
118118 hSignalEvent, numWaitEvents, phWaitEvents);
119- if (ret == ZE_RESULT_SUCCESS) {
120- if (this ->isFlushTaskSubmissionEnabled ) {
121- executeCommandListImmediateWithFlushTask (true );
122- } else {
123- executeCommandListImmediate (true );
124- }
125- }
126- return ret;
119+ return flushImmediate (ret, true );
127120}
128121
129122template <GFXCORE_FAMILY gfxCoreFamily>
@@ -136,14 +129,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendLaunchKernelInd
136129 }
137130 auto ret = CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelIndirect (hKernel, pDispatchArgumentsBuffer,
138131 hSignalEvent, numWaitEvents, phWaitEvents);
139- if (ret == ZE_RESULT_SUCCESS) {
140- if (this ->isFlushTaskSubmissionEnabled ) {
141- executeCommandListImmediateWithFlushTask (true );
142- } else {
143- executeCommandListImmediate (true );
144- }
145- }
146- return ret;
132+ return flushImmediate (ret, true );
147133}
148134
149135template <GFXCORE_FAMILY gfxCoreFamily>
@@ -167,13 +153,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendBarrier(
167153 checkAvailableSpace ();
168154 }
169155 ret = CommandListCoreFamily<gfxCoreFamily>::appendBarrier (hSignalEvent, numWaitEvents, phWaitEvents);
170- if (ret == ZE_RESULT_SUCCESS) {
171- if (this ->isFlushTaskSubmissionEnabled ) {
172- executeCommandListImmediateWithFlushTask (true );
173- } else {
174- executeCommandListImmediate (true );
175- }
176- }
156+ return flushImmediate (ret, true );
177157 } else {
178158 ret = CommandListCoreFamilyImmediate<gfxCoreFamily>::appendWaitOnEvents (numWaitEvents, phWaitEvents);
179159 if (!hSignalEvent) {
@@ -204,14 +184,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendMemoryCopy(
204184 }
205185 auto ret = CommandListCoreFamily<gfxCoreFamily>::appendMemoryCopy (dstptr, srcptr, size, hSignalEvent,
206186 numWaitEvents, phWaitEvents);
207- if (ret == ZE_RESULT_SUCCESS) {
208- if (this ->isFlushTaskSubmissionEnabled ) {
209- executeCommandListImmediateWithFlushTask (true );
210- } else {
211- executeCommandListImmediate (true );
212- }
213- }
214- return ret;
187+ return flushImmediate (ret, true );
215188}
216189
217190template <GFXCORE_FAMILY gfxCoreFamily>
@@ -234,14 +207,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendMemoryCopyRegio
234207 auto ret = CommandListCoreFamily<gfxCoreFamily>::appendMemoryCopyRegion (dstPtr, dstRegion, dstPitch, dstSlicePitch,
235208 srcPtr, srcRegion, srcPitch, srcSlicePitch,
236209 hSignalEvent, numWaitEvents, phWaitEvents);
237- if (ret == ZE_RESULT_SUCCESS) {
238- if (this ->isFlushTaskSubmissionEnabled ) {
239- executeCommandListImmediateWithFlushTask (true );
240- } else {
241- executeCommandListImmediate (true );
242- }
243- }
244- return ret;
210+ return flushImmediate (ret, true );
245211}
246212
247213template <GFXCORE_FAMILY gfxCoreFamily>
@@ -255,14 +221,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendMemoryFill(void
255221 checkAvailableSpace ();
256222 }
257223 auto ret = CommandListCoreFamily<gfxCoreFamily>::appendMemoryFill (ptr, pattern, patternSize, size, hSignalEvent, numWaitEvents, phWaitEvents);
258- if (ret == ZE_RESULT_SUCCESS) {
259- if (this ->isFlushTaskSubmissionEnabled ) {
260- executeCommandListImmediateWithFlushTask (true );
261- } else {
262- executeCommandListImmediate (true );
263- }
264- }
265- return ret;
224+ return flushImmediate (ret, true );
266225}
267226
268227template <GFXCORE_FAMILY gfxCoreFamily>
@@ -277,13 +236,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendSignalEvent(ze_
277236 checkAvailableSpace ();
278237 }
279238 ret = CommandListCoreFamily<gfxCoreFamily>::appendSignalEvent (hSignalEvent);
280- if (ret == ZE_RESULT_SUCCESS) {
281- if (this ->isFlushTaskSubmissionEnabled ) {
282- executeCommandListImmediateWithFlushTask (true );
283- } else {
284- executeCommandListImmediate (true );
285- }
286- }
239+ return flushImmediate (ret, true );
287240 } else {
288241 const auto &hwInfo = this ->device ->getHwInfo ();
289242 NEO::PipeControlArgs args;
@@ -309,13 +262,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendEventReset(ze_e
309262 checkAvailableSpace ();
310263 }
311264 ret = CommandListCoreFamily<gfxCoreFamily>::appendEventReset (hSignalEvent);
312- if (ret == ZE_RESULT_SUCCESS) {
313- if (this ->isFlushTaskSubmissionEnabled ) {
314- executeCommandListImmediateWithFlushTask (true );
315- } else {
316- executeCommandListImmediate (true );
317- }
318- }
265+ return flushImmediate (ret, true );
319266 } else {
320267 const auto &hwInfo = this ->device ->getHwInfo ();
321268 NEO::PipeControlArgs args;
@@ -339,14 +286,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendPageFaultCopy(N
339286 }
340287
341288 auto ret = CommandListCoreFamily<gfxCoreFamily>::appendPageFaultCopy (dstAllocation, srcAllocation, size, flushHost);
342- if (ret == ZE_RESULT_SUCCESS) {
343- if (this ->isFlushTaskSubmissionEnabled ) {
344- executeCommandListImmediateWithFlushTask (false );
345- } else {
346- executeCommandListImmediate (false );
347- }
348- }
349- return ret;
289+ return flushImmediate (ret, false );
350290}
351291
352292template <GFXCORE_FAMILY gfxCoreFamily>
@@ -365,13 +305,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendWaitOnEvents(ui
365305 checkAvailableSpace ();
366306 }
367307 ret = CommandListCoreFamily<gfxCoreFamily>::appendWaitOnEvents (numEvents, phWaitEvents);
368- if (ret == ZE_RESULT_SUCCESS) {
369- if (this ->isFlushTaskSubmissionEnabled ) {
370- executeCommandListImmediateWithFlushTask (true );
371- } else {
372- executeCommandListImmediate (true );
373- }
374- }
308+ return flushImmediate (ret, true );
375309 } else {
376310 bool dcFlushRequired = false ;
377311 const auto &hwInfo = this ->device ->getHwInfo ();
@@ -403,14 +337,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendWriteGlobalTime
403337 checkAvailableSpace ();
404338 }
405339 auto ret = CommandListCoreFamily<gfxCoreFamily>::appendWriteGlobalTimestamp (dstptr, hSignalEvent, numWaitEvents, phWaitEvents);
406- if (ret == ZE_RESULT_SUCCESS) {
407- if (this ->isFlushTaskSubmissionEnabled ) {
408- executeCommandListImmediateWithFlushTask (true );
409- } else {
410- executeCommandListImmediate (true );
411- }
412- }
413- return ret;
340+ return flushImmediate (ret, true );
414341}
415342
416343template <GFXCORE_FAMILY gfxCoreFamily>
@@ -446,14 +373,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendImageCopyRegion
446373 }
447374 auto ret = CommandListCoreFamily<gfxCoreFamily>::appendImageCopyRegion (hDstImage, hSrcImage, pDstRegion, pSrcRegion, hSignalEvent,
448375 numWaitEvents, phWaitEvents);
449- if (ret == ZE_RESULT_SUCCESS) {
450- if (this ->isFlushTaskSubmissionEnabled ) {
451- executeCommandListImmediateWithFlushTask (true );
452- } else {
453- executeCommandListImmediate (true );
454- }
455- }
456- return ret;
376+ return flushImmediate (ret, true );
457377}
458378
459379template <GFXCORE_FAMILY gfxCoreFamily>
@@ -470,14 +390,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendImageCopyFromMe
470390 }
471391 auto ret = CommandListCoreFamily<gfxCoreFamily>::appendImageCopyFromMemory (hDstImage, srcPtr, pDstRegion, hSignalEvent,
472392 numWaitEvents, phWaitEvents);
473- if (ret == ZE_RESULT_SUCCESS) {
474- if (this ->isFlushTaskSubmissionEnabled ) {
475- executeCommandListImmediateWithFlushTask (true );
476- } else {
477- executeCommandListImmediate (true );
478- }
479- }
480- return ret;
393+ return flushImmediate (ret, true );
481394}
482395
483396template <GFXCORE_FAMILY gfxCoreFamily>
@@ -494,14 +407,19 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendImageCopyToMemo
494407 }
495408 auto ret = CommandListCoreFamily<gfxCoreFamily>::appendImageCopyToMemory (dstPtr, hSrcImage, pSrcRegion, hSignalEvent,
496409 numWaitEvents, phWaitEvents);
497- if (ret == ZE_RESULT_SUCCESS) {
410+ return flushImmediate (ret, true );
411+ }
412+
413+ template <GFXCORE_FAMILY gfxCoreFamily>
414+ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::flushImmediate(ze_result_t inputRet, bool performMigration) {
415+ if (inputRet == ZE_RESULT_SUCCESS) {
498416 if (this ->isFlushTaskSubmissionEnabled ) {
499- executeCommandListImmediateWithFlushTask (true );
417+ inputRet = executeCommandListImmediateWithFlushTask (performMigration );
500418 } else {
501- executeCommandListImmediate (true );
419+ inputRet = executeCommandListImmediate (performMigration );
502420 }
503421 }
504- return ret ;
422+ return inputRet ;
505423}
506424
507425} // namespace L0
0 commit comments