1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Transfer, display, save CPU topology data.

This commit is contained in:
Bartosz Taudul
2019-11-29 22:41:41 +01:00
parent 5148ecdc50
commit 712403e9fd
7 changed files with 156 additions and 9 deletions
+27 -7
View File
@@ -2450,6 +2450,13 @@ void Profiler::CalibrateDelay()
void Profiler::ReportTopology()
{
struct CpuData
{
uint32_t package;
uint32_t core;
uint32_t thread;
};
#if defined _WIN32 || defined __CYGWIN__
# ifdef UNICODE
t_GetLogicalProcessorInformationEx _GetLogicalProcessorInformationEx = (t_GetLogicalProcessorInformationEx)GetProcAddress( GetModuleHandle( L"kernel32" ), "GetLogicalProcessorInformationEx" );
@@ -2475,13 +2482,6 @@ void Profiler::ReportTopology()
GetSystemInfo( &sysinfo );
const uint32_t numcpus = sysinfo.dwNumberOfProcessors;
struct CpuData
{
uint32_t package;
uint32_t core;
uint32_t thread;
};
auto cpuData = (CpuData*)tracy_malloc( sizeof( CpuData ) * numcpus );
for( uint32_t i=0; i<numcpus; i++ ) cpuData[i].thread = i;
@@ -2521,6 +2521,26 @@ void Profiler::ReportTopology()
idx++;
}
Magic magic;
auto token = GetToken();
for( uint32_t i=0; i<numcpus; i++ )
{
auto& data = cpuData[i];
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin( magic );
MemWrite( &item->hdr.type, QueueType::CpuTopology );
MemWrite( &item->cpuTopology.package, data.package );
MemWrite( &item->cpuTopology.core, data.core );
MemWrite( &item->cpuTopology.thread, data.thread );
#ifdef TRACY_ON_DEMAND
DeferItem( *item );
#endif
tail.store( magic + 1, std::memory_order_release );
}
tracy_free( cpuData );
tracy_free( coreInfo );
tracy_free( packageInfo );