@@ -40,9 +40,7 @@ namespace OCLRT {
4040template <typename GfxFamily>
4141CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiverHw(const HardwareInfo &hwInfoIn) : hwInfo(hwInfoIn) {
4242 requiredThreadArbitrationPolicy = PreambleHelper<GfxFamily>::getDefaultThreadArbitrationPolicy ();
43- if (hwInfo.capabilityTable .kmdNotifyProperties .enableQuickKmdSleepForSporadicWaits ) {
44- lastWaitForCompletionTimestamp = std::chrono::high_resolution_clock::now ();
45- }
43+ resetKmdNotifyHelper (new KmdNotifyHelper (&(hwInfoIn.capabilityTable .kmdNotifyProperties )));
4644}
4745
4846template <typename GfxFamily>
@@ -568,22 +566,19 @@ inline void CommandStreamReceiverHw<GfxFamily>::emitNoop(LinearStream &commandSt
568566
569567template <typename GfxFamily>
570568inline void CommandStreamReceiverHw<GfxFamily>::waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep) {
571- const auto &kmdNotifyProperties = this ->hwInfo .capabilityTable .kmdNotifyProperties ;
572-
573- int64_t waitTimeout = kmdNotifyProperties.pickTimeoutValue (lastWaitForCompletionTimestamp, useQuickKmdSleep, *getTagAddress (), taskCountToWait);
569+ int64_t waitTimeout = 0 ;
570+ bool enableTimeout = kmdNotifyHelper->obtainTimeoutParams (waitTimeout, useQuickKmdSleep, *getTagAddress (), taskCountToWait, flushStampToWait);
574571
575- auto status = waitForCompletionWithTimeout (kmdNotifyProperties.timeoutEnabled (flushStampToWait),
576- waitTimeout,
577- taskCountToWait);
572+ auto status = waitForCompletionWithTimeout (enableTimeout, waitTimeout, taskCountToWait);
578573 if (!status) {
579574 waitForFlushStamp (flushStampToWait);
580575 // now call blocking wait, this is to ensure that task count is reached
581576 waitForCompletionWithTimeout (false , 0 , taskCountToWait);
582577 }
583578 UNRECOVERABLE_IF (*getTagAddress () < taskCountToWait);
584579
585- if (kmdNotifyProperties. enableQuickKmdSleepForSporadicWaits ) {
586- updateLastWaitForCompletionTimestamp ();
580+ if (kmdNotifyHelper-> quickKmdSleepForSporadicWaitsEnabled () ) {
581+ kmdNotifyHelper-> updateLastWaitForCompletionTimestamp ();
587582 }
588583}
589584
@@ -636,11 +631,6 @@ size_t CommandStreamReceiverHw<GfxFamily>::getCmdSizeForMediaSampler(bool mediaS
636631 return 0 ;
637632}
638633
639- template <typename GfxFamily>
640- void CommandStreamReceiverHw<GfxFamily>::updateLastWaitForCompletionTimestamp() {
641- lastWaitForCompletionTimestamp = std::chrono::high_resolution_clock::now ();
642- }
643-
644634template <typename GfxFamily>
645635void CommandStreamReceiverHw<GfxFamily>::collectStateBaseAddresPatchInfo(
646636 uint64_t baseAddress,
@@ -666,4 +656,13 @@ void CommandStreamReceiverHw<GfxFamily>::collectStateBaseAddresPatchInfo(
666656 setPatchInfoData (instructionPatchInfo);
667657}
668658
659+ template <typename GfxFamily>
660+ void CommandStreamReceiverHw<GfxFamily>::resetKmdNotifyHelper(KmdNotifyHelper *newHelper) {
661+ kmdNotifyHelper.reset (newHelper);
662+ kmdNotifyHelper->updateAcLineStatus ();
663+ if (kmdNotifyHelper->quickKmdSleepForSporadicWaitsEnabled ()) {
664+ kmdNotifyHelper->updateLastWaitForCompletionTimestamp ();
665+ }
666+ }
667+
669668} // namespace OCLRT
0 commit comments