目录
- 固定cpu频率
- max_ipc_test.sh
固定cpu频率
随笔-处理器微架构-固定cpu频率 - LiYanbin - 博客园
max_ipc_test.sh
#!/bin/bash[[ -z "$1" || -z "$2" ]] && {echo "usage: $0 [cpuid] [nop_count]"exit
}cpuid=$1
nop_count=$2echo 'void main() { do {__asm__ (' > nop.c
for ((i = 1; i <= $nop_count; i++)); do
echo '"nop\n\t"' >> nop.c;
done
echo ');} while(1);}' >> nop.cgcc -O0 nop.c -o nopecho $?
[[ $? -ne 0 ]] && exit -1set -x
[ -f ./nop ] && {perf stat -C $cpuid --timeout 2000 taskset -c $cpuid ./nop
}
set +xrm nop.c
rm nop
$ sudo bash max_ipc_test.sh 7 4
... 12,290,206,450 instructions # 3.97 insn per cycle
...
当nop_count较小,可能因为while(1)
分支指令达不到max ipc,可以增加nop_count来弱化while(1)
分支指令