Error Reported When the Query API Is Called for Asynchronous Copy
Symptom
event is used for synchronous waiting of H2D or D2H asynchronous copy tasks, and aclrtQueryEventStatus is called to confirm task progress. After that, aclrtFreeHost is called to free the host memory before calling aclrtDestroyEvent. As a result, the following error message may be displayed.

Possible Cause
An event record task is delivered after the asynchronous copy task is executed. It is expected that aclrtQueryEventStatus can be used to query whether the event record task is complete to determine whether the asynchronous copy task is complete before calling aclrtFreeHost to free the memory.
However, aclrtQueryEventStatus actually queries that the device does not transparently transmitted data to the host after executing the task. In this case, if the memory is freed before the event is destroyed, a time sequence error occurs.
Solution
To solve this problem, use either of the following solutions:
Solution 1: Call aclrtSynchronizeStream to check whether the task is completed.
Solution 2: Call aclrtDestroyEvent before calling aclrtQueryEventStatus, and then call aclrtFreeHost. This prevents problems caused by time sequence.