public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Frederik Harwath <frederik@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Cc: <thomas@codesourcery.com>, <sebpop@gmail.com>,
	<grosser@fim.uni-passau.de>, <rguenther@suse.de>
Subject: [PATCH 29/40] graphite: Tune parameters for OpenACC use
Date: Wed, 15 Dec 2021 16:54:36 +0100	[thread overview]
Message-ID: <20211215155447.19379-30-frederik@codesourcery.com> (raw)
In-Reply-To: <20211215155447.19379-1-frederik@codesourcery.com>

The default values of some parameters that restrict Graphite's
resource usage are too low for many OpenACC codes.  Furthermore,
exceeding the limits does not alwas lead to user-visible diagnostic
messages.

This commit increases the parameter values on OpenACC functions.  The
values were chosen to allow for the analysis of all "kernels" regions
in the SPEC ACCEL v1.3 benchmark suite.  Warnings about exceeded
Graphite-related limits are added to the -fopt-info-missed
output. Those warnings are phrased in a uniform way that intentionally
refers to the "data-dependence analysis" of "OpenACC loops" instead of
"a failure in Graphite" to make them easier to understand for users.

gcc/ChangeLog:

        * graphite-optimize-isl.c (optimize_isl): Adjust
        param_max_isl_operations value for OpenACC functions and add
        special warnings if value gets exceeded.

        * graphite-scop-detection.c (build_scops): Likewise for
        param_graphite_max_arrays_per_scop.

gcc/testsuite/ChangeLog:

        * gcc.dg/goacc/graphite-parameter-1.c: New test.
        * gcc.dg/goacc/graphite-parameter-2.c: New test.
---
 gcc/graphite-optimize-isl.c                   | 35 ++++++++++++++++---
 gcc/graphite-scop-detection.c                 | 28 ++++++++++++++-
 .../gcc.dg/goacc/graphite-parameter-1.c       | 21 +++++++++++
 .../gcc.dg/goacc/graphite-parameter-2.c       | 23 ++++++++++++
 4 files changed, 101 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/goacc/graphite-parameter-1.c
 create mode 100644 gcc/testsuite/gcc.dg/goacc/graphite-parameter-2.c

diff --git a/gcc/graphite-optimize-isl.c b/gcc/graphite-optimize-isl.c
index 019452700a49..4eecbd20b740 100644
--- a/gcc/graphite-optimize-isl.c
+++ b/gcc/graphite-optimize-isl.c
@@ -38,6 +38,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "dumpfile.h"
 #include "tree-vectorizer.h"
 #include "graphite.h"
+#include "graphite-oacc.h"


 /* get_schedule_for_node_st - Improve schedule for the schedule node.
@@ -115,6 +116,14 @@ optimize_isl (scop_p scop, bool oacc_enabled_graphite)
   int old_err = isl_options_get_on_error (scop->isl_context);
   int old_max_operations = isl_ctx_get_max_operations (scop->isl_context);
   int max_operations = param_max_isl_operations;
+
+  /* The default value for param_max_isl_operations is easily exceeded
+     by "kernels" loops in existing OpenACC codes.  Raise the values
+     significantly since analyzing those loops is crucial. */
+  if (param_max_isl_operations == 350000 /* default value */
+      && oacc_function_p (cfun))
+    max_operations = 2000000;
+
   if (max_operations)
     isl_ctx_set_max_operations (scop->isl_context, max_operations);
   isl_options_set_on_error (scop->isl_context, ISL_ON_ERROR_CONTINUE);
@@ -164,11 +173,27 @@ optimize_isl (scop_p scop, bool oacc_enabled_graphite)
          dump_user_location_t loc = find_loop_location
            (scop->scop_info->region.entry->dest->loop_father);
          if (isl_ctx_last_error (scop->isl_context) == isl_error_quota)
