aclrtResetDevice
Applicable Products
Product |
Supported |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
Function
Resets the current compute device and releases the resources on the device. The resources to be released include the default context, default stream, and all streams created in the default context. If tasks in the default context or default stream have not yet completed, the system will wait for the tasks to finish before releasing the resources.
aclrtResetDevice involves reference counting. You are advised to 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, the 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.