aclrtSetExceptionInfoCallback
Description
Sets the exception callback function.
Restrictions
- Set an exception callback function before task execution on the device. When a task fails, the system passes a pointer to the aclrtExceptionInfo struct that contains the task ID, stream ID, thread ID, and device ID to the exception callback function and executes the callback function. You can call aclrtGetTaskIdFromExceptionInfo, aclrtGetStreamIdFromExceptionInfo, aclrtGetThreadIdFromExceptionInfo, aclrtGetDeviceIdFromExceptionInfo, and aclrtGetErrorCodeFromExceptionInfo to obtain the error task ID, stream ID, thread ID, and device ID, respectively, to facilitate fault locating.
Example use case: Before the aclopExecuteV2 call, call aclrtSetExceptionInfoCallback to set an exception callback function. When operator execution on the device fails, the system passes a pointer to the aclrtExceptionInfo struct that contains the task ID, stream ID, thread ID, device ID, and error code to the exception callback function and executes the callback function.
- If the exception callback function is set repeatedly, the most recent setting applies.
- To clear the callback function, pass a null pointer to the aclrtSetExceptionInfoCallback call.
Prototype
aclError aclrtSetExceptionInfoCallback(aclrtExceptionInfoCallback callback)
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
callback |
Input |
Callback function. Prototype: typedef void (*aclrtExceptionInfoCallback)(aclrtExceptionInfo *exceptionInfo); |
Returns
The value 0 indicates success, and other values indicate failure. For details, see aclError.
Parent topic: Exception Handling