From patchwork Sun Jul 26 15:39:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 7863 Received: (qmail 118696 invoked by alias); 26 Jul 2015 15:40:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 118683 invoked by uid 89); 26 Jul 2015 15:40:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f43.google.com Received: from mail-pa0-f43.google.com (HELO mail-pa0-f43.google.com) (209.85.220.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 26 Jul 2015 15:40:39 +0000 Received: by pachj5 with SMTP id hj5so37997314pac.3 for ; Sun, 26 Jul 2015 08:40:38 -0700 (PDT) X-Received: by 10.66.141.74 with SMTP id rm10mr56256770pab.96.1437925237977; Sun, 26 Jul 2015 08:40:37 -0700 (PDT) Received: from seba.sebabeach.org.gmail.com (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by smtp.gmail.com with ESMTPSA id 1sm24732862pds.79.2015.07.26.08.40.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jul 2015 08:40:37 -0700 (PDT) From: Doug Evans To: gdb-patches@sourceware.org Subject: [PATCH 5/8 v2] gen-perf-test: parallel build support Date: Sun, 26 Jul 2015 08:39:47 -0700 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi. This patch is v2 of this patch: https://sourceware.org/ml/gdb-patches/2015-07/msg00589.html Regression tested for real this time. The change is to the leave the default handling as setting GDB_PARALLEL to "yes" instead of a subdirectory name, and then having one function that computes the path to use, and then have everyone call it. 2015-07-26 Doug Evans * Makefile.in (workers/%.worker, build-perf): New rule. (GDB_PERFTEST_MODE): New variable. (check-perf): Use it. (clean): Clean up gdb.perf parallel build subdirs. * lib/build-piece.exp: New file. * lib/gdb.exp (make_gdb_parallel_path): New function (standard_output_file, standard_temp_file): Call it. (GDB_PARALLEL handling): Make outputs,temp,cache directories as subdirs of $GDB_PARALLEL. * lib/cache.exp (gdb_do_cache): Call make_gdb_parallel_path. diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in index c064f06..3ad5feb 100644 --- a/gdb/testsuite/Makefile.in +++ b/gdb/testsuite/Makefile.in @@ -234,9 +234,41 @@ check/no-matching-tests-found: @echo "No matching tests found." @echo "" +# Utility rule invoked by step 2 of the build-perf rule. +@GMAKE_TRUE@workers/%.worker: +@GMAKE_TRUE@ mkdir -p gdb.perf/outputs/$* +@GMAKE_TRUE@ $(DO_RUNTEST) --status --outdir=gdb.perf/outputs/$* lib/build-piece.exp WORKER=$* GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=build-pieces + +# Utility rule to build tests that support it in parallel. +# The build is broken into 3 steps distinguished by GDB_PERFTEST_SUBMODE: +# gen-workers, build-pieces, final. +# +# GDB_PERFTEST_MODE appears *after* RUNTESTFLAGS here because we don't want +# anything in RUNTESTFLAGS to override it. +# +# We don't delete the outputs directory here as these programs can take +# awhile to build, and perftest.exp has support for deciding whether to +# recompile them. If you want to remove these directories, make clean. +# +# The point of step 1 is to construct the set of worker tasks for step 2. +# All of the information needed by build-piece.exp is contained in the name +# of the generated .worker file. +@GMAKE_TRUE@build-perf: $(abs_builddir)/site.exp +@GMAKE_TRUE@ rm -rf gdb.perf/workers +@GMAKE_TRUE@ mkdir -p gdb.perf/workers +@GMAKE_TRUE@ @: Step 1: Generate the build .worker files. +@GMAKE_TRUE@ $(DO_RUNTEST) --status --directory=gdb.perf --outdir gdb.perf/workers GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=gen-workers +@GMAKE_TRUE@ @: Step 2: Compile the pieces. Here is the build parallelism. +@GMAKE_TRUE@ $(MAKE) $$(cd gdb.perf && echo workers/*/*.worker) +@GMAKE_TRUE@ @: Step 3: Do the final link. +@GMAKE_TRUE@ $(DO_RUNTEST) --status --directory=gdb.perf --outdir gdb.perf GDB_PARALLEL=gdb.perf $(RUNTESTFLAGS) GDB_PERFTEST_MODE=compile GDB_PERFTEST_SUBMODE=final + +# The default is to both compile and run the tests. +GDB_PERFTEST_MODE = both + check-perf: all $(abs_builddir)/site.exp @if test ! -d gdb.perf; then mkdir gdb.perf; fi - $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf GDB_PERFTEST_MODE=both $(RUNTESTFLAGS) + $(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf GDB_PERFTEST_MODE=$(GDB_PERFTEST_MODE) $(RUNTESTFLAGS) force:; @@ -245,6 +277,7 @@ clean mostlyclean: -rm -f core.* *.tf *.cl tracecommandsscript copy1.txt zzz-gdbscript -rm -f *.dwo *.dwp -rm -rf outputs temp cache + -rm -rf gdb.perf/workers gdb.perf/outputs gdb.perf/temp gdb.perf/cache -rm -f read1.so expect-read1 if [ x"${ALL_SUBDIRS}" != x ] ; then \ for dir in ${ALL_SUBDIRS}; \ diff --git a/gdb/testsuite/lib/build-piece.exp b/gdb/testsuite/lib/build-piece.exp new file mode 100644 index 0000000..a81530c --- /dev/null +++ b/gdb/testsuite/lib/build-piece.exp @@ -0,0 +1,39 @@ +# Copyright (C) 2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Utility to bootstrap building a piece of a performance test in a +# parallel build. +# See testsuite/Makefile.in:workers/%.worker. +# WORKER is set by the makefile and is +# "{program_name}/{program_name}-{worker_nr}". + +regexp "^\(.+\)/\(.+\)-\(\[0-9\]+\)$" $WORKER entire_match PROGRAM_NAME pname2 WORKER_NR + +if { ![info exists entire_match] || $entire_match != $WORKER } { + error "Bad value for WORKER: $WORKER" +} +if { $PROGRAM_NAME != $pname2 } { + error "Bad value for WORKER: $WORKER" +} + +# $subdir is set to "lib", because that is where this file lives, +# which is not what tests expect. +set subdir "gdb.perf" + +# $gdb_test_file_name is set to this file, build-piece, which is not what +# tests expect. +set gdb_test_file_name $PROGRAM_NAME + +source $srcdir/$subdir/${gdb_test_file_name}.exp diff --git a/gdb/testsuite/lib/cache.exp b/gdb/testsuite/lib/cache.exp index 8df04b9..968e9ff 100644 --- a/gdb/testsuite/lib/cache.exp +++ b/gdb/testsuite/lib/cache.exp @@ -35,7 +35,7 @@ proc gdb_do_cache {name} { } if {[info exists GDB_PARALLEL]} { - set cache_filename [file join $objdir cache $cache_name] + set cache_filename [make_gdb_parallel_path cache $cache_name] if {[file exists $cache_filename]} { set fd [open $cache_filename] set gdb_data_cache($cache_name) [read -nonewline $fd] diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index c5cfa4b..ecfc863 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -3972,6 +3972,26 @@ proc default_gdb_init { test_file_name } { } } +# Return a path using GDB_PARALLEL. +# ARGS is a list of path elements to append to "$objdir/$GDB_PARALLEL". +# GDB_PARALLEL must be defined, the caller must check. +# +# The default value for GDB_PARALLEL is, canonically, ".". +# The catch is that tests don't expect an additional "./" in file paths so +# omit any directory for the default case. +# GDB_PARALLEL is written as "yes" for the default case in Makefile.in to mark +# its special handling. + +proc make_gdb_parallel_path { args } { + global GDB_PARALLEL objdir + set joiner [list "file" "join" $objdir] + if { $GDB_PARALLEL != "yes" } { + lappend joiner $GDB_PARALLEL + } + set joiner [concat $joiner $args] + return [eval $joiner] +} + # Turn BASENAME into a full file name in the standard output # directory. It is ok if BASENAME is the empty string; in this case # the directory is returned. @@ -3980,7 +4000,7 @@ proc standard_output_file {basename} { global objdir subdir gdb_test_file_name GDB_PARALLEL if {[info exists GDB_PARALLEL]} { - set dir [file join $objdir outputs $subdir $gdb_test_file_name] + set dir [make_gdb_parallel_path outputs $subdir $gdb_test_file_name] file mkdir $dir return [file join $dir $basename] } else { @@ -3994,7 +4014,7 @@ proc standard_temp_file {basename} { global objdir GDB_PARALLEL if {[info exists GDB_PARALLEL]} { - return [file join $objdir temp $basename] + return [make_gdb_parallel_path temp $basename] } else { return $basename } @@ -5119,7 +5139,10 @@ if {[info exists GDB_PARALLEL]} { if {[is_remote host]} { unset GDB_PARALLEL } else { - file mkdir outputs temp cache + file mkdir \ + [make_gdb_parallel_path outputs] \ + [make_gdb_parallel_path temp] \ + [make_gdb_parallel_path cache] } }