3.10. 事件

其中一个事件将创建一个CUDBGEvent

  • 当前内核的ELF镜像已加载,其DWARF节中的地址已完成重定位(现在可用于设置断点),

  • 已触发设备断点,

  • 一个CUDA内核已准备就绪可以启动,

  • 一个CUDA内核已终止。

When a CUDBGEvent is created, the debugger is notified by calling the callback functions registered with setNotifyNewEventCallback() after the API struct initialization. It is up to the debugger to decide what method is best to be notified. The debugger API routines cannot be called from within the callback function or the routine will return an error.

收到通知后,调试器负责通过使用CUDBGAPI_st::getNextEvent()处理事件队列中的CUDBGEvents,并通过调用CUDBGAPI_st::acknowledgeEvent()向调试器API确认事件已处理完毕。对于设备自身触发的事件(例如命中断点),事件队列将为空。调试器的职责是在每次接收到CUDBGEvent时检查硬件状态。

示例:

CUDBGEvent event;
      CUDBGResult res;
      for (res = cudbgAPI->getNextEvent(&event);
           res == CUDBG_SUCCESS && event.kind != CUDBG_EVENT_INVALID;
           res = cudbgAPI->getNextEvent(&event)) {
          switch (event.kind)
              {
              case CUDBG_EVENT_ELF_IMAGE_LOADED:
                  //...
                  break;
              case CUDBG_EVENT_KERNEL_READY:
                  //...
                  break;
              case CUDBG_EVENT_KERNEL_FINISHED:
                  //...
                  break;
              default:
                  error(...);
              }
          }

有关如何使用CUDBGEvent的更详细示例,请参阅cuda-gdb源代码中的cuda-tdep.c和cuda-linux-nat.c文件。

struct 
Event information container.
struct 
Event information passed to callback set with setNotifyNewEventCallback function.
struct 
Event information passed to callback set with setNotifyNewEventCallback function.

类型定义

typedef void  ( *CUDBGNotifyNewEventCallback )( CUDBGEventCallbackData*  data )
function type of the function called to notify debugger of the presence of a new event in the event queue.
typedef void  ( *CUDBGNotifyNewEventCallback31 )( void*  data )
function type of the function called to notify debugger of the presence of a new event in the event queue.

枚举

enum CUDBGEventKind
CUDA Kernel Events.

变量

CUDBGResult  ( *CUDBGAPI_st::acknowledgeEvent30 )( CUDBGEvent30* event )
Inform the debugger API that the event has been processed.
CUDBGResult  ( *CUDBGAPI_st::acknowledgeEvents42 )( )
Inform the debugger API that synchronous events have been processed.
CUDBGResult  ( *CUDBGAPI_st::acknowledgeSyncEvents )( )
Inform the debugger API that synchronous events have been processed.
CUDBGResult  ( *CUDBGAPI_st::getErrorStringEx )( char* buf, uint32_t bufSz, uint32_t* msgSz )
Fills a user-provided buffer with an error message encoded as a null-terminated ASCII string. The error message is specific to the last failed API call and is invalidated after every API call.
CUDBGResult  ( *CUDBGAPI_st::getNextAsyncEvent50 )( CUDBGEvent50* event )
Copies the next available event in the asynchronous event queue into 'event' and removes it from the queue. The asynchronous event queue is held separate from the normal event queue, and does not require acknowledgement from the debug client.
CUDBGResult  ( *CUDBGAPI_st::getNextAsyncEvent55 )( CUDBGEvent55* event )
Copies the next available event in the asynchronous event queue into 'event' and removes it from the queue. The asynchronous event queue is held separate from the normal event queue, and does not require acknowledgement from the debug client.
CUDBGResult  ( *CUDBGAPI_st::getNextEvent )( CUDBGEventQueueType type, CUDBGEvent* event )
Copies the next available event into 'event' and removes it from the queue.
CUDBGResult  ( *CUDBGAPI_st::getNextEvent30 )( CUDBGEvent30* event )
Copies the next available event in the event queue into 'event' and removes it from the queue.
CUDBGResult  ( *CUDBGAPI_st::getNextEvent32 )( CUDBGEvent32* event )
Copies the next available event in the event queue into 'event' and removes it from the queue.
CUDBGResult  ( *CUDBGAPI_st::getNextEvent42 )( CUDBGEvent42* event )
Copies the next available event in the event queue into 'event' and removes it from the queue.
CUDBGResult  ( *CUDBGAPI_st::getNextSyncEvent50 )( CUDBGEvent50* event )
CUDBGResult  ( *CUDBGAPI_st::getNextSyncEvent55 )( CUDBGEvent55* event )
Copies the next available event in the synchronous event queue into 'event' and removes it from the queue.
CUDBGResult  ( *CUDBGAPI_st::setNotifyNewEventCallback )( CUDBGNotifyNewEventCallback callback )
Provides the API with the function to call to notify the debugger of a new application or device event.
CUDBGResult  ( *CUDBGAPI_st::setNotifyNewEventCallback31 )( CUDBGNotifyNewEventCallback31 callback, void* data )
Provides the API with the function to call to notify the debugger of a new application or device event.
CUDBGResult  ( *CUDBGAPI_st::setNotifyNewEventCallback40 )( CUDBGNotifyNewEventCallback40 callback )
Provides the API with the function to call to notify the debugger of a new application or device event.

