public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
[parent not found: <OF6C5E5F37.898CB82F-ONC225739A.00535CD6-C225739A.0055D0E0@LocalDomain>]
[parent not found: <OF00E1B419.C8031571-ONC225736D.004CEA3F-C2257399.004BCE3D@LocalDomain>]
* [PATCH 1/2][Modulo-sched] Fix the direction of the scheduling window
@ 2007-11-20 15:54 Revital1 Eres
  0 siblings, 0 replies; 6+ messages in thread
From: Revital1 Eres @ 2007-11-20 15:54 UTC (permalink / raw)
  To: Ayal Zaks; +Cc: Andrey Belevantsev, Alexander Monakov, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]


Hello,

When determining the scheduling window of a node all types of edges are
taken into account.  Currently when a node has both predecessors and
successors it will be set close to it's predecessors. In fact it can
be that a node has only one successor with true dep edge but it will be
scheduled close to it's allegedly predecessor; because of the anti-dep
edge between the two nodes.  Trying to avoid this confusion and reduce the
life range of registers we choose to set the scheduled node close to it's
predecessors or close to it's successors based on true deps edges only.

This change makes SMS succeed on the attached testcase with -funroll-loops
on SPU.  The testcase was provided by Vladimir.

Bootstrapped and tested together with the follow on patch (2/2) on ppc,
SPU and x86 with no new regressions.

:ADDPATCH modulo-sched:

OK for mainline?

Thanks,
Revital

2007-11-20  Ayal Zaks  <zaks@il.ibm.com>
            Revital Eres  <eres@il.ibm.com>

        * modulo-sched.c (get_sched_window): Fix the direction of the
        scheduling window and add dump info.

testsuite:

2007-11-20  Vladimir Yanovsky  <yanov@il.ibm.com>

        * gcc.dg/sms-3.c: New testcase.


(See attached file: patch_win_dir_again.txt)(See attached file:
sms-3.c.txt)

[-- Attachment #2: patch_win_dir_again.txt --]
[-- Type: text/plain, Size: 3457 bytes --]

Index: modulo-sched.c
===================================================================
--- modulo-sched.c	(revision 129721)
+++ modulo-sched.c	(working copy)
@@ -1344,8 +1344,8 @@
                 MAX (early_start, p_st + e->latency - (e->distance * ii));
 
               if (dump_file)
-                fprintf (dump_file, "pred st = %d; early_start = %d; ", p_st,
-                         early_start);
+                fprintf (dump_file, "pred st = %d; early_start = %d; "
+                         " latency: %d", p_st, early_start, e->latency);
 
 	      if (e->data_type == MEM_DEP)
 		end = MIN (end, SCHED_TIME (v_node) + ii - 1);
@@ -1355,6 +1355,7 @@
 	}
       start = early_start;
       end = MIN (end, early_start + ii);
+      /* Schedule the node close to it's processors.  */
       step = 1;
 
       if (dump_file)
@@ -1391,8 +1392,8 @@
                                 s_st - e->latency + (e->distance * ii));
 
               if (dump_file)
-                fprintf (dump_file, "succ st = %d; late_start = %d;", s_st,
-                         late_start);
+                fprintf (dump_file, "succ st = %d; late_start = %d;"
+                         " latency = %d", s_st, late_start, e->latency);
 
 	      if (e->data_type == MEM_DEP)
 		end = MAX (end, SCHED_TIME (v_node) - ii + 1);
@@ -1406,6 +1407,7 @@
 	}
       start = late_start;
       end = MAX (end, late_start - ii);
+      /* Schedule the node close to it's successors.  */
       step = -1;
 
       if (dump_file)
@@ -1419,6 +1421,8 @@
     {
       int early_start = INT_MIN;
       int late_start = INT_MAX;
+      int count_preds = 0;
+      int count_succs = 0;
 
       start = INT_MIN;
       end = INT_MAX;
@@ -1446,9 +1450,12 @@
 				 - (e->distance * ii));
 
               if (dump_file)
-                fprintf (dump_file, "pred st = %d; early_start = %d;", p_st,
-                         early_start);
+                fprintf (dump_file, "pred st = %d; early_start = %d;"
+                         " latency = %d", p_st, early_start, e->latency);
 
+              if (e->type == TRUE_DEP && e->data_type == REG_DEP)
+                count_preds++;
+
 	      if (e->data_type == MEM_DEP)
 		end = MIN (end, SCHED_TIME (v_node) + ii - 1);
 	    }
@@ -1479,10 +1486,13 @@
 				s_st - e->latency
 				+ (e->distance * ii));
 
-               if (dump_file)
-                 fprintf (dump_file, "succ st = %d; late_start = %d;", s_st,
-                          late_start);
+              if (dump_file)
+                fprintf (dump_file, "succ st = %d; late_start = %d;"
+                         " latency = %d", s_st, late_start, e->latency);
 
+               if (e->type == TRUE_DEP && e->data_type == REG_DEP)
+                 count_succs++;
+
 	      if (e->data_type == MEM_DEP)
 		start = MAX (start, SCHED_TIME (v_node) - ii + 1);
 	    }
@@ -1493,6 +1503,16 @@
       start = MAX (start, early_start);
       end = MIN (end, MIN (early_start + ii, late_start + 1));
       step = 1;
+      /* If there are more successors than processors schedule the
+         node close to it's successors.  */
+      if (count_succs >= count_preds)
+        {
+          int old_start = start;
+
+          start = end - 1;
+          end = old_start - 1;
+          step = -1;
+        }
     }
   else /* psp is empty && pss is empty.  */
     {

[-- Attachment #3: sms-3.c.txt --]
[-- Type: text/plain, Size: 332 bytes --]

/* { dg-do compile } */
/* { dg-options "-O2 -fmodulo-sched -funroll-loops -dm" } */

int X[100];
int Y[100];

int
foo (int len, long *result)
{
  int i;

  len = 1000;
  long res = *result;
  for (i = 0; i < len; i++)
    res += X[i] * Y[i];

  *result = res;
}

/* { dg-final { cleanup-rtl-dump "sms" } } */


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-11-30 20:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <OFF029C83D.426DE8BE-ONC225739B.0031BAF0-C22573A1.0030FD7A@LocalDomain>
2007-11-30 22:19 ` [PATCH 1/2][Modulo-sched] Fix the direction of the scheduling window Ayal Zaks
     [not found] <OF6C5E5F37.898CB82F-ONC225739A.00535CD6-C225739A.0055D0E0@LocalDomain>
2007-11-21 18:33 ` Revital1 Eres
2007-11-21 19:02   ` Revital1 Eres
2007-11-28 14:17 ` Revital1 Eres
     [not found] <OF00E1B419.C8031571-ONC225736D.004CEA3F-C2257399.004BCE3D@LocalDomain>
2007-11-21 17:24 ` Ayal Zaks
2007-11-20 15:54 Revital1 Eres

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).