From 0beb1e08b6b1223c2ccec98f8c2a941a029b538d Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 5 Aug 2024 14:49:49 +0200 Subject: [PATCH] add arguments for prepare_instrumentation for BASOP measurements --- scripts/prepare_instrumentation.sh | 121 ++++++++++++++++++----------- 1 file changed, 74 insertions(+), 47 deletions(-) diff --git a/scripts/prepare_instrumentation.sh b/scripts/prepare_instrumentation.sh index d0fa9e41ff..281b4fba87 100755 --- a/scripts/prepare_instrumentation.sh +++ b/scripts/prepare_instrumentation.sh @@ -33,31 +33,48 @@ function usage { echo echo "Usage:" - echo " prepare_instrumentation.sh [MODE]" + echo " $(basename $0) [OPTIONS]" echo - echo " MODE - full (default) or mem_only" + echo " -m MODE one of [FULL|MEM_ONLY]" + echo " -p PROJECT one of [FLOAT|BASOP]" exit } -wmc_opt="" -if [ $# -eq 1 ]; then - mode=$1 - if [ "$mode" = "full" ]; then - wmc_opt="" - elif [ "$mode" = "mem_only" ]; then - wmc_opt="-s" - else - echo "Invalid input for MODE" + +# default values +MODE="FULL" +PROJECT="FLOAT" + +while getopts "m:p:h" OPTIONS; do + case ${OPTIONS} in + m) + MODE=${OPTARG^^} + if [ "$MODE" != "FULL" && "$MODE" != "MEM_ONLY" ]; then + usage + fi + ;; + p) + PROJECT=${OPTARG^^} + if [ "$PROJECT" != "FLOAT" && "$PROJECT" != "BASOP" ]; then + usage + fi + ;; + h | *) usage - exit 1 - fi -elif [ $# -ge 2 ]; then - usage - exit 1 + ;; + esac +done +shift $((OPTIND-1)) + + +wmc_opt="" +if [ "$MODE" = "MEM_ONLY" ]; then + wmc_opt="-s" fi + system=`uname -s` -if [[ ($system == "Linux") && (`uname -a` =~ (microsoft|Microsoft|wsl|WSL) ) ]]; then +if [[ ($system = "Linux") && (`uname -a` =~ (microsoft|Microsoft|wsl|WSL) ) ]]; then system="Linux" fi @@ -98,32 +115,35 @@ cp -R ../Workspace_msvc $targetdir rm -f $ifdef_list touch $ifdef_list -# Add LC3plus feature defines to options.h so that they are stripped correctly -# Generate list of active defines in LC3plus defines.h -lc3plus_defines=$( - gcc -E -dM $targetdir/lib_lc3plus/defines.h -I $targetdir/lib_com -I $targetdir/lib_debug | - sed '/^#define [[:alnum:]][[:alnum:]_]\+[[:space:]]*$/! d' | - sed '/#define DEFINES_H/ d' -) - -# Filter defines that come from outside of the header lib_lc3plus/defines.h -lc3plus_defines_filtered="" -while IFS=' \n' read -r line; -do - line=`echo $line | tr -d '\n'` - if grep -wqF "$line" "$targetdir/lib_lc3plus/defines.h"; then - lc3plus_defines_filtered+=$line$'\n' - fi -done <<< $lc3plus_defines - -# Append LC3plus defines to options.h -echo " -/* LC3plus switches */ -#ifndef OPTIONS_H_LC3_DEFINES -#define OPTIONS_H_LC3_DEFINES -$lc3plus_defines_filtered -#endif /* OPTIONS_H_LC3_DEFINES */ -" >>$targetdir/lib_com/options.h +# LC3plus-related stuff -> only in float code +if [ "$PROJECT" = "FLOAT" ]; then + # Add LC3plus feature defines to options.h so that they are stripped correctly + # Generate list of active defines in LC3plus defines.h + lc3plus_defines=$( + gcc -E -dM $targetdir/lib_lc3plus/defines.h -I $targetdir/lib_com -I $targetdir/lib_debug | + sed '/^#define [[:alnum:]][[:alnum:]_]\+[[:space:]]*$/! d' | + sed '/#define DEFINES_H/ d' + ) + + # Filter defines that come from outside of the header lib_lc3plus/defines.h + lc3plus_defines_filtered="" + while IFS=' \n' read -r line; + do + line=`echo $line | tr -d '\n'` + if grep -wqF "$line" "$targetdir/lib_lc3plus/defines.h"; then + lc3plus_defines_filtered+=$line$'\n' + fi + done <<< $lc3plus_defines + + # Append LC3plus defines to options.h + echo " + /* LC3plus switches */ + #ifndef OPTIONS_H_LC3_DEFINES + #define OPTIONS_H_LC3_DEFINES + $lc3plus_defines_filtered + #endif /* OPTIONS_H_LC3_DEFINES */ + " >>$targetdir/lib_com/options.h +fi # get switches from options.h and append it to $ifdef_list parse_options_opt="" @@ -147,8 +167,10 @@ if coan_exists; then coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/lib_{com,dec,enc,isar,rend,util,debug}/!(wmc_auto*).[hc] coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/apps/*.[hc] - coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/lib_lc3plus/!(wmc_auto*).[hc] - coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/lib_lc3plus/fft/!(wmc_auto*).[hc] + if [ "$PROJECT" = "FLOAT" ]; then + coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/lib_lc3plus/!(wmc_auto*).[hc] + coan source --replace --no-transients -E -K --file $ifdef_list $targetdir/lib_lc3plus/fft/!(wmc_auto*).[hc] + fi else ./strip_defines_cppp.sh $targetdir $ifdef_list fi @@ -160,8 +182,13 @@ find $targetdir -name "*.[ch]" -exec sed -i.bak -e "s/\(0x[0-9a-fA-F]*\)UL/\(\(u # run wmc_tool "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/encoder.c" "$targetdir/lib_enc/*.c" "$targetdir/lib_com/*.c" >> /dev/null "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/decoder.c" "$targetdir/lib_dec/*.c" "$targetdir/lib_rend/*.c" >> /dev/null -"tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" "$targetdir/lib_lc3plus/*.c" "$targetdir/lib_lc3plus/fft/*.c" >> /dev/null -"tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/isar_post_rend.c" "$targetdir/lib_isar/*.c" "$targetdir/lib_lc3plus/*.c" "$targetdir/lib_lc3plus/fft/*.c" >> /dev/null +# ISAR post-renderer and lc3plus sources only need to be instrumented in float code +if [ "$PROJECT" = "FLOAT" ]; then + "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" "$targetdir/lib_lc3plus/*.c" "$targetdir/lib_lc3plus/fft/*.c" >> /dev/null + "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/isar_post_rend.c" "$targetdir/lib_isar/*.c" "$targetdir/lib_lc3plus/*.c" "$targetdir/lib_lc3plus/fft/*.c" >> /dev/null +else + "tools/$system/wmc_tool" $wmc_opt -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" >> /dev/null +fi # automatically enable #define WMOPS in options.h sed -i.bak -e "s/\/\*[[:space:]]*\(#define[[:space:]]*WMOPS\)[[:space:]]*\*\//\1/g" $targetdir/lib_com/options.h -- GitLab