mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Add die to CPU topology data structures.
Drawing dies on the topology chart is a minimal effort for the time being. An improved version will be added later on.
This commit is contained in:
parent
e947aeb72d
commit
357b557684
@ -704,6 +704,7 @@ void View::DrawInfo()
|
|||||||
std::vector<int> maxthreads( topology.size() );
|
std::vector<int> maxthreads( topology.size() );
|
||||||
|
|
||||||
float ptsz = 0;
|
float ptsz = 0;
|
||||||
|
float dtsz = 0;
|
||||||
float ctsz = 0;
|
float ctsz = 0;
|
||||||
float ttsz = 0;
|
float ttsz = 0;
|
||||||
for( auto& package : topology )
|
for( auto& package : topology )
|
||||||
@ -715,20 +716,27 @@ void View::DrawInfo()
|
|||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
|
|
||||||
size_t mt = 0;
|
size_t mt = 0;
|
||||||
for( auto& core : package.second )
|
for( auto& die : package.second )
|
||||||
{
|
{
|
||||||
sprintf( buf, ICON_FA_MICROCHIP "%" PRIu32, core.first );
|
sprintf( buf, ICON_FA_DICE_D6 " Die %" PRIu32, die.first );
|
||||||
const auto csz = ImGui::CalcTextSize( buf ).x;
|
const auto dsz = ImGui::CalcTextSize( buf ).x;
|
||||||
if( csz > ctsz ) ctsz = csz;
|
if( dsz > dtsz ) dtsz = dsz;
|
||||||
|
|
||||||
const auto tnum = core.second.size();
|
for( auto& core : die.second )
|
||||||
if( tnum > mt ) mt = tnum;
|
|
||||||
|
|
||||||
for( auto& thread : core.second )
|
|
||||||
{
|
{
|
||||||
sprintf( buf, ICON_FA_SHUFFLE "%" PRIu32, thread );
|
sprintf( buf, ICON_FA_MICROCHIP "%" PRIu32, core.first );
|
||||||
const auto tsz = ImGui::CalcTextSize( buf ).x;
|
const auto csz = ImGui::CalcTextSize( buf ).x;
|
||||||
if( tsz > ttsz ) ttsz = tsz;
|
if( csz > ctsz ) ctsz = csz;
|
||||||
|
|
||||||
|
const auto tnum = core.second.size();
|
||||||
|
if( tnum > mt ) mt = tnum;
|
||||||
|
|
||||||
|
for( auto& thread : core.second )
|
||||||
|
{
|
||||||
|
sprintf( buf, ICON_FA_SHUFFLE "%" PRIu32, thread );
|
||||||
|
const auto tsz = ImGui::CalcTextSize( buf ).x;
|
||||||
|
if( tsz > ttsz ) ttsz = tsz;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
maxthreads[package.first] = (int)mt;
|
maxthreads[package.first] = (int)mt;
|
||||||
@ -752,48 +760,60 @@ void View::DrawInfo()
|
|||||||
draw->AddText( dpos, 0xFFFFFFFF, buf );
|
draw->AddText( dpos, 0xFFFFFFFF, buf );
|
||||||
dpos.y += ty;
|
dpos.y += ty;
|
||||||
|
|
||||||
const auto inCoreWidth = ( ttsz + margin ) * maxthreads[package->first];
|
std::vector<decltype(package->second.begin())> dsort;
|
||||||
const auto coreWidth = inCoreWidth + 2 * margin;
|
dsort.reserve( package->second.size() );
|
||||||
const auto inCoreHeight = margin + 2 * small + ty;
|
for( auto it = package->second.begin(); it != package->second.end(); ++it ) dsort.emplace_back( it );
|
||||||
const auto coreHeight = inCoreHeight + ty;
|
std::sort( dsort.begin(), dsort.end(), [] ( const auto& l, const auto& r ) { return l->first < r->first; } );
|
||||||
const auto cpl = std::max( 1, (int)floor( ( remainingWidth - 2 * margin ) / coreWidth ) );
|
for( auto& die : dsort )
|
||||||
const auto cl = ( package->second.size() + cpl - 1 ) / cpl;
|
|
||||||
const auto pw = cpl * coreWidth + 2 * margin;
|
|
||||||
const auto ph = margin + cl * coreHeight;
|
|
||||||
if( pw > width ) width = pw;
|
|
||||||
|
|
||||||
draw->AddRect( dpos, dpos + ImVec2( margin + coreWidth * std::min<size_t>( cpl, package->second.size() ), ph ), 0xFFFFFFFF );
|
|
||||||
|
|
||||||
std::vector<decltype(package->second.begin())> csort;
|
|
||||||
csort.reserve( package->second.size() );
|
|
||||||
for( auto it = package->second.begin(); it != package->second.end(); ++it ) csort.emplace_back( it );
|
|
||||||
std::sort( csort.begin(), csort.end(), [] ( const auto& l, const auto& r ) { return l->first < r->first; } );
|
|
||||||
auto cpos = dpos + ImVec2( margin, margin );
|
|
||||||
int ll = cpl;
|
|
||||||
for( auto& core : csort )
|
|
||||||
{
|
{
|
||||||
sprintf( buf, ICON_FA_MICROCHIP "%" PRIu32, core->first );
|
dpos.y += small;
|
||||||
draw->AddText( cpos, 0xFFFFFFFF, buf );
|
sprintf( buf, ICON_FA_DICE_D6 " Die %" PRIu32, die->first );
|
||||||
draw->AddRect( cpos + ImVec2( 0, ty ), cpos + ImVec2( inCoreWidth + small, inCoreHeight + small ), 0xFFFFFFFF );
|
draw->AddText( dpos, 0xFFFFFFFF, buf );
|
||||||
|
dpos.y += ty;
|
||||||
|
|
||||||
for( int i=0; i<core->second.size(); i++ )
|
const auto inCoreWidth = ( ttsz + margin ) * maxthreads[package->first];
|
||||||
{
|
const auto coreWidth = inCoreWidth + 2 * margin;
|
||||||
sprintf( buf, ICON_FA_SHUFFLE "%" PRIu32, core->second[i] );
|
const auto inCoreHeight = margin + 2 * small + ty;
|
||||||
draw->AddText( cpos + ImVec2( margin + i * ( margin + ttsz ), ty + small ), 0xFFFFFFFF, buf );
|
const auto coreHeight = inCoreHeight + ty;
|
||||||
}
|
const auto cpl = std::max( 1, (int)floor( ( remainingWidth - 2 * margin ) / coreWidth ) );
|
||||||
|
const auto cl = ( die->second.size() + cpl - 1 ) / cpl;
|
||||||
|
const auto pw = cpl * coreWidth + 2 * margin;
|
||||||
|
const auto ph = margin + cl * coreHeight;
|
||||||
|
if( pw > width ) width = pw;
|
||||||
|
|
||||||
if( --ll == 0 )
|
draw->AddRect( dpos, dpos + ImVec2( margin + coreWidth * std::min<size_t>( cpl, die->second.size() ), ph ), 0xFFFFFFFF );
|
||||||
|
|
||||||
|
std::vector<decltype(die->second.begin())> csort;
|
||||||
|
csort.reserve( die->second.size() );
|
||||||
|
for( auto it = die->second.begin(); it != die->second.end(); ++it ) csort.emplace_back( it );
|
||||||
|
std::sort( csort.begin(), csort.end(), [] ( const auto& l, const auto& r ) { return l->first < r->first; } );
|
||||||
|
auto cpos = dpos + ImVec2( margin, margin );
|
||||||
|
int ll = cpl;
|
||||||
|
for( auto& core : csort )
|
||||||
{
|
{
|
||||||
ll = cpl;
|
sprintf( buf, ICON_FA_MICROCHIP "%" PRIu32, core->first );
|
||||||
cpos.x -= (cpl-1) * coreWidth;
|
draw->AddText( cpos, 0xFFFFFFFF, buf );
|
||||||
cpos.y += coreHeight;
|
draw->AddRect( cpos + ImVec2( 0, ty ), cpos + ImVec2( inCoreWidth + small, inCoreHeight + small ), 0xFFFFFFFF );
|
||||||
}
|
|
||||||
else
|
for( int i=0; i<core->second.size(); i++ )
|
||||||
{
|
{
|
||||||
cpos.x += coreWidth;
|
sprintf( buf, ICON_FA_SHUFFLE "%" PRIu32, core->second[i] );
|
||||||
|
draw->AddText( cpos + ImVec2( margin + i * ( margin + ttsz ), ty + small ), 0xFFFFFFFF, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( --ll == 0 )
|
||||||
|
{
|
||||||
|
ll = cpl;
|
||||||
|
cpos.x -= (cpl-1) * coreWidth;
|
||||||
|
cpos.y += coreHeight;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cpos.x += coreWidth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
dpos.y += ph;
|
||||||
}
|
}
|
||||||
dpos.y += ph;
|
|
||||||
}
|
}
|
||||||
ImGui::ItemSize( ImVec2( width, dpos.y - origy ) );
|
ImGui::ItemSize( ImVec2( width, dpos.y - origy ) );
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
|
@ -7,7 +7,7 @@ namespace Version
|
|||||||
{
|
{
|
||||||
enum { Major = 0 };
|
enum { Major = 0 };
|
||||||
enum { Minor = 11 };
|
enum { Minor = 11 };
|
||||||
enum { Patch = 1 };
|
enum { Patch = 2 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,22 +643,50 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks, bool allow
|
|||||||
uint32_t packageId;
|
uint32_t packageId;
|
||||||
uint64_t psz;
|
uint64_t psz;
|
||||||
f.Read2( packageId, psz );
|
f.Read2( packageId, psz );
|
||||||
auto& package = *m_data.cpuTopology.emplace( packageId, unordered_flat_map<uint32_t, std::vector<uint32_t>> {} ).first;
|
auto& package = *m_data.cpuTopology.emplace( packageId, unordered_flat_map<uint32_t, unordered_flat_map<uint32_t, std::vector<uint32_t>>> {} ).first;
|
||||||
package.second.reserve( psz );
|
package.second.reserve( psz );
|
||||||
for( uint64_t j=0; j<psz; j++ )
|
for( uint64_t j=0; j<psz; j++ )
|
||||||
{
|
{
|
||||||
uint32_t coreId;
|
if( fileVer >= FileVersion( 0, 11, 2 ) )
|
||||||
uint64_t csz;
|
|
||||||
f.Read2( coreId, csz );
|
|
||||||
auto& core = *package.second.emplace( coreId, std::vector<uint32_t> {} ).first;
|
|
||||||
core.second.reserve( csz );
|
|
||||||
for( uint64_t k=0; k<csz; k++ )
|
|
||||||
{
|
{
|
||||||
uint32_t thread;
|
uint32_t dieId;
|
||||||
f.Read( thread );
|
uint64_t dsz;
|
||||||
core.second.emplace_back( thread );
|
f.Read2( dieId, dsz );
|
||||||
|
auto& die = *package.second.emplace( dieId, unordered_flat_map<uint32_t, std::vector<uint32_t>> {} ).first;
|
||||||
|
die.second.reserve( dsz );
|
||||||
|
for( uint64_t k=0; k<dsz; k++ )
|
||||||
|
{
|
||||||
|
uint32_t coreId;
|
||||||
|
uint64_t csz;
|
||||||
|
f.Read2( coreId, csz );
|
||||||
|
auto& core = *die.second.emplace( coreId, std::vector<uint32_t> {} ).first;
|
||||||
|
core.second.reserve( csz );
|
||||||
|
for( uint64_t l=0; l<csz; l++ )
|
||||||
|
{
|
||||||
|
uint32_t thread;
|
||||||
|
f.Read( thread );
|
||||||
|
core.second.emplace_back( thread );
|
||||||
|
|
||||||
m_data.cpuTopologyMap.emplace( thread, CpuThreadTopology { packageId, coreId } );
|
m_data.cpuTopologyMap.emplace( thread, CpuThreadTopology { packageId, coreId } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto& die = *package.second.emplace( 0, unordered_flat_map<uint32_t, std::vector<uint32_t>> {} ).first;
|
||||||
|
uint32_t coreId;
|
||||||
|
uint64_t csz;
|
||||||
|
f.Read2( coreId, csz );
|
||||||
|
auto& core = *die.second.emplace( coreId, std::vector<uint32_t> {} ).first;
|
||||||
|
core.second.reserve( csz );
|
||||||
|
for( uint64_t k=0; k<csz; k++ )
|
||||||
|
{
|
||||||
|
uint32_t thread;
|
||||||
|
f.Read( thread );
|
||||||
|
core.second.emplace_back( thread );
|
||||||
|
|
||||||
|
m_data.cpuTopologyMap.emplace( thread, CpuThreadTopology { packageId, coreId } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6859,9 +6887,13 @@ void Worker::ProcessSourceCodeNotAvailable( const QueueSourceCodeNotAvailable& e
|
|||||||
void Worker::ProcessCpuTopology( const QueueCpuTopology& ev )
|
void Worker::ProcessCpuTopology( const QueueCpuTopology& ev )
|
||||||
{
|
{
|
||||||
auto package = m_data.cpuTopology.find( ev.package );
|
auto package = m_data.cpuTopology.find( ev.package );
|
||||||
if( package == m_data.cpuTopology.end() ) package = m_data.cpuTopology.emplace( ev.package, unordered_flat_map<uint32_t, std::vector<uint32_t>> {} ).first;
|
if( package == m_data.cpuTopology.end() ) package = m_data.cpuTopology.emplace( ev.package, unordered_flat_map<uint32_t, unordered_flat_map<uint32_t, std::vector<uint32_t>>> {} ).first;
|
||||||
auto core = package->second.find( ev.core );
|
|
||||||
if( core == package->second.end() ) core = package->second.emplace( ev.core, std::vector<uint32_t> {} ).first;
|
auto die = package->second.find( ev.die );
|
||||||
|
if( die == package->second.end() ) die = package->second.emplace( ev.die, unordered_flat_map<uint32_t, std::vector<uint32_t>> {} ).first;
|
||||||
|
|
||||||
|
auto core = die->second.find( ev.core );
|
||||||
|
if( core == die->second.end() ) core = die->second.emplace( ev.core, std::vector<uint32_t> {} ).first;
|
||||||
core->second.emplace_back( ev.thread );
|
core->second.emplace_back( ev.thread );
|
||||||
|
|
||||||
assert( m_data.cpuTopologyMap.find( ev.thread ) == m_data.cpuTopologyMap.end() );
|
assert( m_data.cpuTopologyMap.find( ev.thread ) == m_data.cpuTopologyMap.end() );
|
||||||
@ -7699,14 +7731,20 @@ void Worker::Write( FileWrite& f, bool fiDict )
|
|||||||
sz = package.second.size();
|
sz = package.second.size();
|
||||||
f.Write( &package.first, sizeof( package.first ) );
|
f.Write( &package.first, sizeof( package.first ) );
|
||||||
f.Write( &sz, sizeof( sz ) );
|
f.Write( &sz, sizeof( sz ) );
|
||||||
for( auto& core : package.second )
|
for( auto& die : package.second )
|
||||||
{
|
{
|
||||||
sz = core.second.size();
|
sz = die.second.size();
|
||||||
f.Write( &core.first, sizeof( core.first ) );
|
f.Write( &die.first, sizeof( die.first ) );
|
||||||
f.Write( &sz, sizeof( sz ) );
|
f.Write( &sz, sizeof( sz ) );
|
||||||
for( auto& thread : core.second )
|
for( auto& core : die.second )
|
||||||
{
|
{
|
||||||
f.Write( &thread, sizeof( thread ) );
|
sz = core.second.size();
|
||||||
|
f.Write( &core.first, sizeof( core.first ) );
|
||||||
|
f.Write( &sz, sizeof( sz ) );
|
||||||
|
for( auto& thread : core.second )
|
||||||
|
{
|
||||||
|
f.Write( &thread, sizeof( thread ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ private:
|
|||||||
bool ctxUsageReady = false;
|
bool ctxUsageReady = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unordered_flat_map<uint32_t, unordered_flat_map<uint32_t, std::vector<uint32_t>>> cpuTopology;
|
unordered_flat_map<uint32_t, unordered_flat_map<uint32_t, unordered_flat_map<uint32_t, std::vector<uint32_t>>>> cpuTopology;
|
||||||
unordered_flat_map<uint32_t, CpuThreadTopology> cpuTopologyMap;
|
unordered_flat_map<uint32_t, CpuThreadTopology> cpuTopologyMap;
|
||||||
|
|
||||||
unordered_flat_map<uint64_t, MemoryBlock> symbolCode;
|
unordered_flat_map<uint64_t, MemoryBlock> symbolCode;
|
||||||
|
Loading…
Reference in New Issue
Block a user