Introduce SrcLocCountMap

Add to ThreadData a map from source location to a counter,
which will be used to keep track of the number of
appearances of zones with the corresponding source locations
on each thread's stack.
This commit is contained in:
Terence Rokop 2021-06-05 11:06:32 -07:00
parent 0a8ec09566
commit 1f0b4656f4
No known key found for this signature in database
GPG Key ID: FB9F472D903AD4FD
2 changed files with 50 additions and 0 deletions

View File

@ -587,12 +587,57 @@ enum { GhostZoneSize = sizeof( GhostZone ) };
#pragma pack()
using SrcLocCountMap = unordered_flat_map<int16_t, size_t>;
tracy_force_inline void IncSrcLocCount(SrcLocCountMap& countMap, int16_t srcloc)
{
const auto it = countMap.find( srcloc );
if( it == countMap.end() )
{
countMap.emplace( srcloc, 1 );
return;
}
assert( it->second != 0 );
it->second++;
}
tracy_force_inline bool DecSrcLocCount(SrcLocCountMap& countMap, int16_t srcloc)
{
const auto it = countMap.find( srcloc );
assert( it != countMap.end() );
assert( it->second != 0 );
if( it->second == 1 )
{
countMap.erase( it );
return false;
}
it->second--;
return true;
}
tracy_force_inline bool HasSrcLocCount(SrcLocCountMap& countMap, int16_t srcloc)
{
const auto it = countMap.find( srcloc );
if( it != countMap.end() )
{
assert( it->second != 0 );
return true;
}
return false;
}
struct ThreadData
{
uint64_t id;
uint64_t count;
Vector<short_ptr<ZoneEvent>> timeline;
Vector<short_ptr<ZoneEvent>> stack;
SrcLocCountMap stackCount;
Vector<short_ptr<MessageData>> messages;
uint32_t nextZoneId;
Vector<uint32_t> zoneIdStack;
@ -604,6 +649,10 @@ struct ThreadData
Vector<SampleData> samples;
SampleData pendingSample;
uint64_t kernelSampleCnt;
tracy_force_inline void IncStackCount(int16_t srcloc) { IncSrcLocCount( stackCount, srcloc ); }
tracy_force_inline bool DecStackCount(int16_t srcloc) { return DecSrcLocCount( stackCount, srcloc ); }
};
struct GpuCtxThreadData

View File

@ -2006,6 +2006,7 @@ Worker::~Worker()
{
v->timeline.~Vector();
v->stack.~Vector();
v->stackCount.~Table();
v->messages.~Vector();
v->zoneIdStack.~Vector();
v->samples.~Vector();