This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gomp] Enable !$omp parallel {do,sections,workshare} translation


Hi!

I have committed following change to enable the rest of constructs
and fix a few typos (OpenMP uses reduction(iand:i), not
reduction(.iand.:i)).

With all patches I posted today (including the COMMON/EQUIVALENCE
patch that needs reworking based on rth's feedback) all fortran
OpenMP tests in libgomp as well as gcc testsuites build, just
omp_parse{1,3,4}.f90 fail at runtime.

2005-10-11  Jakub Jelinek  <jakub@redhat.com>

	* openmp.c (gfc_match_omp_clauses): Match min/iand/ior/ieor
	rather than .min. etc.

	* trans-openmpc.c (omp_not_yet): Remove.
	(gfc_trans_omp_parallel_do): Keep listprivate clause on parallel.
	Force creation of BIND_EXPR around the workshare construct.
	(gfc_trans_omp_parallel_sections): Likewise.
	(gfc_trans_omp_parallel_workshare): Likewise.

--- gcc/fortran/openmp.c.jj	2005-09-27 14:34:25.000000000 +0200
+++ gcc/fortran/openmp.c	2005-10-11 19:05:32.000000000 +0200
@@ -251,13 +251,13 @@ gfc_match_omp_clauses (gfc_omp_clauses *
 	    reduction = OMP_LIST_NEQV;
 	  else if (gfc_match ("max") == MATCH_YES)
 	    reduction = OMP_LIST_MAX;
-	  else if (gfc_match (".min.") == MATCH_YES)
+	  else if (gfc_match ("min") == MATCH_YES)
 	    reduction = OMP_LIST_MIN;
-	  else if (gfc_match (".iand.") == MATCH_YES)
+	  else if (gfc_match ("iand") == MATCH_YES)
 	    reduction = OMP_LIST_IAND;
-	  else if (gfc_match (".ior.") == MATCH_YES)
+	  else if (gfc_match ("ior") == MATCH_YES)
 	    reduction = OMP_LIST_IOR;
-	  else if (gfc_match (".ieor.") == MATCH_YES)
+	  else if (gfc_match ("ieor") == MATCH_YES)
 	    reduction = OMP_LIST_IEOR;
 	  if (reduction != OMP_LIST_NUM
 	      && gfc_match_omp_variable_list (" :", &c->lists[reduction])
--- gcc/fortran/trans-openmp.c.jj	2005-10-10 19:13:18.000000000 +0200
+++ gcc/fortran/trans-openmp.c	2005-10-11 20:57:31.000000000 +0200
@@ -36,8 +36,6 @@ Software Foundation, 51 Franklin Street,
 #include "trans-const.h"
 #include "arith.h"
 
-int omp_not_yet;
-
 
 static inline tree
 gfc_trans_add_clause (tree node, tree tail)
@@ -674,21 +672,22 @@ gfc_trans_omp_parallel_do (gfc_code *cod
     {
       memcpy (&parallel_clauses, code->ext.omp_clauses,
 	      sizeof (parallel_clauses));
-      do_clauses.lists[OMP_LIST_LASTPRIVATE]
-	= parallel_clauses.lists[OMP_LIST_LASTPRIVATE];
       do_clauses.sched_kind = parallel_clauses.sched_kind;
       do_clauses.chunk_size = parallel_clauses.chunk_size;
       do_clauses.ordered = parallel_clauses.ordered;
-      parallel_clauses.lists[OMP_LIST_LASTPRIVATE] = NULL;
       parallel_clauses.sched_kind = OMP_SCHED_NONE;
       parallel_clauses.chunk_size = NULL;
       parallel_clauses.ordered = false;
       omp_clauses = gfc_trans_omp_clauses (&block, &parallel_clauses);
     }
   do_clauses.nowait = true;
+  pushlevel (0);
   stmt = gfc_trans_omp_do (code, &do_clauses);
-  if (omp_not_yet)
-    stmt = build2_v (OMP_PARALLEL, omp_clauses, stmt);
+  if (TREE_CODE (stmt) != BIND_EXPR)
+    stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0, 0));
+  else
+    poplevel (0, 0, 0);
+  stmt = build2_v (OMP_PARALLEL, omp_clauses, stmt);
   gfc_add_expr_to_block (&block, stmt);
   return gfc_finish_block (&block);
 }
@@ -697,25 +696,21 @@ static tree
 gfc_trans_omp_parallel_sections (gfc_code *code)
 {
   stmtblock_t block;
-  gfc_omp_clauses parallel_clauses, section_clauses;
-  tree stmt, omp_clauses = NULL_TREE;
-
-  gfc_start_block (&block);
+  gfc_omp_clauses section_clauses;
+  tree stmt, omp_clauses;
 
   memset (&section_clauses, 0, sizeof (section_clauses));
-  if (code->ext.omp_clauses != NULL)
-    {
-      memcpy (&parallel_clauses, code->ext.omp_clauses,
-	      sizeof (parallel_clauses));
-      section_clauses.lists[OMP_LIST_LASTPRIVATE]
-	= parallel_clauses.lists[OMP_LIST_LASTPRIVATE];
-      parallel_clauses.lists[OMP_LIST_LASTPRIVATE] = NULL;
-      omp_clauses = gfc_trans_omp_clauses (&block, &parallel_clauses);
-    }
   section_clauses.nowait = true;
+
+  gfc_start_block (&block);
+  omp_clauses = gfc_trans_omp_clauses (&block, code->ext.omp_clauses);
+  pushlevel (0);
   stmt = gfc_trans_omp_sections (code, &section_clauses);
-  if (omp_not_yet)
-    stmt = build2_v (OMP_PARALLEL, omp_clauses, stmt);
+  if (TREE_CODE (stmt) != BIND_EXPR)
+    stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0, 0));
+  else
+    poplevel (0, 0, 0);
+  stmt = build2_v (OMP_PARALLEL, omp_clauses, stmt);
   gfc_add_expr_to_block (&block, stmt);
   return gfc_finish_block (&block);
 }
@@ -731,11 +726,14 @@ gfc_trans_omp_parallel_workshare (gfc_co
   workshare_clauses.nowait = true;
 
   gfc_start_block (&block);
-
   omp_clauses = gfc_trans_omp_clauses (&block, code->ext.omp_clauses);
+  pushlevel (0);
   stmt = gfc_trans_omp_workshare (code, &workshare_clauses);
-  if (omp_not_yet)
-    stmt = build2_v (OMP_PARALLEL, omp_clauses, stmt);
+  if (TREE_CODE (stmt) != BIND_EXPR)
+    stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0, 0));
+  else
+    poplevel (0, 0, 0);
+  stmt = build2_v (OMP_PARALLEL, omp_clauses, stmt);
   gfc_add_expr_to_block (&block, stmt);
   return gfc_finish_block (&block);
 }

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]