aclmdlRICaptureThreadExchangeMode

Note: This feature is for trial use and may be changed in later versions. It is not available in commercial products.

Applicability

Product

Supported

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

Description

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.

Prototype

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.

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 aclmdlRICaptureThreadExchangeMode 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, aclmdlRICaptureThreadExchangeMode 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, aclmdlRICaptureThreadExchangeMode needs to be called to switch the current thread mode to RELAXED. If other threads need to call unsafe functions, aclmdlRICaptureThreadExchangeMode needs to be called to switch the current thread mode to RELAXED or THREAD_LOCAL.

Returns

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