From f02f878bd2ae6364edbb40146b73ab25b73d6324 Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Mon, 24 May 2021 21:26:29 +0800 Subject: [PATCH 1/5] frame: openblas: Pass building and installing Signed-off-by: Chen Gang --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index bd9c76e..d67dcd2 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ STDCXXV=c++11 # Environments # ARCH := $(shell uname -m) +TOPDIR = $(shell pwd) CONFDIR = ./config PROGDIR = ./pgms SRCDIR = ./src @@ -24,6 +25,7 @@ TESTDIR = ./testdir RESULTDIR = ./results TMPDIR = ./tmp WLDIR = ./workloads +FRMDIR = ./frame # @@ -135,12 +137,17 @@ $(DIRS): $(eval OPTFLAGS = $(OPTFLAGS0) $(OPTFLAGS1) $(OPTFLAGS2)) +make $(OPTFLAGS) -C "$(WLDIR)/$@" +openblas: + +make -C "$(FRMDIR)/openblas" + +make -C "$(FRMDIR)/openblas" PREFIX="$(TOPDIR)" install + clean: $(RM) $(BINS) $(ALLBINS) core *~ */*~ @for subdir in $(DIRS) \ ; do \ make -C "$(WLDIR)/$${subdir}" clean \ ; done + make -C "$(FRMDIR)/openblas" clean spotless: clean $(RM) $(RESULTDIR)/* $(TMPDIR)/* -- Gitee From 97da9bc263e3efd85b6d76053b144dd794cbaa6c Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Mon, 24 May 2021 22:06:41 +0800 Subject: [PATCH 2/5] Run: Support native openblas when there is no system openblas Signed-off-by: Chen Gang --- Run | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/Run b/Run index 015c7dc..7795fd4 100755 --- a/Run +++ b/Run @@ -3,6 +3,7 @@ ################################################################################ BASEDIR=$(cd "$(dirname "$0")"; pwd) +NLIBDIR="${BASEDIR}/lib" WKLDDIR="$BASEDIR/workloads" PEAKFILE="$BASEDIR/peakopt.mk" TTCASESFILE="$BASEDIR/frame/TestCases.plt" @@ -11,14 +12,15 @@ TCASEFILE="CaseConfig.pl" DIRS=`cd ${WKLDDIR}; ls | xargs` ispeak="false" isclean="false" +haveoblas="false" # # Prepare the common environments # if echo "${PATH}" | egrep -v "(^|:)${BASEDIR}(:|$)" > /dev/null 2>&1; then - PATH="${BASEDIR}:$PATH" - export PATH + export PATH="${BASEDIR}:$PATH" fi +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$NLIBDIR" echo "basedir: <${BASEDIR}>; input parameters: <$@> " @@ -100,6 +102,39 @@ done cd .. echo "};" >> $TCASESFILE +# +# Check system libs, if not be found, native libs will be instead of +# + +rpm --help > /dev/null 2>&1 +if [ "$?" == "0" ] +then + isrpm="true" + rpm -qa | grep "openblas-dev" > /dev/null 2>&1 + if [ "$?" == "0" ] + then + haveoblas="true" + fi +fi + +dpkg --help > /dev/null 2>&1 +if [ "$?" == "0" ] +then + dpkg -l | grep "openblas-dev" > /dev/null 2>&1 + if [ "$?" == "0" ] + then + haveoblas="true" + fi +fi + +if [ "$haveoblas" != "true" ] +then + if [ ! -f "${NLIBDIR}/libopenblas.so" ] + then + make openblas + fi +fi + # # Main working # -- Gitee From c472b666600e09e150ed0e7e1ddbc0bca56cd50c Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Tue, 25 May 2021 16:07:14 +0800 Subject: [PATCH 3/5] dhrystone: Firstly be added as an integrated test program Also Run is improved to support both peak and base building for the integrated test programs. Signed-off-by: Chen Gang --- Makefile | 8 ++++---- Run | 37 +++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index d67dcd2..78a9a33 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ else DIRS = $(shell ls $(WLDIR) | xargs) endif -include frame/bins.mk +include $(FRMDIR)/bins.mk ifneq ($(wildcard $(BINSCFG)),) include $(BINSCFG) else @@ -153,15 +153,15 @@ spotless: clean $(RM) $(RESULTDIR)/* $(TMPDIR)/* # -# Testcases for the intergrated test programs +# Testcases for the integrated test programs # -include frame/items.mk +include $(FRMDIR)/items.mk # # Testcases Peak Optimization Configuration for the integrated test programs # ifeq ($(IPEAKOPTCFG),) - IPEAKOPTCFG = frame/peakopt.mk + IPEAKOPTCFG = peakopt_integrated.mk endif ifneq ($(wildcard $(IPEAKOPTCFG)),) include $(IPEAKOPTCFG) diff --git a/Run b/Run index 7795fd4..e80cb32 100755 --- a/Run +++ b/Run @@ -4,10 +4,13 @@ BASEDIR=$(cd "$(dirname "$0")"; pwd) NLIBDIR="${BASEDIR}/lib" -WKLDDIR="$BASEDIR/workloads" -PEAKFILE="$BASEDIR/peakopt.mk" -TTCASESFILE="$BASEDIR/frame/TestCases.plt" -TCASESFILE="$BASEDIR/TestCases.pl" +FRMDIR="${BASEDIR}/frame" +WKLDDIR="${BASEDIR}/workloads" +PEAKFILE="${BASEDIR}/peakopt.mk" +PEAKIFILE="${BASEDIR}/peakopt_integrated.mk" +PEAKFFILE="${FRMDIR}/peakopt.mk" +TTCASESFILE="${FRMDIR}/TestCases.plt" +TCASESFILE="${BASEDIR}/TestCases.pl" TCASEFILE="CaseConfig.pl" DIRS=`cd ${WKLDDIR}; ls | xargs` ispeak="false" @@ -20,12 +23,12 @@ haveoblas="false" if echo "${PATH}" | egrep -v "(^|:)${BASEDIR}(:|$)" > /dev/null 2>&1; then export PATH="${BASEDIR}:$PATH" fi -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$NLIBDIR" +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:"$NLIBDIR" echo "basedir: <${BASEDIR}>; input parameters: <$@> " # -# Prepare the peakopt.mk for each workloads +# Prepare the peakopt.mk for each workloads and integrated cases # for param in $@ @@ -35,31 +38,33 @@ do continue; fi - if test ! -f $PEAKFILE + if test ! -f "${PEAKFILE}" then isclean="true" fi cd ${WKLDDIR} - echo "" > $PEAKFILE + echo "" > "${PEAKFILE}" for subdir in ${DIRS} do if [ "$subdir" = "Makefile" ] then continue fi - make prefix=$subdir >> $PEAKFILE + make prefix=$subdir >> "${PEAKFILE}" done cd .. + rm -rf "${PEAKIFILE}" + cp "${PEAKFFILE}" "${PEAKIFILE}" ispeak="true" done if [ "$ispeak" != "true" ] then - if test -f $PEAKFILE + if test -f "${PEAKFILE}" then isclean="true" - rm -rf $PEAKFILE + rm -rf "${PEAKFILE}" "${PEAKIFILE}" fi fi @@ -72,8 +77,8 @@ fi # Prepare TestCases.pl # -rm -rf $TCASESFILE -cp $TTCASESFILE $TCASESFILE +rm -rf "${TCASESFILE}" +cp "${TTCASESFILE}" "${TCASESFILE}" cd ${WKLDDIR} for subdir in ${DIRS} do @@ -93,14 +98,14 @@ do for case in ${cases[@]} do echo $case | sed -e "s/\"prog.*${prognames[$i]}/\"prog\" => \"\${BINDIR}\/try_workloads.sh/" \ - -e "s/\"options.*=>[ \t]*\"/\"options\" => \"$subdir ${prognames[$i]} /" >> $TCASESFILE + -e "s/\"options.*=>[ \t]*\"/\"options\" => \"$subdir ${prognames[$i]} /" >> "${TCASESFILE}" i=$(($i + 1)) done IFS="$OLD_IFS" done cd .. -echo "};" >> $TCASESFILE +echo "};" >> "${TCASESFILE}" # # Check system libs, if not be found, native libs will be instead of @@ -138,6 +143,6 @@ fi # # Main working # -exec perl $BASEDIR/frame/Run.pl "$@" +exec perl "${BASEDIR}/frame/Run.pl" "$@" # Editor settings: (please leave this at the end of the file) -- Gitee From e5fbc7c3dd9b3b7f4b2424134273b9a311927e6a Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Tue, 25 May 2021 22:41:31 +0800 Subject: [PATCH 4/5] Run: Support maxThreads limitation Can let -threads and -c be in a command line without conflict, although they are conflict during running. Fix bug about maxCopies. Set limitations for the workloads. Signed-off-by: Chen Gang --- frame/Run.pl | 113 +++++++++++++++++++++---------------------- frame/TestCases.plt | 1 + frame/output/CSV.pl | 5 +- frame/output/Html.pl | 5 +- frame/output/Text.pl | 11 ++++- 5 files changed, 71 insertions(+), 64 deletions(-) diff --git a/frame/Run.pl b/frame/Run.pl index 845b748..da6ab37 100755 --- a/frame/Run.pl +++ b/frame/Run.pl @@ -589,6 +589,7 @@ sub parseArgs { # Generate the requested list of bench programs. my $opt; my $word; + $ENV{'OMP_NUM_THREADS'} = 1; while ($word = shift(@words)) { if ($word !~ m/^-/) { # A test name. if ($word eq "all") { @@ -639,7 +640,13 @@ sub parseArgs { } elsif ($word eq "-f") { $params->{'tests'} = readConfigFromFile($CONFDIR . "/" . shift(@words)); } elsif ($word eq "-threads") { - $ENV{'OMP_NUM_THREADS'} = shift(@words); + my $num = shift(@words); + if ($num =~ /^\d+$/) { + $ENV{'OMP_NUM_THREADS'} = $num; + } else { + helpinfo(); + die("Run: parameter threads should be number, but \"$num\" is not number\n"); + } } elsif ($word eq "-peak") { ; # do nothing } else { @@ -1132,10 +1139,7 @@ sub runOnePass { sub runBenchmark { - my ( $bench, $tparams, $verbose, $logFile, $copies ) = @_; - - # Make up the actual benchmark parameters. - my $params = mergeParams($TestCases::baseParams, $tparams); + my ( $bench, $tparams, $params, $verbose, $logFile, $copies ) = @_; # Make up the command string based on the parameters. my $prog = $params->{'prog'} || $BINDIR . "/" . $bench; @@ -1206,29 +1210,43 @@ sub runBenchmark { $bresult; } +require "$FRAMEDIR/output/Text.pl"; +require "$FRAMEDIR/output/Html.pl"; +require "$FRAMEDIR/output/CSV.pl"; # Run the named benchmarks. -sub runTests { - my ( $tests, $verbose, $logFile, $copies ) = @_; +sub runTestsWithReport { + my ( $tests, $verbose, $logFile, $copies, + $systemInfo, $reportFds) = @_; + + if ($verbose > 1) { + printf "Run with %s\n", number($copies, "copy", "copies"); + } # Run all the requested tests and gather the results. my $results = { 'start' => time(), 'copies' => $copies }; foreach my $bench (@$tests) { # Get the parameters for this benchmark. - my $params = $TestCases::testParams->{$bench}; - if (!defined($params)) { + my $tparams = $TestCases::testParams->{$bench}; + if (!defined($tparams)) { abortRun("unknown benchmark \"$bench\""); } # If the benchmark doesn't want to run with this many copies, skip it. - my $cat = $params->{'cat'}; + my $cat = $tparams->{'cat'}; my $maxCopies = $TestCases::testCats->{$cat}{'maxCopies'}; next if ($maxCopies > 0 && $copies > $maxCopies); + + # Make up the actual benchmark parameters. + my $params = mergeParams($TestCases::baseParams, $tparams); + $maxCopies = $params->{'maxCopies'}; next if ($maxCopies > 0 && $copies > $maxCopies); + my $maxThreads = $params->{'maxThreads'}; + next if ($maxThreads > 0 && $ENV{'OMP_NUM_THREADS'} > $maxThreads); # Run the benchmark. - my $bresult = runBenchmark($bench, $params, $verbose, $logFile, $copies); + my $bresult = runBenchmark($bench, $tparams, $params, $verbose, $logFile, $copies); $results->{$bench} = $bresult; } $results->{'end'} = time(); @@ -1245,13 +1263,11 @@ sub runTests { # Generate index scores for the results relative to the baseline data. indexResults($results); - $results; + summarizeRun($systemInfo, $results, $verbose, $reportFds->{'txt'}); + summarizeRunHtml($systemInfo, $results, $verbose, $reportFds->{'html'}); + summarizeRunCsv($systemInfo, $results, $verbose, $reportFds->{'csv'}); } -require "$FRAMEDIR/output/Text.pl"; -require "$FRAMEDIR/output/Html.pl"; -require "$FRAMEDIR/output/CSV.pl"; - ############################################################################ # MAIN ############################################################################ @@ -1282,16 +1298,6 @@ sub main { my $systemInfo = getSystemInfo(); preChecks($tests, $systemInfo); - # If the number of copies to run was not set, set it to 1 - # and the number of CPUs in the system (if > 1). - my $copies = $params->{'copies'}; - if (!$copies || scalar(@$copies) == 0) { - push(@$copies, 1); - if (defined($systemInfo->{'numCpus'}) && $systemInfo->{'numCpus'} > 1) { - push(@$copies, $systemInfo->{'numCpus'}); - } - } - # Display the program banner. system("cat \"${TESTDIR}/benchmark.logo\""); @@ -1322,54 +1328,45 @@ sub main { # If defined "UB_OUTPUT_CSV" on Environment, output csv file. my $ubOutputCsv = $ENV{"UB_OUTPUT_CSV"}; - # my $isOutputFormatCsv = defined($ubOutputCsv) && $ubOutputCsv eq "true"; - my $isOutputFormatCsv = 1; # If write CSV, header needs only once. my $is_csv_header_written = 0; + my $reportFds = { }; # Open the log file for writing. - open(my $reportFd, ">", $reportTxt) || + open($reportFds->{'txt'}, ">", $reportTxt) || die("Run: can't write to $reportTxt\n"); - open(my $reportFd2, ">", $reportHtml) || + open($reportFds->{'html'}, ">", $reportHtml) || die("Run: can't write to $reportHtml\n"); - my $reportFd_Csv; - if ($isOutputFormatCsv) { - open($reportFd_Csv, ">", $reportCsv) || + open($reportFds->{'csv'}, ">", $reportCsv) || die("Run: can't write to $reportCsv\n"); - } - printf $reportFd " Linux Benchmarks (Version %s)\n\n", $version; - runHeaderHtml($systemInfo, $reportFd2, $version); + runHeader($systemInfo, $reportFds->{'txt'}, $version); + runHeaderHtml($systemInfo, $reportFds->{'html'}, $version); # Dump information about the system under test. - displaySystem($systemInfo, $reportFd); - displaySystemHtml($systemInfo, $reportFd2); - - # Run the tests! Do a test run once for each desired number of copies; - # for example, on a 2-CPU system, we may do a single-processing run - # followed by a dual-processing run. - foreach my $c (@$copies) { - if ($verbose > 1) { - printf "Run with %s\n", number($c, "copy", "copies"); - } - my $results = runTests($tests, $verbose, $logFile, $c); - - summarizeRun($systemInfo, $results, $verbose, $reportFd); - summarizeRunHtml($systemInfo, $results, $verbose, $reportFd2); + displaySystem($systemInfo, $reportFds->{'txt'}); + displaySystemHtml($systemInfo, $reportFds->{'html'}); - if ($isOutputFormatCsv) { - summarizeRunCsv($systemInfo, $results, $verbose, $reportFd_Csv); + my $copies = $params->{'copies'}; + if ($copies && (scalar(@$copies) != 0)) { + if ($ENV{'OMP_NUM_THREADS'} != 1) { + runTestsWithReport($tests, $verbose, $logFile, 1, $systemInfo, $reportFds); + $ENV{'OMP_NUM_THREADS'} = 1; + } + foreach my $c (@$copies) { + runTestsWithReport($tests, $verbose, $logFile, $c, $systemInfo, $reportFds); } + } else { + runTestsWithReport($tests, $verbose, $logFile, 1, $systemInfo, $reportFds); } - runFooterHtml($reportFd2); + runFooterHtml($reportFds->{'html'}); # Finish the report. - close($reportFd); - close($reportFd2); - if ($isOutputFormatCsv) { - close($reportFd_Csv); - } + close($reportFds->{'txt'}); + close($reportFds->{'html'}); + close($reportFds->{'csv'}); + `wkhtmltopdf "$reportHtml" "$reportPdf"`; # Display the report, if not in quiet mode. diff --git a/frame/TestCases.plt b/frame/TestCases.plt index 8a3f1e9..8db7e5f 100644 --- a/frame/TestCases.plt +++ b/frame/TestCases.plt @@ -54,6 +54,7 @@ our $baseParams = { "logmsg" => "", "buildep" => "", "maxCopies" => 0, # 0 means unlimited + "maxThreads" => 1, # 0 means unlimited "canbindcpu" => 0, # if none-zero, --bindcpu=cpunum(th0),cpunum(th1), ... cpunum(thn) "checkself" => 0, # if none-zero, the test program will check the result correction by itself. }; diff --git a/frame/output/CSV.pl b/frame/output/CSV.pl index fe6466e..2404d64 100644 --- a/frame/output/CSV.pl +++ b/frame/output/CSV.pl @@ -151,9 +151,10 @@ sub summarizeRunCsv{ strftime("%H:%M:%S", localtime($results->{'start'})), strftime("%H:%M:%S", localtime($results->{'end'})), $tHour, $tMinute, $tSecond; - printf $reportFd "%s in system; running %s of tests\n", + printf $reportFd "%s in system; running %s of tests with %s\n", number($info->{'numCpus'}, "CPU"), - number($results->{'copies'}, "parallel copy", "parallel copies"); + number($results->{'copies'}, "parallel copy", "parallel copies"), + number($ENV{'OMP_NUM_THREADS'}, "thread"); printf $reportFd "\n"; # Display the run scores. diff --git a/frame/output/Html.pl b/frame/output/Html.pl index 03c6f3f..8c3940c 100644 --- a/frame/output/Html.pl +++ b/frame/output/Html.pl @@ -337,9 +337,10 @@ sub summarizeRunHtml { # Display information about this test run. my $time = $results->{'end'} - $results->{'start'}; printf $reportFd "


