filter output option

This commit is contained in:
Andreas Abel
2022-01-20 16:27:58 +01:00
parent 15b1ccb275
commit 0ef60f2a59
3 changed files with 23 additions and 16 deletions

View File

@@ -152,6 +152,7 @@ Both `nanoBench.sh` and `kernel-nanoBench.sh` support the following command-line
| `-basic_mode` | The effect of this option is described in the [Generated Code](#generated-code) section. |
| `-no_mem` | If this option is enabled, the code for `read_perf_ctrs` does not make any memory accesses and stores all performance counter values in registers. This can, for example, be useful for benchmarks that require that the state of the data caches does not change after the execution of `code_init`. *If this option is used, the code to be benchmarked must not modify registers* ***R8-R11 (Intel)*** *and* ***R8-R13 (AMD).*** *Furthermore, `read_perf_ctrs` will modify* ***RAX, RCX, and RDX***. |
| `-no_normalization` | If this option is enabled, the measurement results are not divided by the number of repetitions. |
| `-remove_empty_events` | If this option is enabled, the output does not contain events that did not occur. |
| `-df` | If this option is enabled, the front-end buffers are drained after `code_init`, after `code_late_init`, and after the last instance of `code` by executing an lfence, followed by a long sequence of 1-Byte `NOP` instructions, followed by a long sequence of 15-Byte `NOP` instructions. |
| `-cpu <n>` | Pins the measurement thread to CPU n. `[Default: Pin the thread to the CPU it is currently running on.]` |
| `-verbose` | Outputs the results of all performance counter readings. In the user-space version, the results are printed to stdout. The output of the kernel module can be accessed using `dmesg`. |

View File

@@ -21,6 +21,7 @@ fi
cat /sys/nb/reset
taskset=""
filter_output="cat"
while [ "$1" ]; do
if [[ "$1" == -asm_i* ]]; then
@@ -109,6 +110,9 @@ while [ "$1" ]; do
elif [[ "$1" == -avg* ]]; then
echo "avg" > /sys/nb/agg
shift
elif [[ "$1" == -r* ]]; then
filter_output="grep -v 0.00"
shift
elif [[ "$1" == -h* ]]; then
echo "kernel-nanoBench.sh usage:"
echo
@@ -134,6 +138,7 @@ while [ "$1" ]; do
echo " -basic_mode: Enables basic mode."
echo " -no_mem: The code for reading the perf. ctrs. does not make memory accesses."
echo " -no_normalization: The measurement results are not divided by the number of repetitions."
echo " -remove_empty_events: Removes events from the output that did not occur."
echo " -cpu <n>: Pins the measurement thread to CPU n."
echo " -verbose: Outputs the results of all performance counter readings."
exit 0
@@ -146,6 +151,9 @@ done
prev_nmi_watchdog=$(cat /proc/sys/kernel/nmi_watchdog)
[ $prev_nmi_watchdog != 0 ] && echo 0 > /proc/sys/kernel/nmi_watchdog
$taskset cat /proc/nanoBench
$taskset cat /proc/nanoBench | $filter_output
return_value=${PIPESTATUS[0]}
[ $prev_nmi_watchdog != 0 ] && echo $prev_nmi_watchdog > /proc/sys/kernel/nmi_watchdog
exit $return_value

View File

@@ -18,15 +18,11 @@ if [ $(cat /sys/devices/system/cpu/smt/active) -ne 0 ]; then
echo "Note: Hyper-threading is enabled; it can be disabled with \"sudo ./disable-HT.sh\"" >&2
fi
debug=false
for p in "$@"; do
if [[ "$p" == -de* ]]; then
debug=true
fi
done
debug=""
filter_output="cat"
args=''
while [ "$2" ]; do
while [ "$1" ]; do
if [[ "$1" == -asm_i* ]]; then
assemble "$2" asm-init.bin
args="$args -code_init asm-init.bin"
@@ -43,12 +39,18 @@ while [ "$2" ]; do
assemble "$2" asm-code.bin
args="$args -code asm-code.bin"
shift 2
elif [[ "$1" == -de* ]]; then
debug="gdb -ex=run --args"
args="$args $1"
shift
elif [[ "$1" == -r* ]]; then
filter_output="grep -v 0.00"
shift
else
args="$args $1"
shift
fi
done
args="$args $1"
set "$args"
if [ -d "/sys/bus/event_source/devices/cpu" ]; then
@@ -74,13 +76,8 @@ iTCO_vendor_support_prev_loaded=$?
prev_nmi_watchdog=$(cat /proc/sys/kernel/nmi_watchdog)
[ $prev_nmi_watchdog != 0 ] && echo 0 > /proc/sys/kernel/nmi_watchdog
if [ "$debug" = true ]; then
gdb -ex=run --args user/nanoBench $@
return_value=$?
else
user/nanoBench $@
return_value=$?
fi
$debug user/nanoBench $@ | $filter_output
return_value=${PIPESTATUS[0]}
rm -f asm-*.bin
@@ -104,4 +101,5 @@ fi
if [[ $iTCO_vendor_support_prev_loaded != 0 ]]; then
modprobe iTCO_vendor_support &>/dev/null
fi
exit $return_value