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 i-chaochen committed Aug 8, 2024
1 parent dc89176 commit b1ac447
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 @@ -125,12 +125,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();
TF_ASSIGN_OR_RETURN(auto event, executor->CreateEvent());
// Record memcpy operation completion.
Expand Down

0 comments on commit b1ac447

Please sign in to comment.