类型定义

void ( *CUDBGNotifyNewEventCallback )( CUDBGEventCallbackData*  data )

用于通知调试器事件队列中出现新事件的函数类型。

void ( *CUDBGNotifyNewEventCallback31 )( void*  data )

用于通知调试器事件队列中出现新事件的函数类型。

枚举

enum CUDBGEventKind

数值
CUDBG_EVENT_INVALID = 0x000
Invalid event.
CUDBG_EVENT_ELF_IMAGE_LOADED = 0x001
The ELF image for a CUDA source module is available.
CUDBG_EVENT_KERNEL_READY = 0x002
A CUDA kernel is about to be launched.
CUDBG_EVENT_KERNEL_FINISHED = 0x003
A CUDA kernel has terminated.
CUDBG_EVENT_INTERNAL_ERROR = 0x004
An internal error occur. The debugging framework may be unstable.
CUDBG_EVENT_CTX_PUSH = 0x005
A CUDA context was pushed.
CUDBG_EVENT_CTX_POP = 0x006
A CUDA CTX was popped.
CUDBG_EVENT_CTX_CREATE = 0x007
A CUDA CTX was created.
CUDBG_EVENT_CTX_DESTROY = 0x008
A CUDA context was destroyed.
CUDBG_EVENT_TIMEOUT = 0x009
An timeout event is sent at regular interval. This event can safely ge ignored.
CUDBG_EVENT_ATTACH_COMPLETE = 0x00a
The attach process has completed and debugging of device code may start.
CUDBG_EVENT_DETACH_COMPLETE = 0x00b
CUDBG_EVENT_ELF_IMAGE_UNLOADED = 0x00c
CUDBG_EVENT_FUNCTIONS_LOADED = 0x00d
CUDBG_EVENT_ALL_DEVICES_SUSPENDED = 0x00e

变量

CUDBGResult ( *CUDBGAPI_st::acknowledgeEvent30 )( CUDBGEvent30* event )

通知调试器API该事件已处理完毕。自CUDA 3.0起。

参数
event
- pointer to the event that has been processed
返回

CUDBG_SUCCESS

CUDBGResult ( *CUDBGAPI_st::acknowledgeEvents42 )( )

通知调试器API同步事件已处理完毕。自CUDA 3.1起。

返回

CUDBG_SUCCESS

CUDBGResult ( *CUDBGAPI_st::acknowledgeSyncEvents )( )

通知调试器API同步事件已处理完毕。自CUDA 5.0起。

返回

CUDBG_SUCCESS

CUDBGResult ( *CUDBGAPI_st::getErrorStringEx )( char* buf, uint32_t bufSz, uint32_t* msgSz )

使用以空字符结尾的ASCII字符串编码的错误消息填充用户提供的缓冲区。该错误消息针对最近失败的API调用,并在每次API调用后失效。自CUDA 12.2起。

另请参阅:

获取错误字符串

参数
buf
- the destination buffer
bufSz
- the size of the destination buffer in bytes
msgSz
- the size of an error message including the terminating null character.
返回

CUDBG_SUCCESS, CUDBG_ERROR_BUFFER_TOO_SMALL CUDBG_ERROR_INVALID_ARGS, CUDBG_ERROR_UNINITIALIZED

CUDBGResult ( *CUDBGAPI_st::getNextAsyncEvent50 )( CUDBGEvent50* event )

将异步事件队列中的下一个可用事件复制到'event'中,并将其从队列中移除。异步事件队列与普通事件队列分开维护,不需要调试客户端的确认。自CUDA 5.0起。

