[Sound-open-firmware] [PATCH v2] topology: speed up topology build
Speed up topology with batch processing of m4 files
Signed-off-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com ---
Notes: v2: check for xargs in configure
configure.ac | 2 ++ topology/test/Makefile.am | 4 ++- topology/test/tplg-build.sh | 66 ++++++++++++++++++++++++++++++++------------- 3 files changed, 52 insertions(+), 20 deletions(-)
diff --git a/configure.ac b/configure.ac index b95c44c..cc5e59e 100644 --- a/configure.ac +++ b/configure.ac @@ -5,6 +5,8 @@ AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_SRCDIR([rmbox/rmbox.c]) AC_CONFIG_HEADERS([config.h]) AC_CHECK_HEADER([sof/uapi/abi.h]) +AC_CHECK_PROG([XARGS], xargs, "yes", "no", [$PATH]) +AM_CONDITIONAL(XARGS, test "$XARGS" = "yes")
AC_CANONICAL_HOST
diff --git a/topology/test/Makefile.am b/topology/test/Makefile.am index 61713f9..d494fcb 100644 --- a/topology/test/Makefile.am +++ b/topology/test/Makefile.am @@ -3,7 +3,9 @@ # Dependencies #
- +if XARGS +export USE_XARGS=yes +endif
DEPS = \ ../dsps/*.m4 \ diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 7c55fba..4cf652c 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -8,14 +8,14 @@ set -e
# M4 preprocessor flags -M4_FLAGS="-I ../ -I ../m4 -I ../common" +export M4PATH="../:../m4:../common"
# Simple component test cases # can be used on components with 1 sink and 1 source. SIMPLE_TESTS=(test-ssp test-capture-ssp test-playback-ssp) TONE_TEST=test-tone-playback-ssp - - +TEST_STRINGS="" +M4_STRINGS="" # process m4 simple tests - # simple_test(name, pipe_name, be_name, format, dai_id, dai_format, dai_phy_bits, dai_data_bits dai_bclk) # 1) name - test filename suffix @@ -35,21 +35,35 @@ function simple_test { for i in ${SIMPLE_TESTS[@]} do TFILE="$i$5-${11}-$2-$4-$6-48k-$((${10} / 1000))k-$1" - echo "M4 pre-processing test $i -> ${TFILE}" - m4 ${M4_FLAGS} \ - -DTEST_PIPE_NAME="$2" \ - -DTEST_DAI_LINK_NAME="$3" \ - -DTEST_SSP_PORT=$5 \ - -DTEST_SSP_FORMAT=$6 \ - -DTEST_PIPE_FORMAT=$4 \ - -DTEST_SSP_BCLK=$9 \ - -DTEST_SSP_MCLK=${10} \ - -DTEST_SSP_PHY_BITS=$7 \ - -DTEST_SSP_DATA_BITS=$8 \ - -DTEST_SSP_MODE=${11} \ - $i.m4 > ${TFILE}.conf - echo "Compiling test $i -> ${TFILE}.tplg" - alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg + if [ "$USE_XARGS" == "yes" ] + then + #create input string for batch m4 processing + M4_STRINGS+="-DTEST_PIPE_NAME=$2,-DTEST_DAI_LINK_NAME=$3\ + -DTEST_SSP_PORT=$5,-DTEST_SSP_FORMAT=$6\ + -DTEST_PIPE_FORMAT=$4,-DTEST_SSP_BCLK=$9\ + -DTEST_SSP_MCLK=${10},-DTEST_SSP_PHY_BITS=$7\ + -DTEST_SSP_DATA_BITS=$8,-DTEST_SSP_MODE=${11}\ + $i.m4,${TFILE}," + #create input string for batch processing of conf files + TEST_STRINGS+=${TFILE}"," + else + echo "M4 pre-processing test $i -> ${TFILE}" + m4 ${M4_FLAGS} \ + -DTEST_PIPE_NAME="$2" \ + -DTEST_DAI_LINK_NAME="$3" \ + -DTEST_SSP_PORT=$5 \ + -DTEST_SSP_FORMAT=$6 \ + -DTEST_PIPE_FORMAT=$4 \ + -DTEST_SSP_BCLK=$9 \ + -DTEST_SSP_MCLK=${10} \ + -DTEST_SSP_PHY_BITS=$7 \ + -DTEST_SSP_DATA_BITS=$8 \ + -DTEST_SSP_MODE=${11} \ + $i.m4 > ${TFILE}.conf + echo "Compiling test $i -> ${TFILE}.tplg" + alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg + fi + done }
@@ -69,7 +83,7 @@ function simple_test { function tone_test { TFILE="$TONE_TEST$5-$2-$4-$6-48k-$1" echo "M4 pre-processing test $TONE_TEST -> ${TFILE}" - m4 ${M4_FLAGS} \ + m4 \ -DTEST_PIPE_NAME="$2" \ -DTEST_DAI_LINK_NAME="$3" \ -DTEST_SSP_PORT=$5 \ @@ -84,6 +98,8 @@ function tone_test { alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg }
+echo "Preparing topology build input..." + # Pre-process the simple tests simple_test nocodec passthrough "NoCodec" s16le 2 s16le 20 16 1920000 19200000 I2S simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 19200000 I2S @@ -166,4 +182,16 @@ simple_test nocodec src "NoCodec" s24le 4 s24le 25 24 2400000 24000000 I2S # Tone test: Tone component only supports s32le currently tone_test codec tone "SSP2-Codec" s32le 2 s16le 20 16 1920000 19200000
+if [ "$USE_XARGS" == "yes" ] +then + echo "Batch processing m4 files..." + M4_STRINGS=${M4_STRINGS%?}; + #m4 processing + #echo $M4_STRINGS | tr " " "," | tr '\n' '\0' | xargs -d ',' -n12 -P10 bash -c 'echo "${@:1:${#}-1} > ${12}.conf"' m4 + echo $M4_STRINGS | tr " " "," | tr '\n' '\0' | xargs -d ',' -n12 -P10 bash -c 'm4 "${@:1:${#}-1}" > ${12}.conf' m4 + + #execute alsatplg to create topology binary + TEST_STRINGS=${TEST_STRINGS%?} + echo $TEST_STRINGS | tr '\n' '\0' | xargs -d ',' -n1 -P10 -I string alsatplg -v 1 -c string".conf" -o string".tplg" +fi
participants (1)
-
Ranjani Sridharan