aclmdlRICaptureThreadExchangeMode

Applicable Products

Product

Supported

Ascend 950PR / Ascend 950DT

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

Function

Switches the capture mode of the current thread.

Calling this API will set the capture mode of the calling thread to the value contained in *mode, and return the previously set mode of the thread through *mode.

It is recommended that this API be called between aclmdlRICaptureBegin and aclmdlRICaptureEnd to switch the mode of the current thread. The configurations of all capture modes are described below. Other threads in the description refer to threads that do not call aclmdlRICaptureBegin and are not in the capture state.
  • If aclmdlRICaptureBegin is called to set the capture mode to ACL_MODEL_RI_CAPTURE_MODE_RELAXED (RELAXED mode for short), all threads can call unsafe functions. In this case, even if this API is called in other threads (threads that are not in the capture state) to set the capture mode to another value, the setting does not take effect. Other threads still follow the RELAXED mode.
  • If aclmdlRICaptureBegin is called to set the capture mode to ACL_MODEL_RI_CAPTURE_MODE_THREAD_LOCAL (THREAD_LOCAL mode for short), the current thread is not allowed to call unsafe functions, but other threads can call unsafe functions. If the current thread needs to call unsafe functions, this API needs to be called to switch the current thread mode to RELAXED.
  • If aclmdlRICaptureBegin is called to set the capture mode to ACL_MODEL_RI_CAPTURE_MODE_GLOBAL (GLOBAL mode for short), no thread can call unsafe functions. If the current thread needs to call unsafe functions, this API needs to be called to switch the current thread mode to RELAXED. If other threads need to call unsafe functions, this API needs to be called to switch the current thread mode to RELAXED or THREAD_LOCAL.

Prototype

1
aclError aclmdlRICaptureThreadExchangeMode(aclmdlRICaptureMode *mode)

Parameters

Parameter

Input/Output

Description

mode

Input/Output

Capture mode. This mode is used to limit the scope of unsafe functions, including aclrtMemset, aclrtMemcpy, aclrtMemcpy2d, and APIs (such as aclrtMemcpyAsync) that use non-page-locked host memory for asynchronous memory copy.

For details about the type definition, see aclmdlRICaptureMode.

Returns

0 on success; otherwise, failure. For details, see aclError.

API Call Example

For the API call example, see Single-Stream Capture.