aclrtResetDevice

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

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 is incremented 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

1
aclError aclrtResetDevice(int32_t deviceId)

Parameters

Parameter

Input/Output

Description

deviceId

Input

Device ID.

Returns

0 on success; otherwise, 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.