diff mbox series

[RFC] Adds a target hook

Message ID CAELXzTPbd+Dn4uUEocGffHiDn0f1_bWNQiTV7MxVWO9psMYTjQ@mail.gmail.com
State New
Headers show
Series [RFC] Adds a target hook | expand

Commit Message

Kugan Vivekanandarajah Feb. 12, 2018, 11:53 p.m. UTC
Adds a target hook TARGET_HW_MAX_MEM_READ_STREAMS. Loop unroller, if
defined, will try to limit the unrolling factor based on this.


gcc/ChangeLog:

2018-02-12  Kugan Vivekanandarajah  <kuganv@linaro.org>

    * doc/tm.texi.in (TARGET_HW_MAX_MEM_READ_STREAMS): Dcoument.
    * doc/tm.texi: Regenerate.
    * target.def (hw_max_mem_read_streams): New target hook.

Comments

Kyrill Tkachov Feb. 13, 2018, 9:58 a.m. UTC | #1
Hi Kugan,

On 12/02/18 23:53, Kugan Vivekanandarajah wrote:
> Adds a target hook TARGET_HW_MAX_MEM_READ_STREAMS. Loop unroller, if
> defined, will try to limit the unrolling factor based on this.
>

Could you elaborate a bit on this, in particular how is this different
from the PARAM_SIMULTANEOUS_PREFETCHES param that describes
"the number of prefetches that can run at the same time".
The descriptions seem very similar to me...

Incidentally, since this is expected to always be an integer, maybe
make it into a param so it is consistent with the other prefetch-related
tuning numbers?

Thanks,
Kyrill

>
> gcc/ChangeLog:
>
> 2018-02-12  Kugan Vivekanandarajah <kuganv@linaro.org>
>
>     * doc/tm.texi.in (TARGET_HW_MAX_MEM_READ_STREAMS): Dcoument.
>     * doc/tm.texi: Regenerate.
>     * target.def (hw_max_mem_read_streams): New target hook.
Kugan Vivekanandarajah Feb. 13, 2018, 10:32 p.m. UTC | #2
Hi Kyrill,

Thanks for the review.

On 13 February 2018 at 20:58, Kyrill  Tkachov
<kyrylo.tkachov@foss.arm.com> wrote:
> Hi Kugan,
>
> On 12/02/18 23:53, Kugan Vivekanandarajah wrote:
>>
>> Adds a target hook TARGET_HW_MAX_MEM_READ_STREAMS. Loop unroller, if
>> defined, will try to limit the unrolling factor based on this.
>>
>
> Could you elaborate a bit on this, in particular how is this different
> from the PARAM_SIMULTANEOUS_PREFETCHES param that describes
> "the number of prefetches that can run at the same time".
> The descriptions seem very similar to me...

You are right that they are similar. I wanted to keep it separate
because not all the micro-architectures might prefer limiting unroll
factor this way. If we keep this separate, we will have the option to
disable this without affecting the rest.

> Incidentally, since this is expected to always be an integer, maybe
> make it into a param so it is consistent with the other prefetch-related
> tuning numbers?

Ok, I will change it into param in the next iteration.

Thanks,
Kugan
>
> Thanks,
> Kyrill
>
>
>>
>> gcc/ChangeLog:
>>
>> 2018-02-12  Kugan Vivekanandarajah <kuganv@linaro.org>
>>
>>     * doc/tm.texi.in (TARGET_HW_MAX_MEM_READ_STREAMS): Dcoument.
>>     * doc/tm.texi: Regenerate.
>>     * target.def (hw_max_mem_read_streams): New target hook.
>
>
diff mbox series

Patch

From 95287a11980ff64ee473406d832d75f96204c6e9 Mon Sep 17 00:00:00 2001
From: Kugan Vivekanandarajah <kugan.vivekanandarajah@linaro.org>
Date: Mon, 12 Feb 2018 10:42:29 +1100
Subject: [PATCH 1/4] add-target-hook

Change-Id: I1789769c27786babc6a071d12049c72d7afed00e
---
 gcc/doc/tm.texi    | 6 ++++++
 gcc/doc/tm.texi.in | 2 ++
 gcc/target.def     | 9 +++++++++
 3 files changed, 17 insertions(+)

diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 7f02b0d..08f4e2a 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -11718,6 +11718,12 @@  is required only when the target has special constraints like maximum
 number of memory accesses.
 @end deftypefn
 
+@deftypefn {Target Hook} signed TARGET_HW_MAX_MEM_READ_STREAMS (void)
+This target hook returns the maximum number of memory read streams
+ that hw prefers.  Tree loop unroller will use this while deciding
+ unroll factor.
+@end deftypefn
+
 @defmac POWI_MAX_MULTS
 If defined, this macro is interpreted as a signed integer C expression
 that specifies the maximum number of floating point multiplications
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 90c24be..e222372 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -7927,6 +7927,8 @@  build_type_attribute_variant (@var{mdecl},
 
 @hook TARGET_LOOP_UNROLL_ADJUST
 
+@hook TARGET_HW_MAX_MEM_READ_STREAMS
+
 @defmac POWI_MAX_MULTS
 If defined, this macro is interpreted as a signed integer C expression
 that specifies the maximum number of floating point multiplications
diff --git a/gcc/target.def b/gcc/target.def
index aeb41df..29295ae 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -2751,6 +2751,15 @@  number of memory accesses.",
  unsigned, (unsigned nunroll, struct loop *loop),
  NULL)
 
+/* Return a new value for loop unroll size.  */
+DEFHOOK
+(hw_max_mem_read_streams,
+ "This target hook returns the maximum number of memory read streams\n\
+ that hw prefers.  Tree loop unroller will use this while deciding\n\
+ unroll factor.",
+ signed, (void),
+ NULL)
+
 /* True if X is a legitimate MODE-mode immediate operand.  */
 DEFHOOK
 (legitimate_constant_p,
-- 
2.7.4