Skip to content

Commit 2ecb908

Browse files
authored
GPU: more Metal bringup changes (#16064)
1 parent 52cedef commit 2ecb908

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "GPUDefParametersLoad.inc"
1616
#include "GPUReconstructionMetal.h"
1717

18+
#include <chrono>
1819
#include <cstddef>
1920
#include <map>
2021

@@ -376,13 +377,27 @@ MetalMemRef metalResolve(const GPUReconstructionMetalInternals* internals, const
376377

377378
void GPUReconstructionMetal::DrainStream(int32_t stream)
378379
{
379-
if (mInternals->streamHasWork[stream]) {
380-
CommitStream(stream);
380+
// Hand the GPU what the other streams have encoded too, so it has work
381+
// while the host waits and then works on what it waited for.
382+
for (int32_t i = 0; i < mNStreams; i++) {
383+
if (mInternals->streamHasWork[i]) {
384+
CommitStream(i);
385+
}
381386
}
382387
// Waiting on the buffer that is currently open would block forever: it is not
383388
// committed, so it never completes. Only what was submitted can be waited for.
389+
// The last submitted buffer ends by signalling the stream's order event, once
390+
// all the work before it is done. Watching the event returns sooner than
391+
// waitUntilCompleted, which sleeps until the completion has been processed.
392+
// Only short waits are worth a busy core, so give up after a while.
393+
bool done = false;
394+
const auto t0 = std::chrono::steady_clock::now();
395+
while (!mInternals->submittedBuffers[stream].empty() && !(done = mInternals->streamOrder[stream].signaledValue >= mInternals->streamOrderValue[stream]) && std::chrono::steady_clock::now() - t0 < std::chrono::milliseconds(20)) {
396+
}
384397
for (id<MTLCommandBuffer> cb : mInternals->submittedBuffers[stream]) {
385-
[cb waitUntilCompleted];
398+
if (!done) {
399+
[cb waitUntilCompleted];
400+
}
386401
if (cb.status == MTLCommandBufferStatusError) {
387402
GPUError("Metal command buffer on stream %d failed: %s", stream, [[cb.error description] UTF8String]);
388403
}

‎GPU/GPUTracking/Definitions/Parameters/GPUParameters.csv‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ GPUTPCCFDecodeZSDenseLink,"""GPUCA_WARP_SIZE""",,"[""GPUCA_WARP_SIZE"", 4]","[""
2828
GPUTPCCFGather,"[1024, 1]",,"[1024, 5]","[1024, 1]",,,,,,"[160, 11]","[1024, 1]",736,896,,"[928, 1]",,"[1024, 1]","[320, 2]",
2929
COMPRESSION_GATHER,1024,,1024,1024,,,,,,1024,1024,,1024,,,,,,
3030
GPUTPCGMMergerTrackFit,256,,"[192, 2]","[64, 7]",,,,,,"[32, 16]","[32, 8]","[32, 14]","[160, 2]",,"[32, 24]",,"[64, 8]","[64, 6]","[64, 4]"
31-
GPUTPCGMMergerFollowLoopers,256,,"[256, 5]","[256, 4]",,,,,,"[256, 4]","[128, 4]","[1024, 1]",640,,"[128, 16]",,"[224, 3]","[256, 7]",
31+
GPUTPCGMMergerFollowLoopers,256,,"[256, 5]","[256, 4]",,,,,,"[256, 4]","[128, 4]","[1024, 1]",640,,"[128, 16]",,"[224, 3]","[256, 7]","[1, 16]"
3232
GPUTPCGMMergerSectorRefit,256,,"[64, 4]","[256, 2]",,,,,,"[32, 8]","[64, 5]","[32, 7]","[32, 7]",,"[32, 20]",,"[32, 10]","[64, 4]",
3333
GPUTPCGMMergerUnpackResetIds,256,,256,256,,,,,,256,256,256,256,,256,,256,256,
3434
GPUTPCGMMergerUnpackGlobal,256,,256,256,,,,,,256,256,256,256,,256,,256,256,

0 commit comments

Comments
 (0)