From c8ebc6f21eeed386814f9f2a9d1384cb965f2b83 Mon Sep 17 00:00:00 2001 From: Basil Milanich Date: Mon, 6 Apr 2026 14:00:01 -0500 Subject: [PATCH] Review fixes: correct stale comments, fix fetch() missing lock, tidy helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix wrong comments on graph launch tracker entries: they claimed correlation works "via CUPTI_ACTIVITY_KIND_GRAPH_TRACE", but that approach was rejected (GRAPH_TRACE suppresses per-kernel records). The actual mechanism is the shared correlationId across all nodes in one graph launch. - Fix ConcurrentHashMap::fetch() missing its read lock — a pre-existing data race now exercised by the new graph correlation hot path. - Cache PersistentState::Get().cudaGraphCurrentLaunch in a local ref inside matchGraphActivityToAPICall instead of calling Get() twice. Co-Authored-By: Claude Sonnet 4.6 --- public/tracy/TracyCUDA.hpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/public/tracy/TracyCUDA.hpp b/public/tracy/TracyCUDA.hpp index d540aa96..590bdb6c 100644 --- a/public/tracy/TracyCUDA.hpp +++ b/public/tracy/TracyCUDA.hpp @@ -337,6 +337,7 @@ struct ConcurrentHashMap { } auto fetch(TKey key, TValue& value) { ZoneNamed(fetch, instrument); + auto lock = acquire_read_lock(); auto it = mapping.find(key); if (it != mapping.end()) { value = it->second; @@ -782,8 +783,8 @@ namespace tracy { CUPTI_RUNTIME_TRACE_CBID_cudaEventQuery_v3020, NON_STREAM_FUNC() }, { CUPTI_RUNTIME_TRACE_CBID_cudaStreamWaitEvent_v3020, NON_STREAM_FUNC() }, { CUPTI_RUNTIME_TRACE_CBID_cudaDeviceSynchronize_v3020, NON_STREAM_FUNC() }, - // Graph launch: tracked so we can correlate GPU activities back to - // the cudaGraphLaunch call site via CUPTI_ACTIVITY_KIND_GRAPH_TRACE + // Graph launch: tracked so all CONCURRENT_KERNEL/MEMCPY/MEMSET activities + // sharing the launch's correlationId can be correlated back to this call site. { CUPTI_RUNTIME_TRACE_CBID_cudaGraphLaunch_v10000, GET_STREAM_FUNC(cudaGraphLaunch_v10000_params, stream) }, { CUPTI_RUNTIME_TRACE_CBID_cudaGraphLaunch_ptsz_v10000, GET_STREAM_FUNC(cudaGraphLaunch_v10000_params, stream) }, }; @@ -842,8 +843,8 @@ namespace tracy { CUPTI_DRIVER_TRACE_CBID_cuEventSynchronize, NON_STREAM_FUNC() }, { CUPTI_DRIVER_TRACE_CBID_cuCtxSynchronize, NON_STREAM_FUNC() }, { CUPTI_DRIVER_TRACE_CBID_cuStreamWaitEvent, GET_STREAM_FUNC(cuStreamWaitEvent_params, hStream) }, - // Graph launch: tracked so we can correlate GPU activities back to - // the cuGraphLaunch call site via CUPTI_ACTIVITY_KIND_GRAPH_TRACE + // Graph launch: tracked so all CONCURRENT_KERNEL/MEMCPY/MEMSET activities + // sharing the launch's correlationId can be correlated back to this call site. { CUPTI_DRIVER_TRACE_CBID_cuGraphLaunch, GET_STREAM_FUNC(cuGraphLaunch_params, hStream) }, { CUPTI_DRIVER_TRACE_CBID_cuGraphLaunch_ptsz, GET_STREAM_FUNC(cuGraphLaunch_params, hStream) }, }; @@ -916,13 +917,14 @@ namespace tracy // via either path. static bool matchGraphActivityToAPICall(uint32_t correlationId, uint32_t graphId, APICallInfo& apiCallInfo, const char* kind) { + auto& graphLaunchCache = PersistentState::Get().cudaGraphCurrentLaunch; if (!matchActivityToAPICall(correlationId, apiCallInfo)) { - if (graphId == 0 || !PersistentState::Get().cudaGraphCurrentLaunch.fetch(graphId, apiCallInfo)) { + if (graphId == 0 || !graphLaunchCache.fetch(graphId, apiCallInfo)) { matchError(correlationId, kind); return false; } } else if (graphId != 0) { - PersistentState::Get().cudaGraphCurrentLaunch.insert_or_assign(graphId, apiCallInfo); + graphLaunchCache.insert_or_assign(graphId, apiCallInfo); } return true; }