aclrtResetDevice

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

Resets the current device and releases the resources on the device. The resources it releases include the default context, default stream, and all streams created in the default context. If a task in the default context or stream is not complete, the system releases the context or stream after the task is complete.

aclrtResetDevice involves the implementation of the reference count. It is recommended that you use aclrtResetDevice and aclrtSetDevice in pairs. Each time aclrtSetDevice is called, the reference count increases by 1. Each time aclrtResetDevice is called, the reference count decreases by 1. Resources on the device are released only when the reference count decreases to 0.

If aclrtSetDevice is called repeatedly in a process while aclrtResetDevice is not called to reset the device, device resources used by the process will still be released when the process exits.

Prototype

aclError aclrtResetDevice(int32_t deviceId)

Parameters

Parameter

Input/Output

Description

deviceId

Input

Device ID.

Returns

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

Restrictions

If there are explicitly created contexts, streams, or events on the device to be reset, you are advised to follow the following call sequence before resetting. Otherwise, exceptions may occur.

The API call sequence is as follows: call aclrtDestroyEvent to destroy the event or call aclrtDestroyStream to destroy the explicitly created stream--> call aclrtDestroyContext to destroy the explicitly created context--> call aclrtResetDevice.

See Also

For details about the API call sequence and example, see Runtime Resource Allocation and Deallocation.