This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RIF: [PATCH] Improved driver for vectorizer testsuite


On Sat, Apr 09, 2005 at 10:11:27AM +0200, Bonzini Paolo wrote:
> > Then again, perhaps there should be a new
> > effective-target keyword that is true when we are compiling using
> > target-specific options, and some tests can be skipped or run only
> > when that is true.
> 
> That could be simd_hw: including it would *not* compile without target-specific options.  I see several chicken-and-egg problems though:
>  
> 1) Some generic vectorization tests would fail with hardware vectorization!  For example, a tests checks that multiplication or 16-bit addition are *not* vectorized with generic vectors, because it's worthless.  Tests such as this must not be compiled with hardware vectorization options.
>  
> 2) I would add this effective-target keyword to all vectorization tests, because currently no test can pass if UNITS_PER_SIMD_WORD is zero. But many of them would work with generic vectorization, so I would have to undo a lot of changes when the generic vectorization patch goes in.  Otherwise, I could modify vect.exp only after generic vectorization is approved, but this conflicts with the need to test generic vectorization.
>  
> 3) On a separate side, vect_* detection may need improving when many sets of target options are passed.  For example -msse does not support vect_double; still, dg-require-effective-target will let the test run.
>  
> Also, I'm new to DejaGNU so I prefer to do this in small steps.  So, would it be ok to check-in the patch as is (as a "good start", and especially something that works independently of generic vectorization) and improve on it in a follow-up patch?

I'd prefer to have the gcc.dg/vect testsuite continue to test support
for hardware vectorization just as it does now, and test vectorization
using generic vectors on top of that as follows:

  compile tests for generic vectors; default dg-do action is 'run'
  for each kind of hardware vectors supported by this target
    compile tests for hardware vectors
    if test system supports these vectors
      default dg-do action is 'run
    else
      default dg-do action is 'compile'

The first of the patches below rearranges gcc.dg/vect/vect.exp based on
your patch but without changing how the tests are run.  The second patch
turns on support for testing generic vectors as well as hardware vectors.

The global variable target_vectcflags holds the hardware vector flags
when the test is run and can be examined by procs in target-supports.exp
for additional information needed for the effective-target checks.  I
recommend a new effective-target keyword vect_generic or vect_simd to
show whether hardware support is being generated or not.

The patch also has outlines of support for multiple types of hardware
vectors for a single target.  Someone who understands the various x86
vector support will need to define procs to determine if each kind is
supported in hardware on the test system.

2005-04-18  Paolo Bonzini  <bonzini@gnu.org>
	    Janis Johnson  <janis187@us.ibm.com>

	* gcc.dg/vect/vect.exp: Rework to allow support for generic vectors
	and multiple hardware vector types.

--- gcc.dg/vect/vect.exp.orig	2005-04-18 12:55:57.000000000 -0700
+++ gcc.dg/vect/vect.exp	2005-04-18 13:53:53.000000000 -0700
@@ -1,4 +1,4 @@
-# Copyright (C) 1997, 2004 Free Software Foundation, Inc.
+# Copyright (C) 1997, 2004, 2005 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
@@ -20,67 +20,99 @@
 load_lib gcc-dg.exp
 
 # Set up flags used for tests that don't specify options.
-set DEFAULT_VECTCFLAGS ""
-
 # These flags are used for all targets.
-lappend DEFAULT_VECTCFLAGS "-O2" "-ftree-vectorize" \
-  "-ftree-vectorizer-verbose=3" "-fdump-tree-vect-stats"
+set DEFAULT_VECTCFLAGS [list "-O2" "-ftree-vectorize" \
+  "-ftree-vectorizer-verbose=3" "-fdump-tree-vect-stats"]
 
