Skip to content

Commit

Permalink
Let the other stream wait for the main stream before issuing memcpy d2h
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenying-liu authored and hsharsha committed Jun 19, 2024
1 parent 87532fc commit fceb56c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion xla/service/gpu/runtime/copy_thunk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,13 @@ absl::Status DeviceToHostCopyThunk::ExecuteOnStream(
TF_ASSIGN_OR_RETURN(
se::Stream * stream,
GetStreamForExecution(Thunk::execution_stream_id(), params));
TF_RETURN_IF_ERROR(stream->WaitFor(params.stream));
TF_RETURN_IF_ERROR(stream->Memcpy(cpu_dst, source_data, size_bytes()));
if (stream == params.stream) {
VLOG(2) << "Memcpy D2H from the main stream";
return absl::OkStatus();
}
VLOG(2) << "Memcpy D2H from the other stream";
VLOG(2) << "Memcpy D2H from the stream " << Thunk::execution_stream_id();
se::StreamExecutor* executor = params.stream->parent();
se::Event event(executor);
if (!event.Init()) {
Expand Down

0 comments on commit fceb56c

Please sign in to comment.