diff options
author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-06-01 14:35:21 +0000 |
---|---|---|
committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-06-01 14:35:21 +0000 |
commit | bdc670611b5c204703b06812aacf23278a1c3da5 (patch) | |
tree | a42c064db546f02a394eb04583840ff3aa91c548 /llvm/tools/llvm-mca/Support.cpp | |
parent | 9796b47df1a2dd2a0f16dff7752d8bbd8e52533e (diff) | |
download | bcm5719-llvm-bdc670611b5c204703b06812aacf23278a1c3da5.tar.gz bcm5719-llvm-bdc670611b5c204703b06812aacf23278a1c3da5.zip |
[llvm-mca] Move the logic that computes the block throughput into Support.h. NFC
This will allow us to share the logic that computes the block throughput with
other views.
llvm-svn: 333755
Diffstat (limited to 'llvm/tools/llvm-mca/Support.cpp')
-rw-r--r-- | llvm/tools/llvm-mca/Support.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/tools/llvm-mca/Support.cpp b/llvm/tools/llvm-mca/Support.cpp index e97cc51430d..fac237f740d 100644 --- a/llvm/tools/llvm-mca/Support.cpp +++ b/llvm/tools/llvm-mca/Support.cpp @@ -48,4 +48,32 @@ void computeProcResourceMasks(const MCSchedModel &SM, ProcResourceID++; } } + +double computeBlockRThroughput(const MCSchedModel &SM, unsigned DispatchWidth, + unsigned NumMicroOps, + ArrayRef<unsigned> ProcResourceUsage) { + // The block throughput is bounded from above by the hardware dispatch + // throughput. That is because the DispatchWidth is an upper bound on the + // number of opcodes that can be part of a single dispatch group. + double Max = static_cast<double>(NumMicroOps) / DispatchWidth; + + // The block throughput is also limited by the amount of hardware parallelism. + // The number of available resource units affects the resource pressure + // distribution, as well as how many blocks can be executed every cycle. + for (unsigned I = 0, E = SM.getNumProcResourceKinds(); I < E; ++I) { + unsigned ResourceCycles = ProcResourceUsage[I]; + if (!ResourceCycles) + continue; + + const MCProcResourceDesc &MCDesc = *SM.getProcResource(I); + double Throughput = static_cast<double>(ResourceCycles) / MCDesc.NumUnits; + Max = std::max(Max, Throughput); + } + + // The block reciprocal throughput is computed as the MAX of: + // - (NumMicroOps / DispatchWidth) + // - (NumUnits / ResourceCycles) for every consumed processor resource. + return Max; +} + } // namespace mca |