Build reverse CPU topology map.

This commit is contained in:
Bartosz Taudul 2019-11-29 22:46:57 +01:00
parent 712403e9fd
commit db3e802643
2 changed files with 20 additions and 0 deletions

View File

@ -366,6 +366,8 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
uint32_t thread;
f.Read( thread );
core.second.emplace_back( thread );
m_data.cpuTopologyMap.emplace( thread, CpuThreadTopology { packageId, coreId } );
}
}
}
@ -4622,6 +4624,9 @@ void Worker::ProcessCpuTopology( const QueueCpuTopology& ev )
auto core = package->second.find( ev.core );
if( core == package->second.end() ) core = package->second.emplace( ev.core, std::vector<uint32_t> {} ).first;
core->second.emplace_back( ev.thread );
assert( m_data.cpuTopologyMap.find( ev.thread ) == m_data.cpuTopologyMap.end() );
m_data.cpuTopologyMap.emplace( ev.thread, CpuThreadTopology { ev.package, ev.core } );
}
void Worker::MemAllocChanged( int64_t time )
@ -5747,4 +5752,11 @@ void Worker::SetParameter( size_t paramIdx, int32_t val )
Query( ServerQueryParameter, ( idx << 32 ) | val );
}
const Worker::CpuThreadTopology* Worker::GetThreadTopology( uint32_t cpuThread ) const
{
auto it = m_data.cpuTopologyMap.find( cpuThread );
if( it == m_data.cpuTopologyMap.end() ) return nullptr;
return &it->second;
}
}

View File

@ -100,6 +100,12 @@ public:
enum { ZoneThreadDataSize = sizeof( ZoneThreadData ) };
#pragma pack()
struct CpuThreadTopology
{
uint32_t package;
uint32_t core;
};
private:
struct SourceLocationZones
{
@ -230,6 +236,7 @@ private:
#endif
flat_hash_map<uint32_t, flat_hash_map<uint32_t, std::vector<uint32_t>>> cpuTopology;
flat_hash_map<uint32_t, CpuThreadTopology, nohash<uint32_t>> cpuTopologyMap;
};
struct MbpsBlock
@ -425,6 +432,7 @@ public:
void SetParameter( size_t paramIdx, int32_t val );
const decltype(DataBlock::cpuTopology)& GetCpuTopology() const { return m_data.cpuTopology; }
const CpuThreadTopology* GetThreadTopology( uint32_t cpuThread ) const;
private:
void Network();