diff --git a/GPU/GPUTracking/Base/metal/GPUReconstructionMetal.mm b/GPU/GPUTracking/Base/metal/GPUReconstructionMetal.mm index 26d7281439c92..338a421df406b 100644 --- a/GPU/GPUTracking/Base/metal/GPUReconstructionMetal.mm +++ b/GPU/GPUTracking/Base/metal/GPUReconstructionMetal.mm @@ -15,6 +15,7 @@ #include "GPUDefParametersLoad.inc" #include "GPUReconstructionMetal.h" +#include #include #include @@ -376,13 +377,27 @@ MetalMemRef metalResolve(const GPUReconstructionMetalInternals* internals, const void GPUReconstructionMetal::DrainStream(int32_t stream) { - if (mInternals->streamHasWork[stream]) { - CommitStream(stream); + // Hand the GPU what the other streams have encoded too, so it has work + // while the host waits and then works on what it waited for. + for (int32_t i = 0; i < mNStreams; i++) { + if (mInternals->streamHasWork[i]) { + CommitStream(i); + } } // Waiting on the buffer that is currently open would block forever: it is not // committed, so it never completes. Only what was submitted can be waited for. + // The last submitted buffer ends by signalling the stream's order event, once + // all the work before it is done. Watching the event returns sooner than + // waitUntilCompleted, which sleeps until the completion has been processed. + // Only short waits are worth a busy core, so give up after a while. + bool done = false; + const auto t0 = std::chrono::steady_clock::now(); + while (!mInternals->submittedBuffers[stream].empty() && !(done = mInternals->streamOrder[stream].signaledValue >= mInternals->streamOrderValue[stream]) && std::chrono::steady_clock::now() - t0 < std::chrono::milliseconds(20)) { + } for (id cb : mInternals->submittedBuffers[stream]) { - [cb waitUntilCompleted]; + if (!done) { + [cb waitUntilCompleted]; + } if (cb.status == MTLCommandBufferStatusError) { GPUError("Metal command buffer on stream %d failed: %s", stream, [[cb.error description] UTF8String]); } diff --git a/GPU/GPUTracking/Definitions/Parameters/GPUParameters.csv b/GPU/GPUTracking/Definitions/Parameters/GPUParameters.csv index 060ae99bffc37..fba91d5366b52 100644 --- a/GPU/GPUTracking/Definitions/Parameters/GPUParameters.csv +++ b/GPU/GPUTracking/Definitions/Parameters/GPUParameters.csv @@ -28,7 +28,7 @@ GPUTPCCFDecodeZSDenseLink,"""GPUCA_WARP_SIZE""",,"[""GPUCA_WARP_SIZE"", 4]","["" GPUTPCCFGather,"[1024, 1]",,"[1024, 5]","[1024, 1]",,,,,,"[160, 11]","[1024, 1]",736,896,,"[928, 1]",,"[1024, 1]","[320, 2]", COMPRESSION_GATHER,1024,,1024,1024,,,,,,1024,1024,,1024,,,,,, GPUTPCGMMergerTrackFit,256,,"[192, 2]","[64, 7]",,,,,,"[32, 16]","[32, 8]","[32, 14]","[160, 2]",,"[32, 24]",,"[64, 8]","[64, 6]","[64, 4]" -GPUTPCGMMergerFollowLoopers,256,,"[256, 5]","[256, 4]",,,,,,"[256, 4]","[128, 4]","[1024, 1]",640,,"[128, 16]",,"[224, 3]","[256, 7]", +GPUTPCGMMergerFollowLoopers,256,,"[256, 5]","[256, 4]",,,,,,"[256, 4]","[128, 4]","[1024, 1]",640,,"[128, 16]",,"[224, 3]","[256, 7]","[1, 16]" GPUTPCGMMergerSectorRefit,256,,"[64, 4]","[256, 2]",,,,,,"[32, 8]","[64, 5]","[32, 7]","[32, 7]",,"[32, 20]",,"[32, 10]","[64, 4]", GPUTPCGMMergerUnpackResetIds,256,,256,256,,,,,,256,256,256,256,,256,,256,256, GPUTPCGMMergerUnpackGlobal,256,,256,256,,,,,,256,256,256,256,,256,,256,256,