+2017-09-01 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/81887
+ * c-pragma.c (omp_pragmas): Move "ordered" entry from here to ...
+ (omp_pragmas_simd): ... here.
+ * c-omp.c (c_finish_omp_ordered): If clauses isn't simd clause alone,
+ create new clauses list containing just simd clause.
+
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
tree t = make_node (OMP_ORDERED);
TREE_TYPE (t) = void_type_node;
OMP_ORDERED_BODY (t) = stmt;
+ if (!flag_openmp /* flag_openmp_simd */
+ && (OMP_CLAUSE_CODE (clauses) != OMP_CLAUSE_SIMD
+ || OMP_CLAUSE_CHAIN (clauses)))
+ clauses = build_omp_clause (loc, OMP_CLAUSE_SIMD);
OMP_ORDERED_CLAUSES (t) = clauses;
SET_EXPR_LOCATION (t, loc);
return add_stmt (t);
{ "end", PRAGMA_OMP_END_DECLARE_TARGET },
{ "flush", PRAGMA_OMP_FLUSH },
{ "master", PRAGMA_OMP_MASTER },
- { "ordered", PRAGMA_OMP_ORDERED },
{ "section", PRAGMA_OMP_SECTION },
{ "sections", PRAGMA_OMP_SECTIONS },
{ "single", PRAGMA_OMP_SINGLE },
{ "declare", PRAGMA_OMP_DECLARE },
{ "distribute", PRAGMA_OMP_DISTRIBUTE },
{ "for", PRAGMA_OMP_FOR },
+ { "ordered", PRAGMA_OMP_ORDERED },
{ "parallel", PRAGMA_OMP_PARALLEL },
{ "simd", PRAGMA_OMP_SIMD },
{ "target", PRAGMA_OMP_TARGET },
+2017-09-01 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/81887
+ * c-parser.c (c_parser_omp_ordered): Handle -fopenmp-simd.
+
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
if (!strcmp ("depend", p))
{
+ if (!flag_openmp) /* flag_openmp_simd */
+ {
+ c_parser_skip_to_pragma_eol (parser, false);
+ return false;
+ }
if (context == pragma_stmt)
{
error_at (loc,
tree clauses = c_parser_omp_all_clauses (parser, OMP_ORDERED_CLAUSE_MASK,
"#pragma omp ordered");
+
+ if (!flag_openmp /* flag_openmp_simd */
+ && omp_find_clause (clauses, OMP_CLAUSE_SIMD) == NULL_TREE)
+ return false;
+
c_finish_omp_ordered (loc, clauses,
c_parser_omp_structured_block (parser, if_p));
return true;
+2017-09-01 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/81887
+ * parser.c (cp_parser_omp_ordered): Handle -fopenmp-simd.
+
2017-09-01 Marek Polacek <polacek@redhat.com>
PR c++/82040
if (strcmp (p, "depend") == 0)
{
+ if (!flag_openmp) /* flag_openmp_simd */
+ {
+ cp_parser_skip_to_pragma_eol (parser, pragma_tok);
+ return false;
+ }
if (context == pragma_stmt)
{
error_at (pragma_tok->location, "%<#pragma omp ordered%> with "
tree clauses
= cp_parser_omp_all_clauses (parser, OMP_ORDERED_CLAUSE_MASK,
"#pragma omp ordered", pragma_tok);
+
+ if (!flag_openmp /* flag_openmp_simd */
+ && omp_find_clause (clauses, OMP_CLAUSE_SIMD) == NULL_TREE)
+ return false;
+
c_finish_omp_ordered (loc, clauses,
cp_parser_omp_structured_block (parser, if_p));
return true;
+2017-09-01 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/81887
+ * parse.c (decode_omp_directive): Use matchs instead of matcho for
+ end ordered and ordered directives, except for ordered depend. For
+ -fopenmp-simd and ordered depend, reject the stmt.
+ * trans-openmp.c (gfc_trans_omp_ordered): For -fopenmp-simd ignore
+ threads clause and if simd clause isn't present, just translate the
+ body.
+
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
matcho ("end do", gfc_match_omp_end_nowait, ST_OMP_END_DO);
matchs ("end simd", gfc_match_omp_eos, ST_OMP_END_SIMD);
matcho ("end master", gfc_match_omp_eos, ST_OMP_END_MASTER);
- matcho ("end ordered", gfc_match_omp_eos, ST_OMP_END_ORDERED);
+ matchs ("end ordered", gfc_match_omp_eos, ST_OMP_END_ORDERED);
matchs ("end parallel do simd", gfc_match_omp_eos,
ST_OMP_END_PARALLEL_DO_SIMD);
matcho ("end parallel do", gfc_match_omp_eos, ST_OMP_END_PARALLEL_DO);
matcho ("master", gfc_match_omp_master, ST_OMP_MASTER);
break;
case 'o':
- if (flag_openmp && gfc_match ("ordered depend (") == MATCH_YES)
+ if (gfc_match ("ordered depend (") == MATCH_YES)
{
gfc_current_locus = old_locus;
+ if (!flag_openmp)
+ break;
matcho ("ordered", gfc_match_omp_ordered_depend,
ST_OMP_ORDERED_DEPEND);
}
else
- matcho ("ordered", gfc_match_omp_ordered, ST_OMP_ORDERED);
+ matchs ("ordered", gfc_match_omp_ordered, ST_OMP_ORDERED);
break;
case 'p':
matchs ("parallel do simd", gfc_match_omp_parallel_do_simd,
static tree
gfc_trans_omp_ordered (gfc_code *code)
{
+ if (!flag_openmp)
+ {
+ if (!code->ext.omp_clauses->simd)
+ return gfc_trans_code (code->block ? code->block->next : NULL);
+ code->ext.omp_clauses->threads = 0;
+ }
tree omp_clauses = gfc_trans_omp_clauses (NULL, code->ext.omp_clauses,
code->loc);
return build2_loc (input_location, OMP_ORDERED, void_type_node,
+2017-09-01 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/81887
+ * c-c++-common/gomp/pr81887.c: New test.
+ * gfortran.dg/gomp/pr81887.f90: New test.
+
2017-09-01 Marek Polacek <polacek@redhat.com>
PR c++/82040
--- /dev/null
+/* PR c/81887 */
+/* { dg-do compile } */
+/* { dg-options "-fno-openmp -fopenmp-simd -fdump-tree-gimple" } */
+/* { dg-final { scan-tree-dump-times "#pragma omp simd" 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp ordered simd\[ \t]*\[\n\r]" 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp" 4 "gimple" } } */
+
+void
+f1 (int *x)
+{
+ int i;
+#pragma omp simd
+ for (i = 0; i < 100; i++)
+ #pragma omp ordered simd
+ x[i / 2] = i;
+}
+
+void
+f2 (int *x)
+{
+ int i;
+#pragma omp parallel for simd ordered
+ for (i = 0; i < 100; i++)
+ #pragma omp ordered threads simd
+ x[i / 2] = i;
+}
+
+void
+f3 (int *x)
+{
+ int i;
+#pragma omp parallel for ordered
+ for (i = 0; i < 100; i++)
+ #pragma omp ordered
+ x[i / 2] = i;
+}
+
+void
+f4 (int *x)
+{
+ int i;
+#pragma omp parallel for ordered
+ for (i = 0; i < 100; i++)
+ #pragma omp ordered threads
+ x[i / 2] = i;
+}
+
+void
+f5 (int n, int ***x)
+{
+ int i, j, k;
+#pragma omp parallel for ordered(3)
+ for (i=0; i < n; i++)
+ for (j=0; j < n; ++j)
+ for (k=0; k < n; ++k)
+ {
+#pragma omp ordered depend(sink:i-8,j-2,k+2) depend(sink:i, j-1,k) depend(sink:i-4,j-3,k+6) depend(sink:i-6,j-4,k-6)
+ x[i][j][k] = i + j + k;
+#pragma omp ordered depend(source)
+ }
+}
--- /dev/null
+! PR c/81887
+! { dg-do compile }
+! { dg-options "-fno-openmp -fopenmp-simd -fdump-tree-gimple" }
+! { dg-final { scan-tree-dump-times "#pragma omp simd" 2 "gimple" } }
+! { dg-final { scan-tree-dump-times "#pragma omp ordered simd\[ \t]*\[\n\r]" 2 "gimple" } }
+! { dg-final { scan-tree-dump-times "#pragma omp" 4 "gimple" } }
+
+subroutine f1 (x)
+ integer :: i, x(100)
+ !$omp simd
+ do i = 2, 101
+ !$omp ordered simd
+ x(i / 2) = i
+ !$omp end ordered
+ end do
+end subroutine
+
+subroutine f2 (x)
+ integer :: i, x(100)
+ !$omp parallel do simd ordered
+ do i = 2, 101
+ !$omp ordered threads simd
+ x(i / 2) = i
+ !$omp end ordered
+ end do
+end subroutine
+
+subroutine f3 (x)
+ integer :: i, x(100)
+ !$omp parallel do ordered
+ do i = 2, 101
+ !$omp ordered
+ x(i / 2) = i
+ !$omp end ordered
+ end do
+end subroutine
+
+subroutine f4 (x)
+ integer :: i, x(100)
+ !$omp parallel do ordered
+ do i = 2, 101
+ !$omp ordered threads
+ x(i / 2) = i
+ !$omp end ordered
+ end do
+end subroutine
+
+subroutine f5(x, n)
+ integer :: i, j, k, n, x(100,100,100)
+ !$omp parallel do ordered(3)
+ do i = 1, n
+ do j = 1, n
+ do k = 1, n
+ !$omp ordered depend(sink:i-8,j-2,k+2) depend(sink:i, j-1,k) depend(sink:i-4,j-3,k+6) depend(sink:i-6,j-4,k-6)
+ x(i, j, k) = i + j + k
+ !$omp ordered depend(source)
+ end do
+ end do
+ end do
+ !$omp end parallel do
+end subroutine