public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 3/8] Remove cached_first_cycle_multipass_dfa_lookahead and cached_issue_rate
@ 2014-10-21  3:21 Maxim Kuvyrkov
  2014-10-21 15:53 ` Vladimir Makarov
  0 siblings, 1 reply; 4+ messages in thread
From: Maxim Kuvyrkov @ 2014-10-21  3:21 UTC (permalink / raw)
  To: GCC Patches; +Cc: Vladimir Makarov, Jeff Law

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

Hi,

This patch cleans up (removes) cached_first_cycle_multipass_dfa_lookahead and cached_issue_rate.

These seem to be an artifact from the scheduler refactoring 10+ years ago.  They assume that dfa_lookahead and issue_rate can change mid-way through scheduling, which is never the case.  All backends currently treat dfa_lookahead and issue_rate as constants for the duration of scheduling passes.

Bootstrapped on x86_64-linux-gnu.  Regression testing is in progress.  OK to commit if no regressions?

[ChangeLog is part of the git patch]

--
Maxim Kuvyrkov
www.linaro.org



[-- Attachment #2: 0003-Remove-cached_first_cycle_multipass_dfa_lookahead-an.patch --]
[-- Type: application/octet-stream, Size: 3280 bytes --]

From 3c26ff02a08d7b107a558b2033787f810ca900c9 Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
Date: Mon, 20 Oct 2014 23:30:12 +0100
Subject: [PATCH 3/8] Remove cached_first_cycle_multipass_dfa_lookahead and
 cached_issue_rate

	* haifa-sched.c (cached_first_cycle_multipass_dfa_lookahead,)
	(cached_issue_rate): Remove.  Use dfa_lookahead and issue_rate instead.
	(max_issue, choose_ready, sched_init): Update.
---
 gcc/haifa-sched.c |   30 +++++-------------------------
 1 file changed, 5 insertions(+), 25 deletions(-)

diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index f8549a0..4f9648c 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -5471,15 +5471,6 @@ int dfa_lookahead;
    could achieve DFA_LOOKAHEAD ** N , where N is the queue length.  */
 static int max_lookahead_tries;
 
-/* The following value is value of hook
-   `first_cycle_multipass_dfa_lookahead' at the last call of
-   `max_issue'.  */
-static int cached_first_cycle_multipass_dfa_lookahead = 0;
-
-/* The following value is value of `issue_rate' at the last call of
-   `sched_init'.  */
-static int cached_issue_rate = 0;
-
 /* The following function returns maximal (or close to maximal) number
    of insns which can be issued on the same cycle and one of which
    insns is insns with the best rank (the first insn in READY).  To
@@ -5508,9 +5499,8 @@ max_issue (struct ready_list *ready, int privileged_n, state_t state,
 	      && privileged_n <= n_ready);
 
   /* Init MAX_LOOKAHEAD_TRIES.  */
-  if (cached_first_cycle_multipass_dfa_lookahead != dfa_lookahead)
+  if (max_lookahead_tries == 0)
     {
-      cached_first_cycle_multipass_dfa_lookahead = dfa_lookahead;
       max_lookahead_tries = 100;
       for (i = 0; i < issue_rate; i++)
 	max_lookahead_tries *= dfa_lookahead;
@@ -5673,8 +5663,6 @@ static int
 choose_ready (struct ready_list *ready, bool first_cycle_insn_p,
 	      rtx_insn **insn_ptr)
 {
-  int lookahead;
-
   if (dbg_cnt (sched_insn) == false)
     {
       if (nonscheduled_insns_begin == NULL_RTX)
@@ -5695,11 +5683,7 @@ choose_ready (struct ready_list *ready, bool first_cycle_insn_p,
       return -1;
     }
 
-  lookahead = 0;
-
-  if (targetm.sched.first_cycle_multipass_dfa_lookahead)
-    lookahead = targetm.sched.first_cycle_multipass_dfa_lookahead ();
-  if (lookahead <= 0 || SCHED_GROUP_P (ready_element (ready, 0))
+  if (dfa_lookahead <= 0 || SCHED_GROUP_P (ready_element (ready, 0))
       || DEBUG_INSN_P (ready_element (ready, 0)))
     {
       if (targetm.sched.dispatch (NULL, IS_DISPATCH_ON))
@@ -6883,18 +6867,14 @@ sched_init (void)
   else
     issue_rate = 1;
 
-  if (cached_issue_rate != issue_rate)
-    {
-      cached_issue_rate = issue_rate;
-      /* To invalidate max_lookahead_tries:  */
-      cached_first_cycle_multipass_dfa_lookahead = 0;
-    }
-
   if (targetm.sched.first_cycle_multipass_dfa_lookahead)
     dfa_lookahead = targetm.sched.first_cycle_multipass_dfa_lookahead ();
   else
     dfa_lookahead = 0;
 
+  /* Set to "0" so that we recalculate.  */
+  max_lookahead_tries = 0;
+
   if (targetm.sched.init_dfa_pre_cycle_insn)
     targetm.sched.init_dfa_pre_cycle_insn ();
 
-- 
1.7.9.5


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

* Re: [PATCH 3/8] Remove cached_first_cycle_multipass_dfa_lookahead and cached_issue_rate
  2014-10-21  3:21 [PATCH 3/8] Remove cached_first_cycle_multipass_dfa_lookahead and cached_issue_rate Maxim Kuvyrkov
@ 2014-10-21 15:53 ` Vladimir Makarov
  2014-10-23  3:34   ` Maxim Kuvyrkov
  0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Makarov @ 2014-10-21 15:53 UTC (permalink / raw)
  To: gcc-patches

On 10/20/2014 11:16 PM, Maxim Kuvyrkov wrote:
> Hi,
>
> This patch cleans up (removes) cached_first_cycle_multipass_dfa_lookahead and cached_issue_rate.
>
> These seem to be an artifact from the scheduler refactoring 10+ years ago.  They assume that dfa_lookahead and issue_rate can change mid-way through scheduling, which is never the case.  All backends currently treat dfa_lookahead and issue_rate as constants for the duration of scheduling passes.
>
> Bootstrapped on x86_64-linux-gnu.  Regression testing is in progress.  OK to commit if no regressions?
>
Yes.  the patch for issue rate itself is ok but you should have modified
doc/tm.texi too for dfa lookahead hook saying that it should be a
constant (issue rate already has such clause).

On the other hand I'd not assume that dfa look ahead is a constant.  In
future we could make it non-constant to differentiate non-hot and hot
functions to speed up the scheduler as dfa look ahead scheduling is
pretty expensive.

So issue rate change is ok but I'd not rush to change dfa look ahead
related code.

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

* Re: [PATCH 3/8] Remove cached_first_cycle_multipass_dfa_lookahead and cached_issue_rate
  2014-10-21 15:53 ` Vladimir Makarov
