[patch] More precise cfg for omp constructs

Zdenek Dvorak rakdver@kam.mff.cuni.cz
Wed Dec 19 05:16:00 GMT 2007


> On Tue, Dec 18, 2007 at 06:42:51PM +0100, Zdenek Dvorak wrote:
> > > Assuming all these changes are ok, one fix
> > > would be avoid calling determine_parallel_type from within
> > > build_omp_regions_1, but only when it finished (i.e. from
> > > build_omp_regions_root/build_omp_regions), by walking the tree of
> > > created regions and for OMP_PARALLEL regions calling determine_parallel_type
> > > on them.
> > 
> > yes, the patch below seems to fix the problem.
> 
> This looks good to me.  Diego, are you ok with this if Zdenek writes a
> ChangeLog entry?  I'll prepare testcases tomorrow.

here's the patch, bootstrapped & regtested on amd64-linux.

Zdenek

	* omp-low.c (build_omp_regions_1): Recognition of combined parallels
	moved ...
	(expand_omp): ... here.
	* gcc.dg/gomp/combined-1.c: New test.

Index: omp-low.c
===================================================================
*** omp-low.c	(revision 131013)
--- omp-low.c	(working copy)
*************** expand_omp (struct omp_region *region)
*** 3952,3957 ****
--- 3952,3962 ----
  {
    while (region)
      {
+       /* First, determine whether this is a combined parallel+workshare
+        	 region.  */
+       if (region->type == OMP_PARALLEL)
+ 	determine_parallel_type (region);
+ 
        if (region->inner)
  	expand_omp (region->inner);
  
*************** build_omp_regions_1 (basic_block bb, str
*** 4028,4038 ****
  	  region = parent;
  	  region->exit = bb;
  	  parent = parent->outer;
- 
- 	  /* If REGION is a parallel region, determine whether it is
- 	     a combined parallel+workshare region.  */
- 	  if (region->type == OMP_PARALLEL)
- 	    determine_parallel_type (region);
  	}
        else if (code == OMP_ATOMIC_STORE)
  	{
--- 4033,4038 ----
Index: testsuite/gcc.dg/gomp/combined-1.c
===================================================================
*** testsuite/gcc.dg/gomp/combined-1.c	(revision 0)
--- testsuite/gcc.dg/gomp/combined-1.c	(revision 0)
***************
*** 0 ****
--- 1,24 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O1 -fopenmp -fdump-tree-final_cleanup" } */
+ 
+ int a[10];
+ int foo (void)
+ {
+     int i;
+ #pragma omp parallel for schedule(runtime)
+     for (i = 0; i < 10; i++)
+       a[i] = i;
+ #pragma omp parallel
+ #pragma omp for schedule(runtime)
+     for (i = 0; i < 10; i++)
+       a[i] = 10 - i;
+ #pragma omp parallel
+       {
+ #pragma omp for schedule(runtime)
+ 	for (i = 0; i < 10; i++)
+ 	  a[i] = i;
+       }
+ }
+ 
+ /* { dg-final { scan-tree-dump-times "__builtin_GOMP_parallel_loop_runtime_start" 3 "final_cleanup" } } */
+ /* { dg-final { cleanup-tree-dump "final_cleanup" } } */



More information about the Gcc-patches mailing list