-           dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
-                            "loop nest not optimized, optimization timed out "
-                            "after %d operations [--param max-isl-operations]\n",
-                            max_operations);
-         else
+           {
+              if (oacc_function_p (cfun))
+               {
+                 /* Special casing for OpenACC to unify diagnostic messages
+                    here and in graphite-scop-detection.c. */
+                  dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
+                                   "data-dependence analysis of OpenACC loop "
+                                   "nest "
+                                   "failed; try increasing the value of "
+                                   "--param="
+                                   "max-isl-operations=%d.\n",
+                                   max_operations);
+                }
+              else
+                dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
+                                 "loop nest not optimized, optimization timed "
+                                 "out after %d operations [--param "
+                                 "max-isl-operations]\n",
+                                 max_operations);
+            }
+          else
            dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
                             "loop nest not optimized, ISL signalled an error\n");
        }
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index 234dbe0ec729..9a5e43a5bfc6 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -2053,6 +2053,9 @@ determine_openacc_reductions (scop_p scop)
     }
 }

+
+extern dump_user_location_t find_loop_location (class loop *);
+
 /* Find Static Control Parts (SCoP) in the current function and pushes
    them to SCOPS.  */

@@ -2106,6 +2109,11 @@ build_scops (vec<scop_p> *scops)
        }

       unsigned max_arrays = param_graphite_max_arrays_per_scop;
+
+      if (oacc_function_p (cfun)
+          && param_graphite_max_arrays_per_scop == 100 /* default value */)
+        max_arrays = 200;
+
       if (max_arrays > 0
          && scop->drs.length () >= max_arrays)
        {
@@ -2113,7 +2121,16 @@ build_scops (vec<scop_p> *scops)
                       << scop->drs.length ()
                       << " is larger than --param graphite-max-arrays-per-scop="
                       << max_arrays << ".\n");
-         free_scop (scop);
+
+          if (dump_enabled_p () && oacc_function_p (cfun))
+            dump_printf_loc (MSG_MISSED_OPTIMIZATION,
+                             find_loop_location (s->entry->dest->loop_father),
+                             "data-dependence analysis of OpenACC loop nest "
+                             "failed; try increasing the value of --param="
+                             "graphite-max-arrays-per-scop=%d.\n",
+                             max_arrays);
+
+          free_scop (scop);
          continue;
        }

@@ -2126,6 +2143,15 @@ build_scops (vec<scop_p> *scops)
                          << scop_nb_params (scop)
                          << " larger than --param graphite-max-nb-scop-params="
                          << max_dim << ".\n");
+
+          if (dump_enabled_p () && oacc_function_p (cfun))
+            dump_printf_loc (MSG_MISSED_OPTIMIZATION,
+                             find_loop_location (s->entry->dest->loop_father),
+                             "data-dependence analysis of OpenACC loop nest "
+                             "failed; try increasing the value of --param="
+                             "graphite-max-nb-scop-params=%d.\n",
+                             max_dim);
+
          free_scop (scop);
          continue;
        }