\n"; - printf $reportFd "

Benchmark Run: %s; %s

\n", + printf $reportFd "

Benchmark Run: %s; %s with %s

\n", number($info->{'numCpus'}, "CPU"), - number($results->{'copies'}, "parallel process", "parallel processes"); + number($results->{'copies'}, "parallel process", "parallel processes"), + number($ENV{'OMP_NUM_THREADS'}, "thread"); printf $reportFd "

Time: %s - %s; %dm %02ds

\n", strftime("%H:%M:%S", localtime($results->{'start'})), strftime("%H:%M:%S", localtime($results->{'end'})), diff --git a/frame/output/Text.pl b/frame/output/Text.pl index 2068c9a..27e37a7 100644 --- a/frame/output/Text.pl +++ b/frame/output/Text.pl @@ -20,6 +20,12 @@ sub printUsingDirectoriesToFile { printf $fd "\n"; } +sub runHeader { + my ( $systemInfo, $reportFd, $version ) = @_; + printf $reportFd " Linux Benchmarks (Version %s)\n\n", $version; + +} + # Display a banner indicating the configuration of the system under test # to the given file desc. sub displaySystem { @@ -224,9 +230,10 @@ sub summarizeRun { strftime("%H:%M:%S", localtime($results->{'start'})), strftime("%H:%M:%S", localtime($results->{'end'})), $tHour, $tMinute, $tSecond; - printf $reportFd "%s in system; running %s of tests\n", + printf $reportFd "%s in system; running %s of tests with %s\n", number($info->{'numCpus'}, "CPU"), - number($results->{'copies'}, "parallel copy", "parallel copies"); + number($results->{'copies'}, "parallel copy", "parallel copies"), + number($ENV{'OMP_NUM_THREADS'}, "thread"); printf $reportFd "\n"; # Display the run scores. -- Gitee From 522b2729ad99886351782cd031e579f787afb5ab Mon Sep 17 00:00:00 2001 From: whl Date: Wed, 26 May 2021 11:00:05 +0800 Subject: [PATCH 5/5] Run: delete openblas dependency Signed-off-by: whl --- Run | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/Run b/Run index e80cb32..7a01885 100755 --- a/Run +++ b/Run @@ -107,39 +107,6 @@ done cd .. echo "};" >> "${TCASESFILE}" -# -# Check system libs, if not be found, native libs will be instead of -# - -rpm --help > /dev/null 2>&1 -if [ "$?" == "0" ] -then - isrpm="true" - rpm -qa | grep "openblas-dev" > /dev/null 2>&1 - if [ "$?" == "0" ] - then - haveoblas="true" - fi -fi - -dpkg --help > /dev/null 2>&1 -if [ "$?" == "0" ] -then - dpkg -l | grep "openblas-dev" > /dev/null 2>&1 - if [ "$?" == "0" ] - then - haveoblas="true" - fi -fi - -if [ "$haveoblas" != "true" ] -then - if [ ! -f "${NLIBDIR}/libopenblas.so" ] - then - make openblas - fi -fi - # # Main working # -- Gitee