@ 2014-10-23  3:34   ` Maxim Kuvyrkov
  2014-10-24  3:21     ` Vladimir Makarov
  0 siblings, 1 reply; 4+ messages in thread
From: Maxim Kuvyrkov @ 2014-10-23  3:34 UTC (permalink / raw)
  To: Vladimir Makarov; +Cc: gcc-patches

On Oct 22, 2014, at 4:53 AM, Vladimir Makarov <vmakarov@redhat.com> wrote:

> On 10/20/2014 11:16 PM, Maxim Kuvyrkov wrote:
>> Hi,
>> 
>> This patch cleans up (removes) cached_first_cycle_multipass_dfa_lookahead and cached_issue_rate.
>> 
>> These seem to be an artifact from the scheduler refactoring 10+ years ago.  They assume that dfa_lookahead and issue_rate can change mid-way through scheduling, which is never the case.  All backends currently treat dfa_lookahead and issue_rate as constants for the duration of scheduling passes.
>> 
>> Bootstrapped on x86_64-linux-gnu.  Regression testing is in progress.  OK to commit if no regressions?
>> 
> Yes.  the patch for issue rate itself is ok but you should have modified
> doc/tm.texi too for dfa lookahead hook saying that it should be a
> constant (issue rate already has such clause).
> 
> On the other hand I'd not assume that dfa look ahead is a constant.  In
> future we could make it non-constant to differentiate non-hot and hot
> functions to speed up the scheduler as dfa look ahead scheduling is
> pretty expensive.
> 
> So issue rate change is ok but I'd not rush to change dfa look ahead
> related code.