参数
event
- pointer to an event container where to copy the event parameters
返回

CUDBG_SUCCESS, CUDBG_ERROR_NO_EVENT_AVAILABLE, CUDBG_ERROR_INVALID_ARGS

CUDBGResult ( *CUDBGAPI_st::getNextAsyncEvent55 )( CUDBGEvent55* event )

将异步事件队列中的下一个可用事件复制到'event'中,并将其从队列中移除。异步事件队列与常规事件队列分开维护,不需要调试客户端的确认。自CUDA 5.5起。

参数
event
- pointer to an event container where to copy the event parameters
返回

CUDBG_SUCCESS, CUDBG_ERROR_NO_EVENT_AVAILABLE, CUDBG_ERROR_INVALID_ARGS

CUDBGResult ( *CUDBGAPI_st::getNextEvent )( CUDBGEventQueueType type, CUDBGEvent* event )

将下一个可用事件复制到'event'中,并将其从队列中移除。自CUDA 6.0起。

参数
type
- application event queue type
event
- pointer to an event container where to copy the event parameters
返回

CUDBG_SUCCESS, CUDBG_ERROR_NO_EVENT_AVAILABLE, CUDBG_ERROR_INVALID_ARGS

CUDBGResult ( *CUDBGAPI_st::getNextEvent30 )( CUDBGEvent30* event )

将事件队列中的下一个可用事件复制到'event'中,并将其从队列中移除。自CUDA 3.0起。

参数
event
- pointer to an event container where to copy the event parameters
返回

CUDBG_SUCCESS, CUDBG_ERROR_NO_EVENT_AVAILABLE, CUDBG_ERROR_INVALID_ARGS

CUDBGResult ( *CUDBGAPI_st::getNextEvent32 )( CUDBGEvent32* event )

将事件队列中的下一个可用事件复制到'event'中,并将其从队列中移除。自CUDA 3.1版本起支持。

参数
event
- pointer to an event container where to copy the event parameters
返回

CUDBG_SUCCESS, CUDBG_ERROR_NO_EVENT_AVAILABLE, CUDBG_ERROR_INVALID_ARGS

CUDBGResult ( *CUDBGAPI_st::getNextEvent42 )( CUDBGEvent42* event )

将事件队列中的下一个可用事件复制到'event'中,并将其从队列中移除。自CUDA 4.0起。

参数
event
- pointer to an event container where to copy the event parameters
返回

CUDBG_SUCCESS, CUDBG_ERROR_NO_EVENT_AVAILABLE, CUDBG_ERROR_INVALID_ARGS

CUDBGResult ( *CUDBGAPI_st::getNextSyncEvent50 )( CUDBGEvent50* event )

自 CUDA 5.0 起。

参数
event
- pointer to an event container where to copy the event parameters
返回

CUDBG_SUCCESS, CUDBG_ERROR_NO_EVENT_AVAILABLE, CUDBG_ERROR_INVALID_ARGS

CUDBGResult ( *CUDBGAPI_st::getNextSyncEvent55 )( CUDBGEvent55* event )

将同步事件队列中的下一个可用事件复制到'event'中,并将其从队列中移除。自CUDA 5.5起。

参数
event
- pointer to an event container where to copy the event parameters
返回

CUDBG_SUCCESS, CUDBG_ERROR_NO_EVENT_AVAILABLE, CUDBG_ERROR_INVALID_ARGS

CUDBGResult ( *CUDBGAPI_st::setNotifyNewEventCallback )( CUDBGNotifyNewEventCallback callback )

提供API功能,用于通知调试器有新应用程序或设备事件。自CUDA 4.1起支持。

参数
callback
- the callback function
返回

CUDBG_SUCCESS

CUDBGResult ( *CUDBGAPI_st::setNotifyNewEventCallback31 )( CUDBGNotifyNewEventCallback31 callback, void* data )

提供API功能,用于通知调试器有新应用程序或设备事件。自CUDA 3.0起。

参数
callback
- the callback function
data
- a pointer to be passed to the callback when called
返回

CUDBG_SUCCESS

CUDBGResult ( *CUDBGAPI_st::setNotifyNewEventCallback40 )( CUDBGNotifyNewEventCallback40 callback )

提供API功能,用于通知调试器有新应用程序或设备事件。自CUDA 3.2起。

参数
callback
- the callback function
返回

CUDBG_SUCCESS