Re: [PATCH 0/7] S/390: Rework instruction scheduling.

2019-03-12 Thread Andreas Krebbel
On 12.03.19 11:00, Robin Dapp wrote:
>> Please adjust the year and the author in gcc/config/s390/3906.md. Ok with 
>> that change.
> 
> Changed that and also simplified the longrunning checks.
> 
> gcc/ChangeLog:
> 
> 2019-03-12  Robin Dapp  
> 
> * config/s390/s390.c (LONGRUNNING_THRESHOLD): Remove.
> (s390_is_fpd): Add.
> (s390_is_fxd): Add.
> (s390_is_longrunning): Add.
> (s390_sched_score): Use new functions.
> (s390_sched_variable_issue): Use new functions.
> 

Ok. Thanks!

Andreas



Re: [PATCH 0/7] S/390: Rework instruction scheduling.

2019-03-12 Thread Robin Dapp
> Please adjust the year and the author in gcc/config/s390/3906.md. Ok with 
> that change.

Changed that and also simplified the longrunning checks.

gcc/ChangeLog:

2019-03-12  Robin Dapp  

* config/s390/s390.c (LONGRUNNING_THRESHOLD): Remove.
(s390_is_fpd): Add.
(s390_is_fxd): Add.
(s390_is_longrunning): Add.
(s390_sched_score): Use new functions.
(s390_sched_variable_issue): Use new functions.
>From f92c9095f622453baf9607d1669b1f7e7048aae8 Mon Sep 17 00:00:00 2001
From: Robin Dapp 
Date: Wed, 27 Feb 2019 11:16:07 +0100
Subject: [PATCH 3/8] S/390: Change handling of long-running instructions.
This patch makes the detection of long-running instructions
independent of their latency but checks the execution unit.

---
 gcc/config/s390/s390.c | 80 +++---
 1 file changed, 60 insertions(+), 20 deletions(-)

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 95a4460dcf5..f93a94550cc 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -349,12 +349,11 @@ static int last_scheduled_unit_distance[MAX_SCHED_UNITS];
 
 #define NUM_SIDES 2
 static int current_side = 1;
-#define LONGRUNNING_THRESHOLD 20
 
 /* Estimate of number of cycles a long-running insn occupies an
execution unit.  */
-static unsigned fxd_longrunning[NUM_SIDES];
-static unsigned fpd_longrunning[NUM_SIDES];
+static int fxd_longrunning[NUM_SIDES];
+static int fpd_longrunning[NUM_SIDES];
 
 /* The maximum score added for an instruction whose unit hasn't been
in use for MAX_SCHED_MIX_DISTANCE steps.  Increase this value to
@@ -14357,6 +14356,35 @@ s390_get_unit_mask (rtx_insn *insn, int *units)
   return mask;
 }
 
+static bool
+s390_is_fpd (rtx_insn *insn)
+{
+  if (insn == NULL_RTX)
+return false;
+
+  return get_attr_z13_unit_fpd (insn) || get_attr_z14_unit_fpd (insn);
+}
+
+static bool
+s390_is_fxd (rtx_insn *insn)
+{
+  if (insn == NULL_RTX)
+return false;
+
+  return get_attr_z13_unit_fxd (insn) || get_attr_z14_unit_fxd (insn);
+}
+
+/* Returns TRUE if INSN is a long-running instruction.  */
+static bool
+s390_is_longrunning (rtx_insn *insn)
+{
+  if (insn == NULL_RTX)
+return false;
+
+  return s390_is_fxd (insn) || s390_is_fpd (insn);
+}
+
+
 /* Return the scheduling score for INSN.  The higher the score the
better.  The score is calculated from the OOO scheduling attributes
of INSN and the scheduling state s390_sched_state.  */
@@ -14432,20 +14460,34 @@ s390_sched_score (rtx_insn *insn)
 	  score += (last_scheduled_unit_distance[i] * MAX_SCHED_MIX_SCORE /
 		MAX_SCHED_MIX_DISTANCE);
 
-  unsigned latency = insn_default_latency (insn);
-
   int other_side = 1 - current_side;
 
   /* Try to delay long-running insns when side is busy.  */
