Skip to content

Commit 6f952f3

Browse files
committed
[XPU] add synchronize when copy from/to pinned memory
1 parent a1d519c commit 6f952f3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

paddle/phi/core/memory/memcpy.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ void Copy<phi::XPUPinnedPlace, phi::XPUPlace>(phi::XPUPinnedPlace dst_place,
399399
reinterpret_cast<cudaStream_t>(stream));
400400

401401
} else {
402+
cudaDeviceSynchronize();
402403
phi::RecordEvent record_event(
403404
"cudaMemcpy:XPU->XPUPinned", phi::TracerEventType::UserDefined, 1);
404405
cudaMemcpy(dst, src, num, cudaMemcpyDeviceToHost);
@@ -435,6 +436,7 @@ void Copy<phi::XPUPlace, phi::XPUPinnedPlace>(phi::XPUPlace dst_place,
435436
cudaMemcpyHostToDevice,
436437
reinterpret_cast<cudaStream_t>(stream));
437438
} else {
439+
cudaDeviceSynchronize();
438440
phi::RecordEvent record_event(
439441
"cudaMemcpy:XPUPinned->XPU", phi::TracerEventType::UserDefined, 1);
440442
cudaMemcpy(dst, src, num, cudaMemcpyHostToDevice);

0 commit comments

Comments
 (0)