aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorCesar Philippidis <cesar@codesourcery.com>2015-11-05 18:03:48 -0800
committerCesar Philippidis <cesar@gcc.gnu.org>2015-11-05 18:03:48 -0800
commit7a5e4956cc026cba54159d5c764486ac4151db85 (patch)
tree2f50525608c6a6a2a595620ad902d2efc85ab031 /gcc/fortran
parent906f9ad995368b4891186c07ed3c5c2fd5f53bea (diff)
downloadgcc-7a5e4956cc026cba54159d5c764486ac4151db85.zip
gcc-7a5e4956cc026cba54159d5c764486ac4151db85.tar.gz
gcc-7a5e4956cc026cba54159d5c764486ac4151db85.tar.bz2
gimplify.c (gimplify_scan_omp_clauses): Add support for OMP_CLAUSE_TILE.
gcc/ * gimplify.c (gimplify_scan_omp_clauses): Add support for OMP_CLAUSE_TILE. Update handling of OMP_CLAUSE_INDEPENDENT. (gimplify_adjust_omp_clauses): Likewise. * omp-low.c (scan_sharing_clauses): Add support for OMP_CLAUSE_TILE. * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_TILE. * tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_TILE. * tree.c (omp_clause_num_ops): Add an entry for OMP_CLAUSE_TILE. (omp_clause_code_name): Likewise. (walk_tree_1): Handle OMP_CLAUSE_TILE. * tree.h (OMP_TILE_LIST): New macro. gcc/c-family/ * c-omp.c (c_oacc_split_loop_clauses): Make TILE, GANG, WORKER, VECTOR, AUTO, SEQ, INDEPENDENT and PRIVATE loop clauses. Associate REDUCTION clauses with parallel and kernels and loops. * c-pragma.h (enum pragma_omp_clause): Add entries for PRAGMA_OACC_CLAUSE_{INDEPENDENT,TILE,DEFAULT}. * pt.c (tsubst_omp_clauses): Add support for OMP_CLAUSE_{NUM_GANGS, NUM_WORKERS,VECTOR_LENGTH,GANG,WORKER,VECTOR,ASYNC,WAIT,TILE,AUTO, INDEPENDENT,SEQ}. (tsubst_expr): Add support for OMP_CLAUSE_{KERNELS,PARALLEL,LOOP}. gcc/c/ * c-parser.c (c_parser_omp_clause_name): Add support for PRAGMA_OACC_CLAUSE_INDEPENDENT and PRAGMA_OACC_CLAUSE_TILE. (c_parser_omp_clause_default): Add is_oacc argument. Handle default(none) in OpenACC. (c_parser_oacc_shape_clause): Allow pointer variables as gang static arguments. (c_parser_oacc_clause_tile): New function. (c_parser_oacc_all_clauses): Add support for OMP_CLAUSE_DEFAULT, OMP_CLAUSE_INDEPENDENT and OMP_CLAUSE_TILE. (OACC_LOOP_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_{PRIVATE,INDEPENDENT, TILE}. (OACC_KERNELS_MASK): Add PRAGMA_OACC_CLAUSE_DEFAULT. (OACC_PARALLEL_MASK): Add PRAGMA_OACC_CLAUSE_{DEFAULT,PRIVATE, FIRSTPRIVATE}. (c_parser_omp_all_clauses): Update call to c_parser_omp_clause_default. (c_parser_oacc_update): Update the error message for missing clauses. * c-typeck.c (c_finish_omp_clauses): Add support for OMP_CLAUSE_TILE and OMP_CLAUSE_INDEPENDENT. gcc/cp/ * parser.c (cp_parser_omp_clause_name): Add support for PRAGMA_OACC_CLAUSE_INDEPENDENT and PRAGMA_OACC_CLAUSE_TILE. (cp_parser_oacc_shape_clause): Allow pointer variables as gang static arguments. (cp_parser_oacc_clause_tile): New function. (cp_parser_omp_clause_default): Add is_oacc argument. Handle default(none) in OpenACC. (cp_parser_oacc_all_clauses): Add support for (cp_parser_omp_all_clauses): Update call to cp_parser_omp_clause_default. PRAGMA_OACC_CLAUSE_{DEFAULT,INDEPENDENT,TILE,PRIVATE,FIRSTPRIVATE}. (OACC_LOOP_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_{PRIVATE,INDEPENDENT, TILE}. (OACC_KERNELS_MASK): Add PRAGMA_OACC_CLAUSE_DEFAULT. (OACC_PARALLEL_MASK): Add PRAGMA_OACC_CLAUSE_{DEFAULT,PRIVATE, FIRSTPRIVATE}. (cp_parser_oacc_update): Update the error message for missing clauses. * semantics.c (finish_omp_clauses): Add support for OMP_CLAUSE_INDEPENDENT and OMP_CLAUSE_TILE. gcc/fortran/ * openmp.c (gfc_match_omp_clauses): Update support for the tile and default clauses in OpenACC. (gfc_match_oacc_update): Error when data clauses are supplied. (oacc_compatible_clauses): Delete. (resolve_omp_clauses): Give special care for OpenACC reductions. Also update error reporting for the tile clause. (resolve_oacc_loop_blocks): Update error reporting for the tile clause. * trans-openmp.c (gfc_trans_omp_clauses): Update OMP_CLAUSE_SEQ. Add OMP_CLAUSE_{AUTO,TILE} and add support the the gang static argument. (gfc_trans_oacc_combined_directive): Update the list of clauses which are split to acc loops. gcc/testsuite/ * c-c++-common/goacc/combined-directives.c: New test. * c-c++-common/goacc/loop-clauses.c: New test. * c-c++-common/goacc/tile.c: New test. * c-c++-common/goacc/loop-shape.c: Add test for pointer variable as gang static arguments. * c-c++-common/goacc/update-1.c: Adjust expected error message. * g++.dg/goacc/template.C: New test. * gfortran.dg/goacc/combined-directives.f90: New test. * gfortran.dg/goacc/default.f95: New test. * gfortran.dg/goacc/default_none.f95: New test. * gfortran.dg/goacc/firstprivate-1.f95: New test. * gfortran.dg/goacc/gang-static.f95: New test. * gfortran.dg/goacc/kernels-loop-inner.f95: New test. * gfortran.dg/goacc/kernels-loops-adjacent.f95: New test. * gfortran.dg/goacc/list.f95: Update test. * gfortran.dg/goacc/loop-2.f95: Likewise. * gfortran.dg/goacc/loop-4.f95: New test. * gfortran.dg/goacc/loop-5.f95: New test. * gfortran.dg/goacc/loop-6.f95: New test. * gfortran.dg/goacc/loop-tree-1.f90: Update test. * gfortran.dg/goacc/multi-clause.f90: New test. * gfortran.dg/goacc/parallel-tree.f95: Update test. * gfortran.dg/goacc/update.f95: New test. Co-Authored-By: James Norris <jnorris@codesourcery.com> Co-Authored-By: Nathan Sidwell <nathan@codesourcery.com> Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com> Co-Authored-By: Tom de Vries <tom@codesourcery.com> From-SVN: r229832
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog14
-rw-r--r--gcc/fortran/openmp.c101
-rw-r--r--gcc/fortran/trans-openmp.c54
3 files changed, 115 insertions, 54 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index e2c8f71..bd3fa76 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,17 @@
+2015-11-05 Cesar Philippidis <cesar@codesourcery.com>
+
+ * openmp.c (gfc_match_omp_clauses): Update support for the tile
+ and default clauses in OpenACC.
+ (gfc_match_oacc_update): Error when data clauses are supplied.
+ (oacc_compatible_clauses): Delete.
+ (resolve_omp_clauses): Give special care for OpenACC reductions.
+ Also update error reporting for the tile clause.
+ (resolve_oacc_loop_blocks): Update error reporting for the tile clause.
+ * trans-openmp.c (gfc_trans_omp_clauses): Update OMP_CLAUSE_SEQ. Add
+ OMP_CLAUSE_{AUTO,TILE} and add support the the gang static argument.
+ (gfc_trans_oacc_combined_directive): Update the list of clauses which
+ are split to acc loops.
+
2015-11-05 Jakub Jelinek <jakub@redhat.com>
* types.def (BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR): Remove.
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 929a739..a7c7a19 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -703,6 +703,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, uint64_t mask,
OMP_MAP_FORCE_FROM))
continue;
if ((mask & OMP_CLAUSE_TILE)
+ && !c->tile_list
&& match_oacc_expr_list ("tile (", &c->tile_list, true) == MATCH_YES)
continue;
if ((mask & OMP_CLAUSE_SEQ) && !c->seq
@@ -856,12 +857,14 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, uint64_t mask,
if ((mask & OMP_CLAUSE_DEFAULT)
&& c->default_sharing == OMP_DEFAULT_UNKNOWN)
{
- if (gfc_match ("default ( shared )") == MATCH_YES)
+ if (gfc_match ("default ( none )") == MATCH_YES)
+ c->default_sharing = OMP_DEFAULT_NONE;
+ else if (openacc)
+ /* c->default_sharing = OMP_DEFAULT_UNKNOWN */;
+ else if (gfc_match ("default ( shared )") == MATCH_YES)
c->default_sharing = OMP_DEFAULT_SHARED;
else if (gfc_match ("default ( private )") == MATCH_YES)
c->default_sharing = OMP_DEFAULT_PRIVATE;
- else if (gfc_match ("default ( none )") == MATCH_YES)
- c->default_sharing = OMP_DEFAULT_NONE;
else if (gfc_match ("default ( firstprivate )") == MATCH_YES)
c->default_sharing = OMP_DEFAULT_FIRSTPRIVATE;
if (c->default_sharing != OMP_DEFAULT_UNKNOWN)
@@ -1304,10 +1307,19 @@ match
gfc_match_oacc_update (void)
{
gfc_omp_clauses *c;
+ locus here = gfc_current_locus;
+
if (gfc_match_omp_clauses (&c, OACC_UPDATE_CLAUSES, false, false, true)
!= MATCH_YES)
return MATCH_ERROR;
+ if (!c->lists[OMP_LIST_MAP])
+ {
+ gfc_error ("%<acc update%> must contain at least one "
+ "%<device%> or %<host%> or %<self%> clause at %L", &here);
+ return MATCH_ERROR;
+ }
+
new_st.op = EXEC_OACC_UPDATE;
new_st.ext.omp_clauses = c;
return MATCH_YES;
@@ -2846,30 +2858,6 @@ resolve_omp_udr_clause (gfc_omp_namelist *n, gfc_namespace *ns,
return copy;
}
-/* Returns true if clause in list 'list' is compatible with any of
- of the clauses in lists [0..list-1]. E.g., a reduction variable may
- appear in both reduction and private clauses, so this function
- will return true in this case. */
-
-static bool
-oacc_compatible_clauses (gfc_omp_clauses *clauses, int list,
- gfc_symbol *sym, bool openacc)
-{
- gfc_omp_namelist *n;
-
- if (!openacc)
- return false;
-
- if (list != OMP_LIST_REDUCTION)
- return false;
-
- for (n = clauses->lists[OMP_LIST_FIRST]; n; n = n->next)
- if (n->sym == sym)
- return true;
-
- return false;
-}
-
/* OpenMP directive resolving routines. */
static void
@@ -2975,11 +2963,11 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
&& list != OMP_LIST_DEPEND
&& (list != OMP_LIST_MAP || openacc)
&& list != OMP_LIST_FROM
- && list != OMP_LIST_TO)
+ && list != OMP_LIST_TO
+ && (list != OMP_LIST_REDUCTION || !openacc))
for (n = omp_clauses->lists[list]; n; n = n->next)
{
- if (n->sym->mark && !oacc_compatible_clauses (omp_clauses, list,
- n->sym, openacc))
+ if (n->sym->mark)
gfc_error ("Symbol %qs present on multiple clauses at %L",
n->sym->name, &n->where);
else
@@ -3028,6 +3016,22 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
n->sym->mark = 1;
}
+ /* OpenACC reductions. */
+ if (openacc)
+ {
+ for (n = omp_clauses->lists[OMP_LIST_REDUCTION]; n; n = n->next)
+ n->sym->mark = 0;
+
+ for (n = omp_clauses->lists[OMP_LIST_REDUCTION]; n; n = n->next)
+ {
+ if (n->sym->mark)
+ gfc_error ("Symbol %qs present on multiple clauses at %L",
+ n->sym->name, &n->where);
+ else
+ n->sym->mark = 1;
+ }
+ }
+
for (n = omp_clauses->lists[OMP_LIST_TO]; n; n = n->next)
n->sym->mark = 0;
for (n = omp_clauses->lists[OMP_LIST_FROM]; n; n = n->next)
@@ -4528,22 +4532,8 @@ resolve_oacc_loop_blocks (gfc_code *code)
if (code->ext.omp_clauses->vector)
gfc_error ("Clause AUTO conflicts with VECTOR at %L", &code->loc);
}
- if (!code->ext.omp_clauses->tile_list)
- {
- if (code->ext.omp_clauses->gang)
- {
- if (code->ext.omp_clauses->worker)
- gfc_error ("Clause GANG conflicts with WORKER at %L", &code->loc);
- if (code->ext.omp_clauses->vector)
- gfc_error ("Clause GANG conflicts with VECTOR at %L", &code->loc);
- }
- if (code->ext.omp_clauses->worker)
- if (code->ext.omp_clauses->vector)
- gfc_error ("Clause WORKER conflicts with VECTOR at %L", &code->loc);
- }
- else if (code->ext.omp_clauses->gang
- && code->ext.omp_clauses->worker
- && code->ext.omp_clauses->vector)
+ if (code->ext.omp_clauses->tile_list && code->ext.omp_clauses->gang
+ && code->ext.omp_clauses->worker && code->ext.omp_clauses->vector)
gfc_error ("Tiled loop cannot be parallelized across gangs, workers and "
"vectors at the same time at %L", &code->loc);
@@ -4564,10 +4554,21 @@ resolve_oacc_loop_blocks (gfc_code *code)
{
num++;
if (el->expr == NULL)
- continue;
- resolve_oacc_positive_int_expr (el->expr, "TILE");
- if (el->expr->expr_type != EXPR_CONSTANT)
- gfc_error ("TILE requires constant expression at %L", &code->loc);
+ {
+ /* NULL expressions are used to represent '*' arguments.
+ Convert those to a -1 expressions. */
+ el->expr = gfc_get_constant_expr (BT_INTEGER,
+ gfc_default_integer_kind,
+ &code->loc);
+ mpz_set_si (el->expr->value.integer, -1);
+ }
+ else
+ {
+ resolve_oacc_positive_int_expr (el->expr, "TILE");
+ if (el->expr->expr_type != EXPR_CONSTANT)
+ gfc_error ("TILE requires constant expression at %L",
+ &code->loc);
+ }
}
resolve_oacc_nested_loops (code, code->block->next, num, "tiled");
}
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index 5f4c382..9f0d533 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -2534,8 +2534,12 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
}
if (clauses->seq)
{
- c = build_omp_clause (where.lb->location, OMP_CLAUSE_ORDERED);
- OMP_CLAUSE_ORDERED_EXPR (c) = NULL_TREE;
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_SEQ);
+ omp_clauses = gfc_trans_add_clause (c, omp_clauses);
+ }
+ if (clauses->par_auto)
+ {
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_AUTO);
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
if (clauses->independent)
@@ -2579,6 +2583,21 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
OMP_CLAUSE_VECTOR_LENGTH_EXPR (c) = vector_length_var;
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
+ if (clauses->tile_list)
+ {
+ vec<tree, va_gc> *tvec;
+ gfc_expr_list *el;
+
+ vec_alloc (tvec, 4);
+
+ for (el = clauses->tile_list; el; el = el->next)
+ vec_safe_push (tvec, gfc_convert_expr_to_tree (block, el->expr));
+
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_TILE);
+ OMP_CLAUSE_TILE_LIST (c) = build_tree_list_vec (tvec);
+ omp_clauses = gfc_trans_add_clause (c, omp_clauses);
+ tvec->truncate (0);
+ }
if (clauses->vector)
{
if (clauses->vector_expr)
@@ -2618,7 +2637,17 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
tree gang_var
= gfc_convert_expr_to_tree (block, clauses->gang_expr);
c = build_omp_clause (where.lb->location, OMP_CLAUSE_GANG);
- OMP_CLAUSE_GANG_EXPR (c) = gang_var;
+ if (clauses->gang_static)
+ OMP_CLAUSE_GANG_STATIC_EXPR (c) = gang_var;
+ else
+ OMP_CLAUSE_GANG_EXPR (c) = gang_var;
+ omp_clauses = gfc_trans_add_clause (c, omp_clauses);
+ }
+ else if (clauses->gang_static)
+ {
+ /* This corresponds to gang (static: *). */
+ c = build_omp_clause (where.lb->location, OMP_CLAUSE_GANG);
+ OMP_CLAUSE_GANG_STATIC_EXPR (c) = integer_minus_one_node;
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
else
@@ -3449,16 +3478,33 @@ gfc_trans_oacc_combined_directive (gfc_code *code)
sizeof (construct_clauses));
loop_clauses.collapse = construct_clauses.collapse;
loop_clauses.gang = construct_clauses.gang;
+ loop_clauses.gang_expr = construct_clauses.gang_expr;
+ loop_clauses.gang_static = construct_clauses.gang_static;
loop_clauses.vector = construct_clauses.vector;
+ loop_clauses.vector_expr = construct_clauses.vector_expr;
loop_clauses.worker = construct_clauses.worker;
+ loop_clauses.worker_expr = construct_clauses.worker_expr;
loop_clauses.seq = construct_clauses.seq;
+ loop_clauses.par_auto = construct_clauses.par_auto;
loop_clauses.independent = construct_clauses.independent;
- construct_clauses.collapse = 0;
+ loop_clauses.tile_list = construct_clauses.tile_list;
+ loop_clauses.lists[OMP_LIST_PRIVATE]
+ = construct_clauses.lists[OMP_LIST_PRIVATE];
+ loop_clauses.lists[OMP_LIST_REDUCTION]
+ = construct_clauses.lists[OMP_LIST_REDUCTION];
construct_clauses.gang = false;
+ construct_clauses.gang_expr = NULL;
+ construct_clauses.gang_static = false;
construct_clauses.vector = false;
+ construct_clauses.vector_expr = NULL;
construct_clauses.worker = false;
+ construct_clauses.worker_expr = NULL;
construct_clauses.seq = false;
+ construct_clauses.par_auto = false;
+ construct_clauses.independent = false;
construct_clauses.independent = false;
+ construct_clauses.tile_list = NULL;
+ construct_clauses.lists[OMP_LIST_PRIVATE] = NULL;
oacc_clauses = gfc_trans_omp_clauses (&block, &construct_clauses,
code->loc);
}