From 4a39566801dcdc475c20d9ece2ca26399629d8c2 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 2 Aug 2024 15:29:29 +0200 Subject: [PATCH 1/6] add argument to instr script for passing "-s" to wmc_tool --- scripts/prepare_instrumentation.sh | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/prepare_instrumentation.sh b/scripts/prepare_instrumentation.sh index 08c595b35c..8f3fd76938 100755 --- a/scripts/prepare_instrumentation.sh +++ b/scripts/prepare_instrumentation.sh @@ -35,12 +35,28 @@ function usage { echo "Usage:" echo " prepare_instrumentation.sh [MODE]" echo - echo " MODE - sr_off (default) or sr_on" + echo " MODE - full (default) or mem_only" exit } INCLUDE_SPLIT=1 +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" + usage + exit 1 + fi +elif [ $# -ge 2 ]; then + usage + exit 1 +fi system=`uname -s` if [[ ($system == "Linux") && (`uname -a` =~ (microsoft|Microsoft|wsl|WSL) ) ]]; then @@ -149,11 +165,11 @@ shopt -u extglob find $targetdir -name "*.[ch]" -exec sed -i.bak -e "s/\(0x[0-9a-fA-F]*\)UL/\(\(unsigned long\)\1\)/" \{\} \; # run wmc_tool -"tools/$system/wmc_tool" -m "$targetdir/apps/encoder.c" "$targetdir/lib_enc/*.c" "$targetdir/lib_com/*.c" >> /dev/null -"tools/$system/wmc_tool" -m "$targetdir/apps/decoder.c" "$targetdir/lib_dec/*.c" "$targetdir/lib_rend/*.c" >> /dev/null +"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 if [ $INCLUDE_SPLIT -eq 1 ]; then - "tools/$system/wmc_tool" -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" "$targetdir/lib_lc3plus/*.c" "$targetdir/lib_lc3plus/fft/*.c" >> /dev/null - "tools/$system/wmc_tool" -m "$targetdir/apps/isar_post_rend.c" "$targetdir/lib_isar/*.c" "$targetdir/lib_lc3plus/*.c" "$targetdir/lib_lc3plus/fft/*.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 fi # automatically enable #define WMOPS in options.h -- GitLab From 66a8785930fdec77eaa787755b91775e47660c88 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 2 Aug 2024 15:31:24 +0200 Subject: [PATCH 2/6] remove INCLUDE_SPLIT from instr script as it is obsolete --- scripts/prepare_instrumentation.sh | 51 ++++++++++++------------------ 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/scripts/prepare_instrumentation.sh b/scripts/prepare_instrumentation.sh index 8f3fd76938..d0fa9e41ff 100755 --- a/scripts/prepare_instrumentation.sh +++ b/scripts/prepare_instrumentation.sh @@ -39,8 +39,6 @@ function usage { exit } -INCLUDE_SPLIT=1 - wmc_opt="" if [ $# -eq 1 ]; then mode=$1 @@ -95,42 +93,37 @@ cp -R ../apps $targetdir cp -R ../Makefile $targetdir cp -R ../CMakeLists.txt $targetdir cp -R ../Workspace_msvc $targetdir -if [ $INCLUDE_SPLIT -eq 0 ]; then - ./strip_split_rendering.sh $targetdir -fi # back up #ifdef-list rm -f $ifdef_list touch $ifdef_list # Add LC3plus feature defines to options.h so that they are stripped correctly -if [ $INCLUDE_SPLIT -eq 1 ]; then - # 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 " +# 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="" @@ -167,10 +160,8 @@ 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 -if [ $INCLUDE_SPLIT -eq 1 ]; 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 -fi +"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 # 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 From c6855044700ff57104cc752d2637cd5662435b56 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 2 Aug 2024 15:50:12 +0200 Subject: [PATCH 3/6] add argument to IvasBuildAndRunChecks to instrument mem only --- scripts/IvasBuildAndRunChecks.py | 6 ++++++ scripts/pyivastest/IvasSvnBuilder.py | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/scripts/IvasBuildAndRunChecks.py b/scripts/IvasBuildAndRunChecks.py index 4bca48a672..c1f31e433d 100755 --- a/scripts/IvasBuildAndRunChecks.py +++ b/scripts/IvasBuildAndRunChecks.py @@ -95,6 +95,11 @@ class IvasBuildAndRunChecks(IvasScriptsCommon.IvasScript): help="suppression file for undef behaviour sanitizer", default=None, ) + self.parser.add_argument( + "--wmc_tool_mem_only", + help="pass the '-s' argument to the wmc tool to only measure memory", + action="store_true", + ) def run(self): @@ -159,6 +164,7 @@ class IvasBuildAndRunChecks(IvasScriptsCommon.IvasScript): format_select_list=modes, formats_fname=self.args["format_file"], max_workers=self.args["max_workers"], + mem_only=self.args["wmc_tool_mem_only"], ) else: br.add_check( diff --git a/scripts/pyivastest/IvasSvnBuilder.py b/scripts/pyivastest/IvasSvnBuilder.py index ca4859ffd6..cec143b67b 100644 --- a/scripts/pyivastest/IvasSvnBuilder.py +++ b/scripts/pyivastest/IvasSvnBuilder.py @@ -226,6 +226,7 @@ class IvasBuilder(IvasBaseClass): defines_to_enable=[], defines_to_disable=[], instrumented=False, + mem_only=False, ): """ @@ -272,6 +273,8 @@ class IvasBuilder(IvasBaseClass): instrument_cmd = [ os.path.join(self.src_dir, "scripts", "prepare_instrumentation.sh") ] + if mem_only: + instrument_cmd.append("mem_only") build_log.write(" ".join(instrument_cmd)) build_log.write("\n") build_result = subprocess.run( @@ -640,6 +643,7 @@ class IvasSvnBuilder(IvasBuilder): defines_to_enable=[], defines_to_disable=[], instrumented=False, + mem_only=False, ): """ @@ -668,6 +672,7 @@ class IvasSvnBuilder(IvasBuilder): defines_to_enable=defines_to_enable, defines_to_disable=defines_to_disable, instrumented=instrumented, + mem_only=mem_only, ) @@ -775,6 +780,7 @@ class IvasBuilderAndRunner(IvasBaseClass): formats_fname="", max_workers=1, timeout=None, + mem_only=False, ): """ @@ -818,6 +824,7 @@ class IvasBuilderAndRunner(IvasBaseClass): self.build_and_run_dict[cfg_name]["defines_to_enable"] = defines_to_enable self.build_and_run_dict[cfg_name]["defines_to_disable"] = defines_to_disable self.build_and_run_dict[cfg_name]["instrumented"] = instrumented + self.build_and_run_dict[cfg_name]["mem_only"] = mem_only self.build_and_run_dict[cfg_name]["make_options"] = make_options else: self.logger.console("Adding config {}".format(cfg_name), logging.INFO) @@ -1045,6 +1052,7 @@ class IvasBuilderAndRunner(IvasBaseClass): defines_to_enable=cfg["defines_to_enable"], defines_to_disable=cfg["defines_to_disable"], instrumented=cfg["instrumented"], + mem_only=cfg["mem_only"], ) self.build_and_run_dict[cfg_name]["runner"].encoder = self.builder.encoder self.build_and_run_dict[cfg_name]["runner"].decoder = self.builder.decoder @@ -1245,6 +1253,7 @@ class IvasBuilderAndRunner(IvasBaseClass): defines_to_disable=None, formats_fname="", max_workers=1, + mem_only=False, ): """ @@ -1277,6 +1286,7 @@ class IvasBuilderAndRunner(IvasBaseClass): defines_to_disable=defines_to_disable_check, formats_fname=formats_fname, max_workers=max_workers, + mem_only=mem_only, ) # TODO: this is used nowhere, is this still needed? -- GitLab From 158b19b3b5fa02dbcadc93e42ee1f07638f1fe17 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 2 Aug 2024 16:04:46 +0200 Subject: [PATCH 4/6] add argument to get_wmops.sh too --- ci/complexity_measurements/getWmops.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ci/complexity_measurements/getWmops.sh b/ci/complexity_measurements/getWmops.sh index a3d4710f2c..721414d4e3 100755 --- a/ci/complexity_measurements/getWmops.sh +++ b/ci/complexity_measurements/getWmops.sh @@ -28,15 +28,26 @@ # accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and # the United Nations Convention on Contracts on the International Sales of Goods. -# get format from command line -if [ $# -ne 2 ]; then - echo "Usage: $0 \"ivas-format(s)\" \"output-format(s)\"" +function usage { + echo "Usage: $0 \"ivas-format(s)\" \"output-format(s)\" \"mode[full|mem_only]\"" exit 1 +} + +# get format from command line +if [ $# -ne 3 ]; then + usage fi ivas_format=$1 output_format="$2" +mode_arg_script="" +if [ "$3" = "mem_only" ]; then + mode_arg_script="--wmc_tool_mem_only" +elif [ "$3" != "full" ]; then + usage +fi + date=`date +%Y%m%d` # used for log-file file ending shortDate=`date "+%b %d" | sed -e "s/\ /_/g"` # stored in the log-file fullDate=`date "+%c" | sed -e "s/\ /_/g"` # stored in the log-file @@ -56,7 +67,7 @@ wmopsFilenameFlc=${destDir}/wmops/logs/${wmopsFilenameFlcLast} ret_val=0 # instrument and build -./scripts/IvasBuildAndRunChecks.py -p $config_file --checks COMPLEXITY --create_complexity_tables ${wmopsFilenameFlc} -C $ivas_format -f ${ep} --oc $output_format +./scripts/IvasBuildAndRunChecks.py $mode_arg_script -p $config_file --checks COMPLEXITY --create_complexity_tables ${wmopsFilenameFlc} -C $ivas_format -f ${ep} --oc $output_format ret_val=$? # get the info on worst-case operating point: WMOPS number, enc-operating mode, dec-operating mode -- GitLab From 963b83a3b8e8c46c3979070dd1347b196bdc63ab Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 2 Aug 2024 16:06:04 +0200 Subject: [PATCH 5/6] add mem_only var to cfg dict at both places --- scripts/pyivastest/IvasSvnBuilder.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/pyivastest/IvasSvnBuilder.py b/scripts/pyivastest/IvasSvnBuilder.py index cec143b67b..e437843d16 100644 --- a/scripts/pyivastest/IvasSvnBuilder.py +++ b/scripts/pyivastest/IvasSvnBuilder.py @@ -868,6 +868,7 @@ class IvasBuilderAndRunner(IvasBaseClass): "defines_to_enable": defines_to_enable, "defines_to_disable": defines_to_disable, "instrumented": instrumented, + "mem_only": mem_only, "make_options": make_options, "analyzer": new_analyzer, } -- GitLab From f5b555113f9874a92899e9d19daf564b9559bffb Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 2 Aug 2024 16:18:48 +0200 Subject: [PATCH 6/6] make "full" the default in getWmops --- ci/complexity_measurements/getWmops.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ci/complexity_measurements/getWmops.sh b/ci/complexity_measurements/getWmops.sh index 721414d4e3..b5f3db2e82 100755 --- a/ci/complexity_measurements/getWmops.sh +++ b/ci/complexity_measurements/getWmops.sh @@ -29,12 +29,11 @@ # the United Nations Convention on Contracts on the International Sales of Goods. function usage { - echo "Usage: $0 \"ivas-format(s)\" \"output-format(s)\" \"mode[full|mem_only]\"" + echo "Usage: $0 \"ivas-format(s)\" \"output-format(s)\" \"mode{full(default)|mem_only}\"" exit 1 } -# get format from command line -if [ $# -ne 3 ]; then +if [ $# -ne 2 ] && [ $# -ne 3 ]; then usage fi @@ -42,10 +41,12 @@ ivas_format=$1 output_format="$2" mode_arg_script="" -if [ "$3" = "mem_only" ]; then - mode_arg_script="--wmc_tool_mem_only" -elif [ "$3" != "full" ]; then - usage +if [ $# -eq 3 ]; then + if [ "$3" = "mem_only" ]; then + mode_arg_script="--wmc_tool_mem_only" + elif [ "$3" != "full" ]; then + usage + fi fi date=`date +%Y%m%d` # used for log-file file ending -- GitLab