diff mbox

[omp] Create openmp -fopt-info optimization group

Message ID 20160316141251.GF9566@virgil.suse.cz
State New
Headers show

Commit Message

Martin Jambor March 16, 2016, 2:12 p.m. UTC
Hi,

the following patch does two things.  First, it creates a new optinfo
group for OpenMP and moves OpenMP lowering and expansion to this
group.  Second, it changes all gridification MSG_NOTE dumps to
MSG_MISSED_OPTIMIZATION, which is more appropriate.  (Apparently, I
remembered to change the dump about performed gridification to
MSG_OPTIMIZED_LOCATIONS last autumn but failed to do it for dumps with
failure reasons).

With these changes, users that configured their compiler with HSA can
use (for example) the -fopt-info-all-openmp option to get information
about which target constructs have been gridified and which were not:

  mjambor@virgil:~/gcc/hsa/tests/grid$ ~/gcc/hsa/inst/bin/gcc -fopenmp -O combined-hsa.c -fopt-info-all-openmp
  combined-hsa.c:9:9: note: Target construct will be turned into a gridified GPGPU kernel

or

  /home/mjambor/gcc/hsa/src/libgomp/testsuite/libgomp.c/examples-4/target_data-3.c:50:10: note: Will not turn target construct into a simple GPGPU kernel because it does not have a sole teams construct in it.

and so forth.

I have bootstrapped and tested the patch on x86_64-linux (with and
without configured HSA) and by running make info and examining the
generated info files.  Since it is only a dumping change, I'd like to
propose it for trunk even at this late stage.  If release managers
however do not think it is desirable, I'll commit it to the hsa branch
and propose to trunk again once stage1 opens.

Thanks,

Martin


2016-03-14  Martin Jambor  <mjambor@suse.cz>

	* doc/invoke.texi (-fopt-info): Document openmp optimization group.
	* doc/optinfo.texi (Optimization groups): Document OPTGROUP_OPENMP.
	* dumpfile.c (optgroup_options): Add entry for OpenMP optimizations.
	* dumpfile.h (OPTGROUP_OPENMP): New define.
	* omp-low.c (pass_data_expand_omp): Change optinfo_flags to
	OPTGROUP_OPENMP.
	(pass_data_expand_omp_ssa): Likewise.
	(pass_data_lower_omp): Likewise.
	(pass_data_omp_simd_clone): Likewise.
	(grid_find_single_omp_among_assignments_1): Changed all occurrences of
	MSG_NOTE to MSG_MISSED_OPTIMIZATION.
	(grid_find_single_omp_among_assignments): Likewise.
	(grid_target_follows_gridifiable_pattern): Likewise.
---
 gcc/doc/invoke.texi  |  2 ++
 gcc/doc/optinfo.texi |  3 +++
 gcc/dumpfile.c       |  1 +
 gcc/dumpfile.h       |  3 ++-
 gcc/omp-low.c        | 56 ++++++++++++++++++++++++++--------------------------
 5 files changed, 36 insertions(+), 29 deletions(-)
diff mbox

Patch

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 99ac11b..5c798a4 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -12194,6 +12194,8 @@  Enable dumps from all interprocedural optimizations.
 Enable dumps from all loop optimizations.
 @item inline
 Enable dumps from all inlining optimizations.
+@item openmp
+Enable dumps from OpenMP optimizations.
 @item vec
 Enable dumps from all vectorization optimizations.
 @item optall
diff --git a/gcc/doc/optinfo.texi b/gcc/doc/optinfo.texi
index 3c8fdba..20ca560 100644
--- a/gcc/doc/optinfo.texi
+++ b/gcc/doc/optinfo.texi
@@ -59,6 +59,9 @@  Loop optimization passes. Enabled by @option{-loop}.
 @item OPTGROUP_INLINE
 Inlining passes. Enabled by @option{-inline}.
 
+@item OPTGROUP_OPENMP
+OpenMP passes. Enabled by @option{-openmp}.
+
 @item OPTGROUP_VEC
 Vectorization passes. Enabled by @option{-vec}.
 
diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c
index 144e371..f2430f3 100644
--- a/gcc/dumpfile.c
+++ b/gcc/dumpfile.c
@@ -136,6 +136,7 @@  static const struct dump_option_value_info optgroup_options[] =
   {"ipa", OPTGROUP_IPA},
   {"loop", OPTGROUP_LOOP},
   {"inline", OPTGROUP_INLINE},
+  {"openmp", OPTGROUP_OPENMP},
   {"vec", OPTGROUP_VEC},
   {"optall", OPTGROUP_ALL},
   {NULL, 0}
diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h
index c168cbf..72f696b 100644
--- a/gcc/dumpfile.h
+++ b/gcc/dumpfile.h
@@ -97,7 +97,8 @@  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_OPENMP      (1 << 5)	/* OpenMP specific transformations */
+#define OPTGROUP_OTHER       (1 << 6)   /* All other passes */
 #define OPTGROUP_ALL	     (OPTGROUP_IPA | OPTGROUP_LOOP | OPTGROUP_INLINE \
                               | OPTGROUP_VEC | OPTGROUP_OTHER)
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 82dec9d..6f42717 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -13990,7 +13990,7 @@  const pass_data pass_data_expand_omp =
 {
   GIMPLE_PASS, /* type */
   "ompexp", /* name */
-  OPTGROUP_NONE, /* optinfo_flags */
+  OPTGROUP_OPENMP, /* optinfo_flags */
   TV_NONE, /* tv_id */
   PROP_gimple_any, /* properties_required */
   PROP_gimple_eomp, /* properties_provided */
@@ -14037,7 +14037,7 @@  const pass_data pass_data_expand_omp_ssa =
 {
   GIMPLE_PASS, /* type */
   "ompexpssa", /* name */
-  OPTGROUP_NONE, /* optinfo_flags */
+  OPTGROUP_OPENMP, /* optinfo_flags */
   TV_NONE, /* tv_id */
   PROP_cfg | PROP_ssa, /* properties_required */
   PROP_gimple_eomp, /* properties_provided */
@@ -17210,7 +17210,7 @@  grid_find_single_omp_among_assignments_1 (gimple_seq seq, location_t target_loc,
 	  if (*ret)
 	    {
 	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_NOTE, target_loc,
+		dump_printf_loc (MSG_MISSED_OPTIMIZATION, target_loc,
 				 "Will not turn target construct into a simple "
 				 "GPGPU kernel because %s construct contains "
 				 "multiple OpenMP constructs\n", name);
@@ -17221,7 +17221,7 @@  grid_find_single_omp_among_assignments_1 (gimple_seq seq, location_t target_loc,
       else
 	{
 	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, target_loc,
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, target_loc,
 			     "Will not turn target construct into a simple "
 			     "GPGPU kernel because %s construct contains "
 			     "a complex statement\n", name);
@@ -17244,7 +17244,7 @@  grid_find_single_omp_among_assignments (gimple_seq seq, location_t target_loc,
   if (!seq)
     {
       if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, target_loc,
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, target_loc,
 			 "Will not turn target construct into a simple "
 			 "GPGPU kernel because %s construct has empty "
 			 "body\n",
@@ -17256,7 +17256,7 @@  grid_find_single_omp_among_assignments (gimple_seq seq, location_t target_loc,
   if (grid_find_single_omp_among_assignments_1 (seq, target_loc, name, &ret))
     {
       if (!ret && dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, target_loc,
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, target_loc,
 			 "Will not turn target construct into a simple "
 			 "GPGPU kernel because %s construct does not contain"
 			 "any other OpenMP construct\n", name);
@@ -17340,7 +17340,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
   tree group_size = NULL;
   if (!teams)
     {
-      dump_printf_loc (MSG_NOTE, tloc,
+      dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 		       "Will not turn target construct into a simple "
 		       "GPGPU kernel because it does not have a sole teams "
 		       "construct in it.\n");
@@ -17354,7 +17354,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
 	{
 	case OMP_CLAUSE_NUM_TEAMS:
 	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, tloc,
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			     "Will not turn target construct into a "
 			     "gridified GPGPU kernel because we cannot "
 			     "handle num_teams clause of teams "
@@ -17363,7 +17363,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
 
 	case OMP_CLAUSE_REDUCTION:
 	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, tloc,
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			     "Will not turn target construct into a "
 			     "gridified GPGPU kernel because a reduction "
 			     "clause is present\n ");
@@ -17371,7 +17371,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
 
 	case OMP_CLAUSE_LASTPRIVATE:
 	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, tloc,
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			     "Will not turn target construct into a "
 			     "gridified GPGPU kernel because a lastprivate "
 			     "clause is present\n ");
@@ -17394,7 +17394,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
   gomp_for *dist = dyn_cast <gomp_for *> (stmt);
   if (!dist)
     {
-      dump_printf_loc (MSG_NOTE, tloc,
+      dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 		       "Will not turn target construct into a simple "
 		       "GPGPU kernel because the teams construct  does not have "
 		       "a sole distribute construct in it.\n");
@@ -17405,7 +17405,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
   if (!gimple_omp_for_combined_p (dist))
     {
       if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, tloc,
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			 "Will not turn target construct into a gridified GPGPU "
 			 "kernel because we cannot handle a standalone "
 			 "distribute construct\n ");
@@ -17414,7 +17414,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
   if (dist->collapse > 1)
     {
       if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, tloc,
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			 "Will not turn target construct into a gridified GPGPU "
 			 "kernel because the distribute construct contains "
 			 "collapse clause\n");
@@ -17427,7 +17427,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
       if (group_size && !operand_equal_p (group_size, fd.chunk_size, 0))
 	{
 	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, tloc,
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			     "Will not turn target construct into a "
 			     "gridified GPGPU kernel because the teams "
 			     "thread limit is different from distribute "
@@ -17449,7 +17449,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
 	{
 	case OMP_CLAUSE_NUM_THREADS:
 	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, tloc,
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			     "Will not turn target construct into a gridified"
 			     "GPGPU kernel because there is a num_threads "
 			     "clause of the parallel construct\n");
@@ -17457,7 +17457,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
 
 	case OMP_CLAUSE_REDUCTION:
 	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, tloc,
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			     "Will not turn target construct into a "
 			     "gridified GPGPU kernel because a reduction "
 			     "clause is present\n ");
@@ -17465,7 +17465,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
 
 	case OMP_CLAUSE_LASTPRIVATE:
 	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, tloc,
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			     "Will not turn target construct into a "
 			     "gridified GPGPU kernel because a lastprivate "
 			     "clause is present\n ");
@@ -17486,7 +17486,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
   if (gimple_omp_for_kind (gfor) != GF_OMP_FOR_KIND_FOR)
     {
       if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, tloc,
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			 "Will not turn target construct into a gridified GPGPU "
 			 "kernel because the inner loop is not a simple for "
 			 "loop\n");
@@ -17495,7 +17495,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
   if (gfor->collapse > 1)
     {
       if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, tloc,
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			 "Will not turn target construct into a gridified GPGPU "
 			 "kernel because the inner loop contains collapse "
 			 "clause\n");
@@ -17505,7 +17505,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
   if (!grid_seq_only_contains_local_assignments (gimple_omp_for_pre_body (gfor)))
     {
       if (dump_enabled_p ())
-	dump_printf_loc (MSG_NOTE, tloc,
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			 "Will not turn target construct into a gridified GPGPU "
 			 "kernel because the inner loop pre_body contains"
 			 "a complex instruction\n");
@@ -17521,7 +17521,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
 	  if (OMP_CLAUSE_SCHEDULE_KIND (clauses) != OMP_CLAUSE_SCHEDULE_AUTO)
 	    {
 	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_NOTE, tloc,
+		dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 				 "Will not turn target construct into a "
 				 "gridified GPGPU kernel because the inner "
 				 "loop has a non-automatic scheduling clause\n");
@@ -17531,7 +17531,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
 
 	case OMP_CLAUSE_REDUCTION:
 	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, tloc,
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			     "Will not turn target construct into a "
 			     "gridified GPGPU kernel because a reduction "
 			     "clause is present\n ");
@@ -17539,7 +17539,7 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
 
 	case OMP_CLAUSE_LASTPRIVATE:
 	  if (dump_enabled_p ())
-	    dump_printf_loc (MSG_NOTE, tloc,
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			     "Will not turn target construct into a "
 			     "gridified GPGPU kernel because a lastprivate "
 			     "clause is present\n ");
@@ -17561,17 +17561,17 @@  grid_target_follows_gridifiable_pattern (gomp_target *target, tree *group_size_p
       if (dump_enabled_p ())
 	{
 	  if (is_gimple_call (bad))
-	    dump_printf_loc (MSG_NOTE, tloc,
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			     "Will not turn target construct into a gridified "
 			     " GPGPU kernel because the inner loop contains "
 			     "call to a noreturn function\n");
 	  if (gimple_code (bad) == GIMPLE_OMP_FOR)
-	    dump_printf_loc (MSG_NOTE, tloc,
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			     "Will not turn target construct into a gridified "
 			     " GPGPU kernel because the inner loop contains "
 			     "a simd construct\n");
 	  else
-	    dump_printf_loc (MSG_NOTE, tloc,
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, tloc,
 			     "Will not turn target construct into a gridified "
 			     "GPGPU kernel because the inner loop contains "
 			     "statement %s which cannot be transformed\n",
@@ -17895,7 +17895,7 @@  const pass_data pass_data_lower_omp =
 {
   GIMPLE_PASS, /* type */
   "omplower", /* name */
-  OPTGROUP_NONE, /* optinfo_flags */
+  OPTGROUP_OPENMP, /* optinfo_flags */
   TV_NONE, /* tv_id */
   PROP_gimple_any, /* properties_required */
   PROP_gimple_lomp, /* properties_provided */
@@ -19895,7 +19895,7 @@  const pass_data pass_data_omp_simd_clone =
 {
   SIMPLE_IPA_PASS,		/* type */
   "simdclone",			/* name */
-  OPTGROUP_NONE,		/* optinfo_flags */
+  OPTGROUP_OPENMP,		/* optinfo_flags */
   TV_NONE,			/* tv_id */
   ( PROP_ssa | PROP_cfg ),	/* properties_required */
   0,				/* properties_provided */