From 88a153504d5483b2404239477c19e9990bda374b Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 1 Apr 2022 19:06:15 +0200 Subject: [PATCH] Show branch impact if no retirement data available. Some CPUs are only able to report branch miss data, but not branch retirement data. --- server/TracySourceView.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index cc56298b..3e73e48a 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -4416,6 +4416,7 @@ void SourceView::GatherIpHwStats( AddrStatData& as, Worker& worker, const View& void SourceView::CountHwStats( AddrStatData& as, Worker& worker, const View& view ) { + const auto hasBranchRetirement = worker.HasHwBranchRetirement(); auto filename = m_source.filename(); for( auto& v : m_asm ) { @@ -4426,12 +4427,26 @@ void SourceView::CountHwStats( AddrStatData& as, Worker& worker, const View& vie uint64_t branch, cache; if( view.m_statRange.active ) { - branch = sqrt( CountHwSamples( hw->branchMiss, view.m_statRange ) * CountHwSamples( hw->branchRetired, view.m_statRange ) ); + if( hasBranchRetirement ) + { + branch = sqrt( CountHwSamples( hw->branchMiss, view.m_statRange ) * CountHwSamples( hw->branchRetired, view.m_statRange ) ); + } + else + { + branch = CountHwSamples( hw->branchMiss, view.m_statRange ); + } cache = sqrt( CountHwSamples( hw->cacheMiss, view.m_statRange ) * CountHwSamples( hw->cacheRef, view.m_statRange ) ); } else { - branch = sqrt( hw->branchMiss.size() * hw->branchRetired.size() ); + if( hasBranchRetirement ) + { + branch = sqrt( hw->branchMiss.size() * hw->branchRetired.size() ); + } + else + { + branch = hw->branchMiss.size(); + } cache = sqrt( hw->cacheMiss.size() * hw->cacheRef.size() ); } assert( as.hwCountAsm.find( addr ) == as.hwCountAsm.end() );