It is trivial to prove that currently cached_first_cycle_multipass_dfa_lookahead always has the same value as dfa_lookahead.  And, even should targetm.sched.first_cycle_multipass_dfa_lookahead start returning different values, max_issue will happily continue to use the value that the hook returned in sched_init().

Also, your suggestion to use different dfa_lookahead values for hot/cold functions is not affected by this patch.  The values of dfa_lookahead variable have scope of the scheduling pass, which is invoked separately for every function.

I guess, you could, potentially, start differentiating values of dfa_lookahead based on whether a basic_block is hot or cold, but handling this scenario would require significant changes throughout the scheduler.

To summarize, dfa_lookahead is currently a pass-time invariant, that is free to change between invocations of the scheduler pass.  Cached_first_cycle_multipass_dfa_lookahead always holds the same value as dfa_lookahead, and, as such, is extraneous.

Thank you,

--
Maxim Kuvyrkov
www.linaro.org



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

* Re: [PATCH 3/8] Remove cached_first_cycle_multipass_dfa_lookahead and cached_issue_rate
  2014-10-23  3:34   ` Maxim Kuvyrkov
@ 2014-10-24  3:21     ` Vladimir Makarov
  0 siblings, 0 replies; 4+ messages in thread
From: Vladimir Makarov @ 2014-10-24  3:21 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: gcc-patches

On 2014-10-22 11:29 PM, Maxim Kuvyrkov wrote:
> On Oct 22, 2014, at 4:53 AM, Vladimir Makarov <vmakarov@redhat.com> wrote:
>
>> On 10/20/2014 11:16 PM, Maxim Kuvyrkov wrote:
>>> Hi,
>>>
>>> This patch cleans up (removes) cached_first_cycle_multipass_dfa_lookahead and cached_issue_rate.
>>>
>>> These seem to be an artifact from the scheduler refactoring 10+ years ago.  They assume that dfa_lookahead and issue_rate can change mid-way through scheduling, which is never the case.  All backends currently treat dfa_lookahead and issue_rate as constants for the duration of scheduling passes.
>>>
>>> Bootstrapped on x86_64-linux-gnu.  Regression testing is in progress.  OK to commit if no regressions?
>>>
>> Yes.  the patch for issue rate itself is ok but you should have modified
>> doc/tm.texi too for dfa lookahead hook saying that it should be a
>> constant (issue rate already has such clause).
>>
>> On the other hand I'd not assume that dfa look ahead is a constant.  In
>> future we could make it non-constant to differentiate non-hot and hot
>> functions to speed up the scheduler as dfa look ahead scheduling is
>> pretty expensive.
>>
>> So issue rate change is ok but I'd not rush to change dfa look ahead
>> related code.
>
> It is trivial to prove that currently cached_first_cycle_multipass_dfa_lookahead always has the same value as dfa_lookahead.  And, even should targetm.sched.first_cycle_multipass_dfa_lookahead start returning different values, max_issue will happily continue to use the value that the hook returned in sched_init().
>
> Also, your suggestion to use different dfa_lookahead values for hot/cold functions is not affected by this patch.  The values of dfa_lookahead variable have scope of the scheduling pass, which is invoked separately for every function.
>
> I guess, you could, potentially, start differentiating values of dfa_lookahead based on whether a basic_block is hot or cold, but handling this scenario would require significant changes throughout the scheduler.
>
> To summarize, dfa_lookahead is currently a pass-time invariant, that is free to change between invocations of the scheduler pass.  Cached_first_cycle_multipass_dfa_lookahead always holds the same value as dfa_lookahead, and, as such, is extraneous.
>

Ok, then.  It was a temporary intermediate stage very long ago.  But 
temporary solutions become permanent ones.  I don't think I'll find a 
time to work on implementing such feature (differentiating lookahead for 
cold/hot BBs).

The patch is ok without my previous request.

Thanks, Maxim.



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

end of thread, other threads:[~2014-10-24  3:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-21  3:21 [PATCH 3/8] Remove cached_first_cycle_multipass_dfa_lookahead and cached_issue_rate Maxim Kuvyrkov
2014-10-21 15:53 ` Vladimir Makarov
2014-10-23  3:34   ` Maxim Kuvyrkov
2014-10-24  3:21     ` Vladimir Makarov

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).