-  if (latency > LONGRUNNING_THRESHOLD)
+  if (s390_is_longrunning (insn))
 	{
-	  if (get_attr_z13_unit_fxu (insn) && fxd_longrunning[current_side]
-	  && fxd_longrunning[other_side] <= fxd_longrunning[current_side])
-	score = MAX (0, score - 10);
+	  if (s390_is_fxd (insn))
+	{
+	  if (fxd_longrunning[sched_state.side]
+		  && fxd_longrunning[other_side]
+		  <= fxd_longrunning[sched_state.side])
+		score = MAX (0, score - 10);
+
+	  else if (fxd_longrunning[other_side]
+		  >= fxd_longrunning[sched_state.side])
+		score += 10;
+	}
 
-	  if (get_attr_z13_unit_vfu (insn) && fpd_longrunning[current_side]
-	  && fpd_longrunning[other_side] <= fpd_longrunning[current_side])
-	score = MAX (0, score - 10);
+	  if (s390_is_fpd (insn))
+	{
+	  if (fpd_longrunning[sched_state.side]
+		  && fpd_longrunning[other_side]
+		  <= fpd_longrunning[sched_state.side])
+		score = MAX (0, score - 10);
+
+	  else if (fpd_longrunning[other_side]
+		  >= fpd_longrunning[sched_state.side])
+		score += 10;
+	}
 	}
 }
 
@@ -14629,19 +14671,17 @@ s390_sched_variable_issue (FILE *file, int verbose, rtx_insn *insn, int more)
 
   for (int i = 0; i < 2; i++)
 	{
-	  if (fxd_longrunning[i] >= 1)
-	fxd_longrunning[i] -= 1;
-	  if (fpd_longrunning[i] >= 1)
-	fpd_longrunning[i] -= 1;
+	  fxd_longrunning[i] = MAX (0, fxd_longrunning[i] - 1);
+	  fpd_longrunning[i] = MAX (0, fpd_longrunning[i] - 1);
 	}
 
   unsigned latency = insn_default_latency (insn);
-  if (latency > LONGRUNNING_THRESHOLD)
+  if (s390_is_longrunning (insn))
 	{
-	  if (get_attr_z13_unit_fxu (insn))
-	fxd_longrunning[current_side] = latency;
+	  if (s390_is_fxd (insn))
+	fxd_longrunning[sched_state.side] = latency;
 	  else
-	fpd_longrunning[current_side] = latency;
+	fpd_longrunning[sched_state.side] = latency;
 	}
 
   if (verbose > 5)
-- 
2.17.0



Re: [PATCH 0/7] S/390: Rework instruction scheduling.

2019-03-11 Thread Andreas Krebbel
On 11.03.19 13:53, Robin Dapp wrote:
> Hi,
> 
> this patch set adds new pipeline descriptions for z13 and z14.  Based
> on that, the scoring and some properties are handled differently in
> the scheduler hooks.
> 
> Regards
>  Robin
> 
> Robin Dapp (7):
>   S/390: Change z13 pipeline description.
>   S/390: Add z14 pipeline description.
>   S/390: Change handling of long-running instructions.
>   S/390: Change handling of group end.
>   S/390: Add side to schedule-mix calculations.
>   S/390: Add handling for group-of-two instructions.
>   S/390: Tune scheduling parameters.
> 
>  gcc/config/s390/2964.md | 373 ++--
>  gcc/config/s390/3906.md | 281 ++
>  gcc/config/s390/s390.c  | 303 +++-
>  gcc/config/s390/s390.h  |   2 +-
>  gcc/config/s390/s390.md |   3 +
>  5 files changed, 679 insertions(+), 283 deletions(-)
>  create mode 100644 gcc/config/s390/3906.md
> 

Please adjust the year and the author in gcc/config/s390/3906.md. Ok with that 
change.

Thanks!

Andreas



[PATCH 0/7] S/390: Rework instruction scheduling.

2019-03-11 Thread Robin Dapp
Hi,

this patch set adds new pipeline descriptions for z13 and z14.  Based
on that, the scoring and some properties are handled differently in
the scheduler hooks.

Regards
 Robin

Robin Dapp (7):
  S/390: Change z13 pipeline description.
  S/390: Add z14 pipeline description.
  S/390: Change handling of long-running instructions.
  S/390: Change handling of group end.
  S/390: Add side to schedule-mix calculations.
  S/390: Add handling for group-of-two instructions.
  S/390: Tune scheduling parameters.

 gcc/config/s390/2964.md | 373 ++--
 gcc/config/s390/3906.md | 281 ++
 gcc/config/s390/s390.c  | 303 +++-
 gcc/config/s390/s390.h  |   2 +-
 gcc/config/s390/s390.md |   3 +
 5 files changed, 679 insertions(+), 283 deletions(-)
 create mode 100644 gcc/config/s390/3906.md

-- 
2.17.0