Use a map to record counter values

This removes the limitation of 10 counters.
This commit is contained in:
Eric Eaton
2025-07-09 23:08:58 -07:00
parent 6a5e4d8a60
commit 3fce5c1280
4 changed files with 31 additions and 25 deletions

View File

@@ -1580,16 +1580,15 @@ void View::DrawGpuInfoWindow()
}
TextFocused( "Query ID:", RealToString( ev.query_id ) );
for( int i = 0; i < ev.note_count; i++ )
for( auto& p : ev.notes )
{
auto id = ev.note_ids[i];
if( ctx->notes.count( id ) )
if( ctx->notes.count( p.first ) )
{
TextFocused( m_worker.GetString( ctx->notes.at( id ) ), RealToString( ev.note_vals[i] ) );
TextFocused( m_worker.GetString( ctx->notes.at( p.first ) ), RealToString( p.second ) );
}
else
{
TextFocused( RealToString( ev.note_ids[i] ), RealToString( ev.note_vals[i] ) );
TextFocused( RealToString( p.first ), RealToString( p.second ) );
}
}
@@ -2061,16 +2060,15 @@ void View::ZoneTooltip( const GpuEvent& ev )
}
TextFocused( "Query ID:", RealToString( ev.query_id ) );
for( int i = 0; i < ev.note_count; i++ )
for( auto& p : ev.notes )
{
auto id = ev.note_ids[i];
if( ctx->notes.count( id ) )
if( ctx->notes.count( p.first ) )
{
TextFocused( m_worker.GetString( ctx->notes.at( id ) ), RealToString( ev.note_vals[i] ) );
TextFocused( m_worker.GetString( ctx->notes.at( p.first ) ), RealToString( p.second ) );
}
else
{
TextFocused( RealToString( ev.note_ids[i] ), RealToString( ev.note_vals[i] ) );
TextFocused( RealToString( p.first ), RealToString( p.second ) );
}
}

View File

@@ -366,8 +366,6 @@ void dispatch_callback( rocprofiler_dispatch_counting_service_data_t dispatch_da
*config = profile;
}
using kernel_symbol_data_t = rocprofiler_callback_tracing_code_object_kernel_symbol_register_data_t;
void tool_callback_tracing_callback( rocprofiler_callback_tracing_record_t record, rocprofiler_user_data_t* user_data,
void* callback_data )
{

View File

@@ -413,9 +413,7 @@ struct GpuEvent
uint64_t _gpuEnd_child2;
Int24 callstack;
uint16_t query_id;
int64_t note_ids[10];
double note_vals[10];
uint8_t note_count;
unordered_flat_map<int64_t, double> notes;
};
enum { GpuEventSize = sizeof( GpuEvent ) };

View File

@@ -5774,6 +5774,10 @@ void Worker::ProcessGpuZoneBeginImplCommon( GpuEvent* zone, const QueueGpuZoneBe
zone->callstack.SetVal( 0 );
zone->SetChild( -1 );
zone->query_id = ev.queryId;
// tracy allocates slab memory without invoking the constructor
new( &zone->notes ) unordered_flat_map<int64_t, double>();
// reserve space for all the counters we've been given a name for
zone->notes.reserve( ctx->notes.size() );
uint64_t ztid;
if( ctx->thread == 0 )
@@ -6054,10 +6058,7 @@ void Worker::ProcessGpuZoneAnnotation( const QueueGpuZoneAnnotation& ev )
}
}
auto& zone = timeline[i];
assert( zone->note_count < 10 );
zone->note_ids[zone->note_count] = ev.noteId;
zone->note_vals[zone->note_count] = ev.value;
zone->note_count++;
zone->notes.insert_or_assign( ev.noteId, ev.value );
}
MemEvent* Worker::ProcessMemAllocImpl( MemData& memdata, const QueueMemAlloc& ev )
@@ -7836,9 +7837,17 @@ void Worker::ReadTimeline( FileRead& f, Vector<short_ptr<GpuEvent>>& _vec, uint6
zone->SetCpuEnd( refTime );
zone->SetGpuEnd( refGpuTime );
f.Read( zone->query_id );
f.Read( zone->note_count );
f.Read( zone->note_ids );
f.Read( zone->note_vals );
uint64_t note_count;
f.Read( note_count );
new( &zone->notes ) unordered_flat_map<int64_t, double>();
zone->notes.reserve( note_count );
for( uint64_t i = 0; i < note_count; i++ )
{
int64_t id;
double value;
f.Read2( id, value );
zone->notes[id] = value;
}
}
while( ++zone != end );
}
@@ -8570,9 +8579,12 @@ void Worker::WriteTimelineImpl( FileWrite& f, const V& vec, int64_t& refTime, in
WriteTimeOffset( f, refTime, v.CpuEnd() );
WriteTimeOffset( f, refGpuTime, v.GpuEnd() );
f.Write( &v.query_id, sizeof( v.query_id ) );
f.Write( &v.note_count, sizeof( v.note_count ) );
f.Write( &v.note_ids, sizeof( v.note_ids ) );
f.Write( &v.note_vals, sizeof( v.note_vals ) );
uint64_t note_count = v.notes.size();
f.Write( &note_count, sizeof( note_count ) );
for ( auto& p : v.notes ) {
f.Write( &p.first, sizeof( p.first ) );
f.Write( &p.second, sizeof( p.second ) );
}
}
}