Skip to content

Commit 85ca66a

Browse files
CANN: Stream sync between devices for acl_graph (#15809)
* CANN: Switch to stream synchronization Switch to stream synchronization because events are not effective. Co-authored-by: hipudding <[email protected]> * CANN: add Comments --------- Co-authored-by: hipudding <[email protected]>
1 parent 3976dfb commit 85ca66a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

ggml/src/ggml-cann/ggml-cann.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,16 +2092,17 @@ static bool ggml_backend_cann_cpy_tensor_async(
20922092
ACL_CHECK(aclrtMemcpyAsync(dst->data, copy_size, src->data, copy_size,
20932093
ACL_MEMCPY_DEVICE_TO_DEVICE,
20942094
cann_ctx_src->stream()));
2095-
20962095
// record event on src stream after the copy
2097-
if (!cann_ctx_src->copy_event) {
2098-
ACL_CHECK(aclrtCreateEventWithFlag(&cann_ctx_src->copy_event, ACL_EVENT_SYNC));
2099-
}
2100-
ACL_CHECK(aclrtRecordEvent(cann_ctx_src->copy_event, cann_ctx_src->stream()));
2101-
2102-
// wait on dst stream for the copy to complete
2103-
ggml_cann_set_device(cann_ctx_dst->device);
2104-
ACL_CHECK(aclrtStreamWaitEvent(cann_ctx_dst->stream(), cann_ctx_src->copy_event));
2096+
// TODO: this event is not effective with acl graph mode, change to use aclrtSynchronizeStream
2097+
// if (!cann_ctx_src->copy_event) {
2098+
// ACL_CHECK(aclrtCreateEventWithFlag(&cann_ctx_src->copy_event, ACL_EVENT_SYNC));
2099+
// }
2100+
// ACL_CHECK(aclrtRecordEvent(cann_ctx_src->copy_event, cann_ctx_src->stream()));
2101+
2102+
// // wait on dst stream for the copy to complete
2103+
// ggml_cann_set_device(cann_ctx_dst->device);
2104+
// ACL_CHECK(aclrtStreamWaitEvent(cann_ctx_dst->stream(), cann_ctx_src->copy_event));
2105+
ACL_CHECK(aclrtSynchronizeStream(cann_ctx_src->stream()));
21052106
} else {
21062107
// src and dst are on the same backend
21072108
ACL_CHECK(aclrtMemcpyAsync(dst->data, copy_size, src->data, copy_size,

0 commit comments

Comments
 (0)