Event-based Synchronization

Following the API calls, add exception handling branches and specify log printing of error and information levels. The following is a code snippet of key steps only, which is not ready to be built or run.

#include "acl/acl.h"
// ......
//Create an event.
aclrtEvent event;
aclrtCreateEvent(&event);

//Create a stream.
aclrtStream stream;
aclrtCreateStream(&stream);

//Append an event to a stream.
aclrtRecordEvent(event, stream);

//Block the app execution and wait until the event is complete, that is, the completion of the stream.
//The stream completion event wakes up the control flow, starting the app execution.
aclrtSynchronizeEvent(event);

//Explicitly destroy allocations.
aclrtDestroyStream(stream);
aclrtDestroyEvent(event);
// ......