Task Stopping Upon Failure

CANN supports the ACL_STOP_ON_FAILURE (stopping upon failure) and ACL_CONTINUE_ON_FAILURE (continuing upon failure) modes to meet differentiated control requirements of different applications on task execution failures. By default, the ACL_CONTINUE_ON_FAILURE mode is used.

If a task in a stream fails to be executed and the ACL_STOP_ON_FAILURE mode is used, the execution of tasks in all streams of the context is stopped. If the ACL_CONTINUE_ON_FAILURE mode is used, subsequent tasks in the stream continue to be executed.

The following is the sample code for calling the aclrtSetStreamFailureMode API to specify the scheduling mode, which is for reference only and cannot be directly copied for compilation and running:

1
2
3
4
5
6
aclrtStream stream;
aclrtCreateStream(&stream);

// Set the ACL_STOP_ON_FAILURE mode.
aclrtSetStreamFailureMode(stream, ACL_STOP_ON_FAILURE);
......

The following is the sample code for calling the aclrtSetStreamAttribute API to specify the scheduling mode, which is for reference only and cannot be directly copied for compilation and running:

1
2
3
4
5
6
aclrtStream stream;
aclrtCreateStream(&stream);

// Set the ACL_CONTINUE_ON_FAILURE mode.
aclrtSetStreamAttribute(stream, ACL_STREAM_ATTR_FAILURE_MODE, ACL_CONTINUE_ON_FAILURE);
......