public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Jambor <mjambor@suse.cz>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [hsa] Stricter target_follows_kernelizable_pattern
Date: Wed, 02 Sep 2015 18:46:00 -0000	[thread overview]
Message-ID: <20150902184644.GI2685@virgil.suse.cz> (raw)

Hi,

the patch below makes target_follows_kernelizable_pattern stricter by
adding a few checks for clauses that have to preclude kernelization.
Committed to the branch.

Thanks,

Martin


2015-09-02  Martin Jambor  <mjambor@suse.cz>

	* omp-low.c (target_follows_kernelizable_pattern): Parallel
	num_thread clause and non-automatic loop schedule preclude
	kernelization.
---
 gcc/ChangeLog.hsa |  6 ++++++
 gcc/omp-low.c     | 32 ++++++++++++++++++++++++++++++--
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 6c2bbe7..d6c521f 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2832,9 +2832,23 @@ target_follows_kernelizable_pattern (gomp_target *target, tree *group_size_p,
   gomp_parallel *par;
   if (!stmt || !(par = dyn_cast <gomp_parallel *> (stmt)))
     return NULL;
+
+  tree clauses = gimple_omp_parallel_clauses (par);
+  tree num_threads_clause = find_omp_clause (clauses, OMP_CLAUSE_NUM_THREADS);
+  if (num_threads_clause)
+    {
+      if (dump_enabled_p ())
+	dump_printf_loc (MSG_NOTE, tloc,
+			 "Will not turn target construct into a "
+			 "simple GPGPU kernel because there is a num_threads "
+			 "clause of the parallel construct that "
+			 "is likely to require looping \n");
+      return NULL;
+    }
+
   stmt = single_stmt_in_seq_skip_bind (gimple_omp_body (par), tloc, "parallel");
-  /* FIXME: We are currently ignoring parallel clauses and potentially also
-     sharing clauses of teams and distribute, if there are any. We need to
+  /* FIXME: We are currently ignoring parallel sharing clauses and potentially
+     also sharing clauses of teams and distribute, if there are any. We need to
      check they can be skipped.  */
   gomp_for *gfor;
   if (!stmt || !(gfor = dyn_cast <gomp_for *> (stmt)))
@@ -2859,6 +2873,20 @@ target_follows_kernelizable_pattern (gomp_target *target, tree *group_size_p,
       return NULL;
     }
 
+  clauses = gimple_omp_for_clauses (gfor);
+  tree for_sched_clause = find_omp_clause (clauses, OMP_CLAUSE_SCHEDULE);
+
+  if (for_sched_clause
+      && OMP_CLAUSE_SCHEDULE_KIND (for_sched_clause) != OMP_CLAUSE_SCHEDULE_AUTO)
+    {
+      if (dump_enabled_p ())
+	dump_printf_loc (MSG_NOTE, tloc,
+			 "Will not turn target construct into a simple GPGPU "
+			 "kernel because the inner loop has non-automatic "
+			 "scheduling clause\n");
+      return NULL;
+    }
+
   if (teams)
     gather_inner_locals (gimple_omp_body (teams), kri);
   if (dist)
-- 
2.4.6



                 reply	other threads:[~2015-09-02 18:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20150902184644.GI2685@virgil.suse.cz \
    --to=mjambor@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    /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).