aclrtResetDevice
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 reference counting. It is recommended that aclrtResetDevice and aclrtSetDevice be used 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, no functional error is reported because the device will be automatically reset when the process exits.
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.
Prototype
aclError aclrtResetDevice(int32_t deviceId)
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
deviceId |
Input |
Device ID. |
Returns
The value 0 indicates success, and other values indicate failure. For details, see aclError.