Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions tools/metric_frontend_bound
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

# Copyright (C) 2018 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
# OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
# OR OTHER DEALINGS IN THE SOFTWARE.
#
# SPDX-License-Identifier: MIT

SCRIPTS_DIR=`dirname $0`
source ${SCRIPTS_DIR}/utils.sh

function init_frontend_bound() {
Copy link
Contributor

@catalin-manciu catalin-manciu Nov 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this useful/used?
Also, I think it can be reduced to the following, due to the fact that the array is already hardcoded there and there's nothing preventing us from hardcoding it as a string (we could even drop the variable declaration, though it makes the code slightly more readable):

function init_frontend_bound() {
  local local_pmus="cpu_clk_unhalted.thread_any,idq_uops_not_delivered.core"
  echo $local_pmus
}

local local_pmu_array=(cpu_clk_unhalted.thread_any idq_uops_not_delivered.core)
local local_pmus
for item in ${local_pmu_array[*]}
do
if [ "x${local_pmus}" == "x" ]; then
local_pmus="$item"
else
local_pmus="$local_pmus,$item"
fi
done
echo $local_pmus
}

function calc_frontend_bound() {
local perf_data_file="$1"
local metric_name="metric_frontend_bound>"
echo
echo "================================================="
echo "Final ${metric_name}"
echo "--------------------------------------------------"
echo "FORMULA: ${metric_name} = 100*b/(4*(a/threads))"
echo " where, a=cpu_clk_unhalted.thread_any"
echo " b=idq_uops_not_delivered.core"
echo "================================================="

local a=`return_pmu_value "cpu_clk_unhalted.thread_any" $perf_data_file `
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space after $perf_data_file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @uttampawar for the PR.

Here are some comments:

FE BOUND = IDQ_UOPS_NOT_DELIVERED.CORE / SLOTS
SLOTS = #Pipeline_Width  * CORE_CLKS
CORE_CLKS = CPU_CLK_UNHALTED.THREAD
  • In future we want to add some checks about the architecture. Some other formulas work only on Skylake and beyond. This one is fine.

--

I realize it yesterday while working on this script. This needs to be addressed for sure one for getting up to date architecture information, exact counter names and formulas to getting various metrics.

local b=`return_pmu_value "idq_uops_not_delivered.core" $perf_data_file`
local threads=2 #with HT on there are 2 threads per core

if [ $a == -1 -o $b == -1 ]; then
echo "ERROR: ${metric_name} can't be derived. Missing pmus"
else
local metric=`echo "scale=$bc_scale;100*${b}/(4*(${a}/${threads}))"| bc -l`
echo "${metric_name}=${metric}"
fi
echo
}