1 Star 0 Fork 2

sunlock0653/shell_opt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Mon_MemBWCollect.sh 3.26 KB
一键复制 编辑 原始数据 按行查看 历史
sunlock0653 提交于 2024-11-20 17:12 . at zj
#! /bin/bash
# ڴؽű
function perf_Mem_bw () {
if dmidecode -t processor | grep -qE 'Kunpeng|1620' ;then
CPU0_Die0_BW_R="hisi_sccl1_ddrc0/flux_rd/,hisi_sccl1_ddrc1/flux_rd/,hisi_sccl1_ddrc2/flux_rd/,hisi_sccl1_ddrc3/flux_rd/"
CPU0_Die0_BW_W="hisi_sccl1_ddrc0/flux_wr/,hisi_sccl1_ddrc1/flux_wr/,hisi_sccl1_ddrc2/flux_wr/,hisi_sccl1_ddrc3/flux_wr/"
CPU0_Die1_BW_R="hisi_sccl3_ddrc0/flux_rd/,hisi_sccl3_ddrc1/flux_rd/,hisi_sccl3_ddrc2/flux_rd/,hisi_sccl3_ddrc3/flux_rd/"
CPU0_Die1_BW_W="hisi_sccl3_ddrc0/flux_wr/,hisi_sccl3_ddrc1/flux_wr/,hisi_sccl3_ddrc2/flux_wr/,hisi_sccl3_ddrc3/flux_wr/"
CPU1_Die0_BW_R="hisi_sccl5_ddrc0/flux_rd/,hisi_sccl5_ddrc1/flux_rd/,hisi_sccl5_ddrc2/flux_rd/,hisi_sccl5_ddrc3/flux_rd/"
CPU1_Die0_BW_W="hisi_sccl5_ddrc0/flux_wr/,hisi_sccl5_ddrc1/flux_wr/,hisi_sccl5_ddrc2/flux_wr/,hisi_sccl5_ddrc3/flux_wr/"
CPU1_Die1_BW_R="hisi_sccl7_ddrc0/flux_rd/,hisi_sccl7_ddrc1/flux_rd/,hisi_sccl7_ddrc2/flux_rd/,hisi_sccl7_ddrc3/flux_rd/"
CPU1_Die1_BW_W="hisi_sccl7_ddrc0/flux_wr/,hisi_sccl7_ddrc1/flux_wr/,hisi_sccl7_ddrc2/flux_wr/,hisi_sccl7_ddrc3/flux_wr/"
ifdie1=`perf list|grep hisi_sccl1_ddrc0`
if [ -z "$ifdie1" ]
then
BW_Events="$CPU0_Die1_BW_R,$CPU0_Die1_BW_W,$CPU1_Die1_BW_R,$CPU1_Die1_BW_W"
else
BW_Events="$CPU0_Die0_BW_R,$CPU0_Die0_BW_W,$CPU0_Die1_BW_R,$CPU0_Die1_BW_W,$CPU1_Die0_BW_R,$CPU1_Die0_BW_W,$CPU1_Die1_BW_R,$CPU1_Die1_BW_W"
fi
else
echo "not support"
exit
fi
let interval=1000;
timeout $1 perf stat -x ',' -a -I $interval -e $BW_Events 2>&1| \
awk -F, '
BEGIN {
tpre=-1;
first=1;
}
{
idx_failed = index($0, "failed")
if (idx_failed > 0)
{
printf("failed\n");
}
else {
tcurr=$1;
if(first==1)
{
tpre=tcurr;
first=0;
}
if (tcurr!=tpre)
{
printf("cpu0_Die0:%8.2f MB|cpu0_Die1:%8.2f MB|cpu1_Die0:%8.2f MB|cpu1_Die1:%8.2f MB\n",(CPU0_Die0_R+CPU0_Die0_W)*32/1024/1024,(CPU0_Die1_R+CPU0_Die1_W)*32/1024/1024,(CPU1_Die0_R+CPU1_Die0_W)*32/1024/1024,(CPU1_Die1_R+CPU1_Die1_W)*32/1024/1024);
CPU0_Die0_R=0;
CPU0_Die0_W=0;
CPU0_Die1_R=0;
CPU0_Die1_W=0;
CPU1_Die0_R=0;
CPU1_Die0_W=0;
CPU1_Die1_R=0;
CPU1_Die1_W=0;
tpre=tcurr;
}
switch ($4)
{
case /sccl1.*rd/:
CPU0_Die0_R += $2;
break;
case /sccl1.*wr/:
CPU0_Die0_W += $2;
break;
case /sccl3.*rd/:
CPU0_Die1_R += $2;
break;
case /sccl3.*wr/:
CPU0_Die1_W += $2;
break;
case /sccl5.*rd/:
CPU1_Die0_R += $2;
break;
case /sccl5.*wr/:
CPU1_Die0_W += $2;
break;
case /sccl7.*rd/:
CPU1_Die1_R += $2;
break;
case /sccl7.*wr/:
CPU1_Die1_W += $2;
break;
}
}
}
'
}
perf_Mem_bw 100
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/sunlock0653/shell_opts.git
[email protected]:sunlock0653/shell_opts.git
sunlock0653
shell_opts
shell_opt
master

搜索帮助