Skip to content

Commit 32841da

Browse files
committed
GPU Metal: wait for synchronous copies to complete
A copy or constant-memory write on stream -1 is synchronous in the CUDA and HIP backends, and the callers read the destination right after it. The Metal backend only encoded the copy into stream 0's open command buffer, so e.g. CheckErrorCodes read a stale error buffer and lost the errors raised after the last synchronisation, such as ERROR_MERGER_HIT_OVERFLOW. Drain the stream before returning.
1 parent 1eb67a0 commit 32841da

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎GPU/GPUTracking/Base/metal/GPUReconstructionMetal.mm‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ MetalMemRef metalResolve(const GPUReconstructionMetalInternals* internals, const
336336
if (ev) {
337337
RecordMarker(ev, realStream);
338338
}
339+
if (stream == -1) { // Synchronous like cudaMemcpy: the caller reads the destination right away
340+
DrainStream(realStream);
341+
}
339342

340343
if (GetProcessingSettings().serializeGPU & 2) {
341344
GPUDebug(("GPUMemCpy " + std::to_string(toGPU)).c_str(), stream, true);
@@ -370,6 +373,9 @@ MetalMemRef metalResolve(const GPUReconstructionMetalInternals* internals, const
370373
if (ev) {
371374
RecordMarker(ev, realStream);
372375
}
376+
if (stream == -1) {
377+
DrainStream(realStream);
378+
}
373379

374380
if (GetProcessingSettings().serializeGPU & 2) {
375381
GPUDebug("WriteToConstantMemory", stream, true);

0 commit comments

Comments
 (0)