-# If the target system supports vector instructions, the default action
-# for a test is 'run', otherwise it's 'compile'.  Save current default.
-# Executing vector instructions on a system without hardware vector support
-# is also disabled by a call to check_vect, but disabling execution here is
-# more efficient.
-global dg-do-what-default
-set save-dg-do-what-default ${dg-do-what-default}
-
-# Skip these tests for targets that do not support generating vector
-# code.  Set additional target-dependent vector flags, which can be
-# overridden by using dg-options in individual tests.
-if [istarget "powerpc*-*-*"] {
-    # If there are powerpc targets to skip, do it here.
+# Lists of flags that are used for compiling each test.
+set TARGET_VECTCFLAGS_LIST [list]
 
-    lappend DEFAULT_VECTCFLAGS "-maltivec"
+# Set target-dependent vector flags, which can be overridden by using
+# dg-options in individual tests.  If the target system supports vector
+# instructions, the default action 'run', otherwise it's 'compile'.
+# Whether the test is executed can also be determined by a call to
+# check_vect within the test.
+if [istarget "powerpc*-*-*"] {
     if [check_vmx_hw_available] {
-	set dg-do-what-default run
+ 	set target-dg-do-what-default run
+	lappend TARGET_VECTCFLAGS_LIST [list "-maltivec"]
     } else {
+	set target-dg-do-what-default compile
 	if [is-effective-target ilp32] {
 	    # Specify a cpu that supports VMX for compile-only tests.
-	    lappend DEFAULT_VECTCFLAGS "-mcpu=7400"
+	    lappend TARGET_VECTCFLAGS_LIST [list "-maltivec" "-mcpu=7400"]
+	} else {
+	    lappend TARGET_VECTCFLAGS_LIST [list "-maltivec"]
 	}
-	set dg-do-what-default compile
     }
 } elseif { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
-    lappend DEFAULT_VECTCFLAGS "-msse2"
-    set dg-do-what-default run
+    lappend TARGET_VECTCFLAGS_LIST [list "-msse2"]
+    # Enable these when there's support for them in effective-target checks
+    # and a way to determine whether a test using them can be run.
+    #lappend TARGET_VECTCFLAGS_LIST [list "-msse"]
+    #lappend TARGET_VECTCFLAGS_LIST [list "-mmmx"]
+    set target-dg-do-what-default run
 } elseif [istarget "mipsisa64*-*-*"] {
-    lappend DEFAULT_VECTCFLAGS "-mpaired-single"
-    set dg-do-what-default run
+    lappend TARGET_VECTCFLAGS_LIST [list "-mpaired-single"]
+    set target-dg-do-what-default run
 } elseif [istarget "sparc*-*-*"] {
-    lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
-    set dg-do-what-default run
+    lappend TARGET_VECTCFLAGS_LIST [list "-mcpu=ultrasparc" "-mvis"]
+    set target-dg-do-what-default run
 } elseif [istarget "alpha*-*-*"] {
-    lappend DEFAULT_VECTCFLAGS "-mmax"
+    lappend TARGET_VECTCFLAGS_LIST [list "-mmax"]
     if [check_alpha_max_hw_available] {
-	set dg-do-what-default run
+	set target-dg-do-what-default run
     } else {
-	set dg-do-what-default compile
+ 	set target-dg-do-what-default compile
     }
 } elseif [istarget "ia64-*-*"] {
-    set dg-do-what-default run
+    # This target supports hardware vectors by default.
+    set target-dg-do-what-default run
+    lappend TARGET_VECTCFLAGS_LIST ""
 } else {
     return
 }
 
+proc vect-dg-runtest { testcases default-extra-flags } {
+    global runtests TARGET_VECTCFLAGS_LIST
+    global dg-do-what-default target-dg-do-what-default
+
+    # Make this variable available to effective-target checks.
+    global target_vectcflags
+
+    foreach test $testcases {
+	# If we're only testing specific files and this isn't one of
+	# them, skip it.
+	if ![runtest_file_p $runtests $test] {
+	    continue
+	}
+
+	set nshort [file tail [file dirname $test]]/[file tail $test]
+
+	set save-dg-do-what-default ${dg-do-what-default}
+
+	foreach target_vectcflags $TARGET_VECTCFLAGS_LIST {
+	    if [string match $target_vectcflags ""] {
+		set dg-do-what-default run
+	    } else {
+		# ??? This needs to be fixed to support sse/sse2/mmx.
+		set dg-do-what-default ${target-dg-do-what-default}
+	    }
+
+	    verbose "Testing $nshort, $target_vectcflags ${dg-do-what-default}" 1
+	    dg-test $test $target_vectcflags ${default-extra-flags}
+	}
+
+	set dg-do-what-default ${save-dg-do-what-default}
+    }
+}
+
 # Initialize `dg'.
 dg-init
 
 # Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]]  \
-	"" $DEFAULT_VECTCFLAGS
-
-# Clean up.
-set dg-do-what-default ${save-dg-do-what-default}
+vect-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
+	$DEFAULT_VECTCFLAGS
 
 # All done.
 dg-finish

2005-04-18  Janis Johnson  <janis187@us.ibm.com>

	* gcc.dg/vect/vect.exp: Support generic vectors.

--- gcc.dg/vect/vect.exp.new	2005-04-18 13:53:53.000000000 -0700
+++ gcc.dg/vect/vect.exp	2005-04-18 13:54:29.000000000 -0700
@@ -24,8 +24,10 @@ load_lib gcc-dg.exp
 set DEFAULT_VECTCFLAGS [list "-O2" "-ftree-vectorize" \
   "-ftree-vectorizer-verbose=3" "-fdump-tree-vect-stats"]
 
-# Lists of flags that are used for compiling each test.
-set TARGET_VECTCFLAGS_LIST [list]
+# Lists of flags that are used for compiling each test.  The first one
+# is empty for testing generic vectors, and additional lists are for
+# each kind of hardware vector support for this target.
+set TARGET_VECTCFLAGS_LIST [list ""]
 
 # Set target-dependent vector flags, which can be overridden by using
 # dg-options in individual tests.  If the target system supports vector
@@ -68,9 +70,6 @@ if [istarget "powerpc*-*-*"] {
 } elseif [istarget "ia64-*-*"] {
     # This target supports hardware vectors by default.
     set target-dg-do-what-default run
-    lappend TARGET_VECTCFLAGS_LIST ""
-} else {
-    return
 }
 
 proc vect-dg-runtest { testcases default-extra-flags } {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]