Function: synchronize_device_with_timeout

Applicability

Product

Supported (√/x)

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas training products

Atlas inference products

Atlas 200I/500 A2 inference products

Function Usage

Blocks app execution until the compute device has completed all preceding requested tasks. This API is enhanced based on synchronize_device and allows users to set the timeout interval. When an app is abnormal, the app automatically exits based on the configured timeout interval. When the app exits due to timeout, ACL_ERROR_RT_STREAM_SYNC_TIMEOUT is returned.

In multi-device scenarios, this API is called to wait for the device of the current context.

Prototype

  • C Prototype
    1
    aclError aclrtSynchronizeDeviceWithTimeout(int32_t timeout)
    
  • Python Function
    1
    ret = acl.rt.synchronize_device_with_timeout(timeout)
    

Parameter Description

Parameter

Description

timeout

Int, API timeout interval.

The options are as follows:

  • -1: waits forever, which functions equivalently as synchronize_device.
  • > 0: specific timeout interval, in milliseconds.

Return Value Description

Return Value

Description

ret

Int, error code: 0 on success; else, failure.