diff --git a/gcc/testsuite/gcc.dg/goacc/graphite-parameter-1.c b/gcc/testsuite/gcc.dg/goacc/graphite-parameter-1.c
new file mode 100644
index 000000000000..45adbb3f0e85
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/goacc/graphite-parameter-1.c
@@ -0,0 +1,21 @@
+/* Verify that a warning about an exceeded Graphite parameter gets
+   output as optimization information and not only as a dump message
+   for OpenACC functions. */
+
+/* { dg-additional-options "-O2 -fopt-info-missed --param=graphite-max-arrays-per-scop=1" } */
+
+extern int a[1000];
+extern int b[1000];
+
+void test ()
+{
+#pragma acc parallel loop auto
+/* { dg-missed {data-dependence analysis of OpenACC loop nest failed\; try increasing the value of --param=graphite-max-arrays-per-scop=1.} "" { target *-*-* } .-1  } */
+/* { dg-missed {'auto' loop has not been analyzed \(cf. 'graphite' dumps for more information\).} "" { target *-*-* } .-2 } */
+/* { dg-missed {.*not inlinable.*} "" { target *-*-* } .-3 } */
+  for (int i = 1; i < 995; i++)
+    a[i] = b[i + 5] + b[i - 1];
+}
+
+
+/* { dg-prune-output ".*not inlinable.*"} */
diff --git a/gcc/testsuite/gcc.dg/goacc/graphite-parameter-2.c b/gcc/testsuite/gcc.dg/goacc/graphite-parameter-2.c
new file mode 100644
index 000000000000..f2830cd62db0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/goacc/graphite-parameter-2.c
@@ -0,0 +1,23 @@
+/* Verify that a warning about an exceeded Graphite parameter gets
+   output as optimization information and not only as a dump message
+   for OpenACC functions. */
+
+/* { dg-additional-options "-O2 -fopt-info-missed --param=max-isl-operations=1" } */
+
+void test (int* restrict a, int *restrict b)
+{
+  int i = 1;
+  int j = 1;
+  int m = 0;
+
+#pragma acc parallel loop auto copyin(b) copyout(a) reduction(max:m)
+/* { dg-missed {data-dependence analysis of OpenACC loop nest failed; try increasing the value of --param=max-isl-operations=1.} "" { target *-*-* } .-1  } */
+/* { dg-missed {'auto' loop has not been analyzed \(cf. 'graphite' dumps for more information\).} "" { target *-*-* } .-2 } */
+/* { dg-missed {.*not inlinable.*} "" { target *-*-* } .-3 } */
+  for (i = 1; i < 995; i++)
+    {
+      int x = b[i] * 2;
+      for (j = 1; j < 995; j++)
+        m = m + a[i] + x;
+    }
+}
--
2.33.0

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

  parent reply	other threads:[~2021-12-15 15:56 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-15 15:54 [PATCH 00/40] OpenACC "kernels" Improvements Frederik Harwath
2021-12-15 15:54 ` [PATCH 01/40] Kernels loops annotation: C and C++ Frederik Harwath
2021-12-15 15:54 ` [PATCH 02/40] Add -fno-openacc-kernels-annotate-loops option to more testcases Frederik Harwath
2021-12-15 15:54 ` [PATCH 03/40] Kernels loops annotation: Fortran Frederik Harwath
2021-12-15 15:54 ` [PATCH 04/40] Additional Fortran testsuite fixes for kernels loops annotation pass Frederik Harwath
2021-12-15 15:54 ` [PATCH 05/40] Fix bug in processing of array dimensions in data clauses Frederik Harwath
2021-12-15 15:54 ` [PATCH 06/40] Add a "combined" flag for "acc kernels loop" etc directives Frederik Harwath
2021-12-15 15:54 ` [PATCH 07/40] Annotate inner loops in "acc kernels loop" directives (C/C++) Frederik Harwath
2021-12-15 15:54 ` [PATCH 08/40] Annotate inner loops in "acc kernels loop" directives (Fortran) Frederik Harwath
2021-12-15 15:54 ` [PATCH 09/40] Permit calls to builtins and intrinsics in kernels loops Frederik Harwath
2021-12-15 15:54 ` [PATCH 10/40] Fix patterns in Fortran tests for kernels loop annotation Frederik Harwath
2021-12-15 15:54 ` [PATCH 11/40] Clean up loop variable extraction in OpenACC " Frederik Harwath
2021-12-15 15:54 ` [PATCH 12/40] Relax some restrictions on the loop bound in " Frederik Harwath
2021-12-15 15:54 ` [PATCH 13/40] Fortran: Delinearize array accesses Frederik Harwath
2021-12-15 15:54 ` [PATCH 14/40] openacc: Move pass_oacc_device_lower after pass_graphite Frederik Harwath
2021-12-15 15:54 ` [PATCH 15/40] graphite: Extend SCoP detection dump output Frederik Harwath
2022-05-16 12:49   ` Tobias Burnus
2022-05-17  8:21     ` Richard Biener
2022-05-18 12:19       ` Harwath, Frederik
2022-05-18 12:21         ` Richard Biener
2021-12-15 15:54 ` [PATCH 16/40] graphite: Rename isl_id_for_ssa_name Frederik Harwath
2022-05-16 12:49   ` Tobias Burnus
2022-05-17  8:22     ` Richard Biener
2021-12-15 15:54 ` [PATCH 17/40] graphite: Fix minor mistakes in comments Frederik Harwath
2022-05-16 12:49   ` Tobias Burnus
2022-05-17  8:22     ` Richard Biener
2021-12-15 15:54 ` [PATCH 18/40] Move compute_alias_check_pairs to tree-data-ref.c Frederik Harwath
2021-12-15 15:54 ` [PATCH 19/40] graphite: Add runtime alias checking Frederik Harwath
2021-12-15 15:54 ` [PATCH 20/40] openacc: Use Graphite for dependence analysis in "kernels" regions Frederik Harwath
2021-12-15 15:54 ` [PATCH 21/40] openacc: Add "can_be_parallel" flag info to "graph" dumps Frederik Harwath
2021-12-15 15:54 ` [PATCH 22/40] openacc: Remove unused partitioning in "kernels" regions Frederik Harwath
2021-12-15 15:54 ` [PATCH 23/40] Add function for printing a single OMP_CLAUSE Frederik Harwath
2021-12-15 15:54 ` [PATCH 24/40] openacc: Add data optimization pass Frederik Harwath
2021-12-15 15:54 ` [PATCH 25/40] openacc: Add runtime alias checking for OpenACC kernels Frederik Harwath
2021-12-15 15:54 ` [PATCH 26/40] openacc: Warn about "independent" "kernels" loops with data-dependences Frederik Harwath
2021-12-15 15:54 ` [PATCH 27/40] openacc: Handle internal function calls in pass_lim Frederik Harwath
2021-12-15 15:54 ` [PATCH 28/40] openacc: Disable pass_pre on outlined functions analyzed by Graphite Frederik Harwath
2021-12-15 15:54 ` Frederik Harwath [this message]
2021-12-15 15:54 ` [PATCH 30/40] graphite: Adjust scop loop-nest choice Frederik Harwath
2021-12-15 15:54 ` [PATCH 31/40] graphite: Accept loops without data references Frederik Harwath
2021-12-15 15:54 ` [PATCH 32/40] Reference reduction localization Frederik Harwath
2021-12-15 15:54 ` [PATCH 33/40] Fix tree check failure with " Frederik Harwath
2021-12-15 15:54 ` [PATCH 34/40] Use more appropriate var in localize_reductions call Frederik Harwath
2021-12-15 15:54 ` [PATCH 35/40] Handle references in OpenACC "private" clauses Frederik Harwath
2021-12-15 15:54 ` [PATCH 36/40] openacc: Enable reduction variable localization for "kernels" Frederik Harwath
2021-12-15 15:54 ` [PATCH 37/40] Fix for is_gimple_reg vars to 'data kernels' Frederik Harwath
2021-12-15 15:54 ` [PATCH 38/40] openacc: fix privatization of by-reference arrays Frederik Harwath
2021-12-15 15:54 ` [PATCH 39/40] openacc: Check type for references in reduction lowering Frederik Harwath
2021-12-16 12:00 ` [PATCH 40/40] openacc: Adjust testsuite to new "kernels" handling Frederik Harwath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211215155447.19379-30-frederik@codesourcery.com \
    --to=frederik@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=grosser@fim.uni-passau.de \
    --cc=rguenther@suse.de \
    --cc=sebpop@gmail.com \
    --cc=thomas@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).