@@ -126,6 +126,7 @@ void *DebugSessionWindows::asyncThreadFunction(void *arg) {
126126
127127 while (self->asyncThread .threadActive ) {
128128 self->readAndHandleEvent (100 );
129+ self->pollFifo ();
129130 self->generateEventsAndResumeStoppedThreads ();
130131 self->sendInterrupts ();
131132 }
@@ -195,6 +196,8 @@ ze_result_t DebugSessionWindows::readAndHandleEvent(uint64_t timeoutMs) {
195196 return handleDeviceCreateDestroyEvent (eventParamsBuffer.eventParamsBuffer .DeviceCreateDestroyEventParams );
196197 case DBGUMD_READ_EVENT_CREATE_DEBUG_DATA:
197198 return handleCreateDebugDataEvent (eventParamsBuffer.eventParamsBuffer .ReadCreateDebugDataParams );
199+ case DBGUMD_READ_EVENT_SYNC_HOST:
200+ return handleSyncHostEvent (eventParamsBuffer.eventParamsBuffer .SyncHostDataParams );
198201 default :
199202 break ;
200203 }
@@ -242,57 +245,15 @@ ze_result_t DebugSessionWindows::handleEuAttentionBitsEvent(DBGUMD_READ_EVENT_EU
242245 euAttentionBitsParams.hContextHandle , euAttentionBitsParams.LRCA ,
243246 euAttentionBitsParams.BitMaskSizeInBytes , &euAttentionBitsParams.BitmaskArrayPtr );
244247
245- auto hwInfo = connectedDevice->getHwInfo ();
246- auto &l0GfxCoreHelper = connectedDevice->getNEODevice ()->getRootDeviceEnvironment ().getHelper <L0GfxCoreHelper>();
247-
248- auto threadsWithAttention = l0GfxCoreHelper.getThreadsFromAttentionBitmask (hwInfo, 0u ,
249- reinterpret_cast <uint8_t *>(&euAttentionBitsParams.BitmaskArrayPtr ),
250- euAttentionBitsParams.BitMaskSizeInBytes );
251-
252- printBitmask (reinterpret_cast <uint8_t *>(&euAttentionBitsParams.BitmaskArrayPtr ), euAttentionBitsParams.BitMaskSizeInBytes );
253-
254- PRINT_DEBUGGER_THREAD_LOG (" ATTENTION received for thread count = %d\n " , (int )threadsWithAttention.size ());
255-
256- if (threadsWithAttention.size () > 0 ) {
257-
258- uint64_t memoryHandle = DebugSessionWindows::invalidHandle;
259- {
260- if (allContexts.empty ()) {
261- return ZE_RESULT_ERROR_UNINITIALIZED;
262- }
263- memoryHandle = *allContexts.begin ();
264- }
265-
266- auto gpuVa = getContextStateSaveAreaGpuVa (memoryHandle);
267- auto stateSaveAreaSize = getContextStateSaveAreaSize (memoryHandle);
268- auto stateSaveReadResult = ZE_RESULT_ERROR_UNKNOWN;
269-
270- std::unique_lock<std::mutex> lock (threadStateMutex);
271-
272- if (gpuVa != 0 && stateSaveAreaSize != 0 ) {
273- std::vector<EuThread::ThreadId> newThreads;
274- getNotStoppedThreads (threadsWithAttention, newThreads);
275- if (newThreads.size () > 0 ) {
276- allocateStateSaveAreaMemory (stateSaveAreaSize);
277- stateSaveReadResult = readGpuMemory (memoryHandle, stateSaveAreaMemory.data (), stateSaveAreaSize, gpuVa);
278- }
279- } else {
280- PRINT_DEBUGGER_ERROR_LOG (" Context state save area bind info invalid\n " , " " );
281- DEBUG_BREAK_IF (true );
282- }
283-
284- if (stateSaveReadResult == ZE_RESULT_SUCCESS) {
248+ std::vector<EuThread::ThreadId> threadsWithAttention;
249+ newAttentionRaised ();
250+ AttentionEventFields attentionEventFields;
251+ attentionEventFields.bitmask = reinterpret_cast <uint8_t *>(&euAttentionBitsParams.BitmaskArrayPtr );
252+ attentionEventFields.bitmaskSize = euAttentionBitsParams.BitMaskSizeInBytes ;
253+ attentionEventFields.contextHandle = euAttentionBitsParams.hContextHandle ;
254+ attentionEventFields.lrcHandle = euAttentionBitsParams.LRCA ;
285255
286- for (auto &threadId : threadsWithAttention) {
287- PRINT_DEBUGGER_THREAD_LOG (" ATTENTION event for thread: %s\n " , EuThread::toString (threadId).c_str ());
288- addThreadToNewlyStoppedFromRaisedAttention (threadId, memoryHandle, stateSaveAreaMemory.data ());
289- }
290- }
291- }
292-
293- checkTriggerEventsForAttention ();
294-
295- return ZE_RESULT_SUCCESS;
256+ return updateStoppedThreadsAndCheckTriggerEvents (attentionEventFields, 0 , threadsWithAttention);
296257}
297258
298259ze_result_t DebugSessionWindows::handleAllocationDataEvent (uint32_t seqNo, DBGUMD_READ_EVENT_READ_ALLOCATION_DATA_PARAMS &allocationDataParams) {
@@ -395,6 +356,84 @@ ze_result_t DebugSessionWindows::handleCreateDebugDataEvent(DBGUMD_READ_EVENT_CR
395356 return ZE_RESULT_SUCCESS;
396357}
397358
359+ ze_result_t DebugSessionWindows::handleSyncHostEvent (DBGUMD_READ_EVENT_SYNC_HOST_DATA_PARAMS &readEventSyncHostDataParams) {
360+ PRINT_DEBUGGER_INFO_LOG (" DBGUMD_READ_EVENT_SYNC_HOST: hContextHandle=0x%llX\n " ,
361+ readEventSyncHostDataParams.hContextHandle );
362+
363+ uint64_t memoryHandle = DebugSessionWindows::invalidHandle;
364+ {
365+ std::unique_lock<std::mutex> lock (asyncThreadMutex);
366+ if (allContexts.empty ()) {
367+ return ZE_RESULT_ERROR_UNINITIALIZED;
368+ }
369+ memoryHandle = *allContexts.begin ();
370+ }
371+
372+ AttentionEventFields attentionEventFields = {};
373+ attentionEventFields.clientHandle = debugHandle;
374+ attentionEventFields.contextHandle = readEventSyncHostDataParams.hContextHandle ;
375+
376+ attentionEventContext[memoryHandle] = attentionEventFields;
377+
378+ handleStoppedThreads ();
379+ return ZE_RESULT_SUCCESS;
380+ }
381+
382+ ze_result_t DebugSessionWindows::updateStoppedThreadsAndCheckTriggerEvents (const AttentionEventFields &attention, uint32_t tileIndex, std::vector<EuThread::ThreadId> &threadsWithAttention) {
383+ auto hwInfo = connectedDevice->getHwInfo ();
384+ auto &l0GfxCoreHelper = connectedDevice->getL0GfxCoreHelper ();
385+
386+ if (threadsWithAttention.size () == 0 ) {
387+ threadsWithAttention = l0GfxCoreHelper.getThreadsFromAttentionBitmask (hwInfo, 0u ,
388+ attention.bitmask , attention.bitmaskSize );
389+
390+ printBitmask (attention.bitmask , attention.bitmaskSize );
391+ }
392+
393+ PRINT_DEBUGGER_THREAD_LOG (" ATTENTION for tile = %d thread count = %d\n " , tileIndex, (int )threadsWithAttention.size ());
394+
395+ if (threadsWithAttention.size () > 0 ) {
396+
397+ uint64_t memoryHandle = DebugSessionWindows::invalidHandle;
398+ {
399+ if (allContexts.empty ()) {
400+ PRINT_DEBUGGER_ERROR_LOG (" No contexts found\n " , " " );
401+ return ZE_RESULT_ERROR_UNINITIALIZED;
402+ }
403+ memoryHandle = *allContexts.begin ();
404+ }
405+
406+ auto gpuVa = getContextStateSaveAreaGpuVa (memoryHandle);
407+ auto stateSaveAreaSize = getContextStateSaveAreaSize (memoryHandle);
408+ auto stateSaveReadResult = ZE_RESULT_ERROR_UNKNOWN;
409+
410+ std::unique_lock<std::mutex> lock (threadStateMutex);
411+
412+ if (gpuVa != 0 && stateSaveAreaSize != 0 ) {
413+ std::vector<EuThread::ThreadId> newThreads;
414+ getNotStoppedThreads (threadsWithAttention, newThreads);
415+ if (newThreads.size () > 0 ) {
416+ allocateStateSaveAreaMemory (stateSaveAreaSize);
417+ stateSaveReadResult = readGpuMemory (memoryHandle, stateSaveAreaMemory.data (), stateSaveAreaSize, gpuVa);
418+ }
419+ } else {
420+ PRINT_DEBUGGER_ERROR_LOG (" Context state save area bind info invalid\n " , " " );
421+ DEBUG_BREAK_IF (true );
422+ }
423+
424+ if (stateSaveReadResult == ZE_RESULT_SUCCESS) {
425+
426+ for (auto &threadId : threadsWithAttention) {
427+ PRINT_DEBUGGER_THREAD_LOG (" ATTENTION event for thread: %s\n " , EuThread::toString (threadId).c_str ());
428+ addThreadToNewlyStoppedFromRaisedAttention (threadId, memoryHandle, stateSaveAreaMemory.data ());
429+ }
430+ }
431+ }
432+
433+ checkTriggerEventsForAttention ();
434+ return ZE_RESULT_SUCCESS;
435+ }
436+
398437ze_result_t DebugSessionWindows::acknowledgeEventImp (uint32_t seqNo, uint32_t eventType) {
399438 PRINT_DEBUGGER_INFO_LOG (" DBGUMD_ACTION_ACKNOWLEDGE_EVENT: seqNo: %d eventType: %d\n " , seqNo, eventType);
400439 KM_ESCAPE_INFO escapeInfo = {};
0 commit comments