public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom de Vries <Tom_deVries@mentor.com>
To: "gcc-patches@gnu.org" <gcc-patches@gnu.org>,
	Thomas Schwinge	<thomas@codesourcery.com>,
	Nathan Sidwell <nathan_sidwell@mentor.com>,
	"Allen, Randy" <randy_allen@mentor.com>
Subject: [PATCH] Add fopt-info-oacc
Date: Mon, 18 Jan 2016 17:27:00 -0000	[thread overview]
Message-ID: <569D2059.4010105@mentor.com> (raw)

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

Hi,

This patch introduces an option fopt-info-oacc.

When using the option like this with a kernels region in kernels-loop.c 
that parloops does not manage to parallelize:
...
$ gcc kernels-loop.c -S -O2 -fopenacc -fopt-info-oacc-all
...

we get a message:
...
kernels-loop.c:23:9: note: kernels region executed sequentially. 
Consider mapping it to host execution, to avoid data copy penalty.
...

Any comments?

Thanks,
- Tom

[-- Attachment #2: 0001-Add-fopt-info-oacc.patch --]
[-- Type: text/x-patch, Size: 2863 bytes --]

Add fopt-info-oacc

---
 gcc/dumpfile.c |  1 +
 gcc/dumpfile.h |  5 +++--
 gcc/omp-low.c  | 30 +++++++++++++++++++++++++++++-
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c
index 144e371..e8aa0e1 100644
--- a/gcc/dumpfile.c
+++ b/gcc/dumpfile.c
@@ -137,6 +137,7 @@ static const struct dump_option_value_info optgroup_options[] =
   {"loop", OPTGROUP_LOOP},
   {"inline", OPTGROUP_INLINE},
   {"vec", OPTGROUP_VEC},
+  {"oacc", OPTGROUP_OACC},
   {"optall", OPTGROUP_ALL},
   {NULL, 0}
 };
diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h
index c168cbf..6e1c657 100644
--- a/gcc/dumpfile.h
+++ b/gcc/dumpfile.h
@@ -97,9 +97,10 @@ enum tree_dump_index
 #define OPTGROUP_LOOP        (1 << 2)   /* Loop optimization passes */
 #define OPTGROUP_INLINE      (1 << 3)   /* Inlining passes */
 #define OPTGROUP_VEC         (1 << 4)   /* Vectorization passes */
-#define OPTGROUP_OTHER       (1 << 5)   /* All other passes */
+#define OPTGROUP_OACC        (1 << 5)   /* Openacc passes */
+#define OPTGROUP_OTHER       (1 << 6)   /* All other passes */
 #define OPTGROUP_ALL	     (OPTGROUP_IPA | OPTGROUP_LOOP | OPTGROUP_INLINE \
-                              | OPTGROUP_VEC | OPTGROUP_OTHER)
+                              | OPTGROUP_VEC | OPTGROUP_OACC | OPTGROUP_OTHER)
 
 /* Define a tree dump switch.  */
 struct dump_file_info
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index a6e3fe3..d5c3484 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -20139,6 +20139,34 @@ execute_oacc_device_lower ()
 	     : fn_level < 0 ? "Function is parallel offload\n"
 	     : "Function is routine level %d\n", fn_level);
 
+#if defined ACCEL_COMPILER
+  bool is_kernels = oacc_fn_attrib_kernels_p (attrs);
+  if (is_kernels)
+    {
+      bool all_one = true;
+      tree pos = TREE_VALUE (attrs);
+      for (unsigned ix = 0; ix != GOMP_DIM_MAX; ix++)
+	{
+	  tree tree_val = TREE_VALUE (pos);
+	  unsigned HOST_WIDE_INT val = (tree_val
+					? TREE_INT_CST_LOW (tree_val)
+					: 1);
+	  if (val != 1)
+	    {
+	      all_one = false;
+	      break;
+	    }
+	  pos = TREE_CHAIN (pos);
+	}
+
+      if (all_one)
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, cfun->function_start_locus,
+			 "Kernels region executed sequentially.  Consider"
+			 " mapping it to host execution, to avoid data copy"
+			 " penalty.\n");
+    }
+#endif
+
   unsigned outer_mask = fn_level >= 0 ? GOMP_DIM_MASK (fn_level) - 1 : 0;
   unsigned used_mask = oacc_loop_partition (loops, outer_mask);
   int dims[GOMP_DIM_MAX];
@@ -20312,7 +20340,7 @@ const pass_data pass_data_oacc_device_lower =
 {
   GIMPLE_PASS, /* type */
   "oaccdevlow", /* name */
-  OPTGROUP_NONE, /* optinfo_flags */
+  OPTGROUP_OACC, /* optinfo_flags */
   TV_NONE, /* tv_id */
   PROP_cfg, /* properties_required */
   0 /* Possibly PROP_gimple_eomp.  */, /* properties_provided */

             reply	other threads:[~2016-01-18 17:27 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87r3hac1w9.fsf@hertz.schwinge.homeip.net>
2016-01-18 17:27 ` Tom de Vries [this message]
2016-01-18 18:28   ` Sandra Loosemore
2016-01-18 20:30     ` Richard Sandiford
2016-01-21 21:55   ` [gomp4] Un-parallelized OpenACC kernels constructs with nvptx offloading: "avoid offloading" (was: [PATCH] Add fopt-info-oacc) Thomas Schwinge
2016-01-22  7:40     ` [gomp4] Un-parallelized OpenACC kernels constructs with nvptx offloading: "avoid offloading" Thomas Schwinge
2016-01-22  8:36       ` Jakub Jelinek
2016-01-22  9:00         ` Thomas Schwinge
2016-01-22 13:18         ` Bernd Schmidt
2016-01-22 13:25           ` Jakub Jelinek
2016-01-22 13:31             ` Bernd Schmidt
2016-02-04 14:47               ` Thomas Schwinge
2016-02-10 11:51                 ` Thomas Schwinge
2016-02-10 13:25                   ` Bernd Schmidt
2016-02-10 14:40                     ` Thomas Schwinge
2016-02-10 15:27                       ` Bernd Schmidt
2016-02-10 16:23                         ` Thomas Schwinge
2016-02-10 16:37                           ` Bernd Schmidt
2016-02-10 17:39                             ` Thomas Schwinge
2016-02-10 20:07                               ` Bernd Schmidt
2016-02-11 10:02                                 ` Thomas Schwinge
2016-02-11 15:58                                   ` Bernd Schmidt
2016-01-26 22:30           ` [gomp4] " Martin Jambor
2016-06-30 21:46     ` Thomas Schwinge
2016-11-03 17:59     ` [gomp4] Un-parallelized OpenACC kernels constructs with nvptx offloading: "avoid offloading" (was: [PATCH] Add fopt-info-oacc) Cesar Philippidis
2019-01-31 17:16     ` [gomp4] Un-parallelized OpenACC kernels constructs with nvptx offloading: "avoid offloading" Thomas Schwinge

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=569D2059.4010105@mentor.com \
    --to=tom_devries@mentor.com \
    --cc=gcc-patches@gnu.org \
    --cc=nathan_sidwell@mentor.com \
    --cc=randy_allen@mentor.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).