Message ID | 9f4c0d8a-b26f-573e-0746-395dba321c8f@mentor.com |
---|---|
State | Superseded |
Headers | show |
Hi! On Thu, Nov 10, 2016 at 06:44:52PM +0800, Chung-Lin Tang wrote: Above this it is fine. > @@ -9388,10 +9373,23 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) > (OMP_FOR_INIT (for_stmt)) > * 2); > } > - int collapse = 1; > - c = find_omp_clause (OMP_FOR_CLAUSES (for_stmt), OMP_CLAUSE_COLLAPSE); > - if (c) > - collapse = tree_to_shwi (OMP_CLAUSE_COLLAPSE_EXPR (c)); > + int collapse = 0; > + /* Find the first of COLLAPSE or TILE. */ > + for (c = OMP_FOR_CLAUSES (for_stmt); c; c = TREE_CHAIN (c)) > + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_COLLAPSE) > + { > + collapse = tree_to_shwi (OMP_CLAUSE_COLLAPSE_EXPR (c)); > + if (collapse == 1) > + /* Not really collapsing. */ > + collapse = 0; > + break; > + } > + else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TILE) > + { > + collapse = list_length (OMP_CLAUSE_TILE_LIST (c)); > + break; > + } I don't really like this, especially pretending collapse(1) or lack of collapse clause e.g. on OpenMP construct is collapse(0). I'd keep what it does, i.e. int collapse = 1; c = find_omp_clause (OMP_FOR_CLAUSES (for_stmt), OMP_CLAUSE_COLLAPSE); if (c) collapse = tree_to_shwi (OMP_CLAUSE_COLLAPSE_EXPR (c)); and in the first switch in gimplify_omp_for you can: case OACC_LOOP: ort = ORT_ACC; c = find_omp_clause (OMP_FOR_CLAUSES (for_stmt), OMP_CLAUSE_TILE); if (c) tile = list_length (OMP_CLAUSE_TILE_LIST (c)); break; and then just use tile != 0 or whatever || with collapse > 1 where needed. > + > for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)); i++) > { > t = TREE_VEC_ELT (OMP_FOR_INIT (for_stmt), i); > @@ -9807,7 +9805,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) > OMP_CLAUSE_LINEAR_STEP (c2) = OMP_CLAUSE_LINEAR_STEP (c); > } > > - if ((var != decl || collapse > 1) && orig_for_stmt == for_stmt) > + if ((var != decl || collapse) && orig_for_stmt == for_stmt) > { > for (c = OMP_FOR_CLAUSES (for_stmt); c ; c = OMP_CLAUSE_CHAIN (c)) > if (((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE Like here. > @@ -9817,7 +9815,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) > && OMP_CLAUSE_LINEAR_GIMPLE_SEQ (c) == NULL)) > && OMP_CLAUSE_DECL (c) == decl) > { > - if (is_doacross && (collapse == 1 || i >= collapse)) > + if (is_doacross && (!collapse || i >= collapse)) > t = var; > else > { And not here. You don't really have doacross loops in OpenACC, do you? Jakub
Hi! Given this: On 2016-11-10T18:44:52+0800, Chung-Lin Tang <chunglin_tang@mentor.com> wrote: > --- tree.c (revision 241809) > +++ tree.c (working copy) > @@ -327,7 +327,7 @@ unsigned const char omp_clause_num_ops[] = > - 1, /* OMP_CLAUSE_TILE */ > + 3, /* OMP_CLAUSE_TILE */ ... for this: > --- tree.h (revision 241809) > +++ tree.h (working copy) > #define OMP_CLAUSE_TILE_LIST(NODE) \ > OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_TILE), 0) > +#define OMP_CLAUSE_TILE_ITERVAR(NODE) \ > + OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_TILE), 1) > +#define OMP_CLAUSE_TILE_COUNT(NODE) \ > + OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_TILE), 2) ..., we also need to "Fix 'OMP_CLAUSE_TILE' operands handling in 'gcc/tree.c:walk_tree_1'". In commit 92dc5d844a2088db79bc4521be3ecb4e2f284444 pushed to master branch, cherry-picked in commit e6880aa976f962ecf78d20b58f7815b585791647 into releases/gcc-11 branch, in commit 82631dd97a3762e59bf5b9623f3c8c999aba7d80 into releases/gcc-10 branch, in commit 1514a668b96a9b66539646ec3d2a6ef9c6f39fb2 into releases/gcc-9 branch, see attached. Grüße Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 From 92dc5d844a2088db79bc4521be3ecb4e2f284444 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <thomas@codesourcery.com> Date: Fri, 27 Aug 2021 07:49:35 +0200 Subject: [PATCH] Fix 'OMP_CLAUSE_TILE' operands handling in 'gcc/tree.c:walk_tree_1' In r245300 (commit 02889d23ee3b02854dff203dd87b9a25e30b61b4) "OpenACC tile clause support" that one had changed to three operands, similar to 'OMP_CLAUSE_COLLAPSE'. There is no (existing) test case where this seems to matter (likewise for 'OMP_CLAUSE_COLLAPSE'), but it's good to be consistent. gcc/ * tree.c (walk_tree_1) <OMP_CLAUSE_TILE>: Handle three operands. --- gcc/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/tree.c b/gcc/tree.c index cba3bca41b3..4c7e03b0f25 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -11166,7 +11166,6 @@ walk_tree_1 (tree *tp, walk_tree_fn func, void *data, case OMP_CLAUSE_BIND: case OMP_CLAUSE_AUTO: case OMP_CLAUSE_SEQ: - case OMP_CLAUSE_TILE: case OMP_CLAUSE__SIMT_: case OMP_CLAUSE_IF_PRESENT: case OMP_CLAUSE_FINALIZE: @@ -11179,6 +11178,7 @@ walk_tree_1 (tree *tp, walk_tree_fn func, void *data, WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); case OMP_CLAUSE_COLLAPSE: + case OMP_CLAUSE_TILE: { int i; for (i = 0; i < 3; i++) -- 2.30.2 From e6880aa976f962ecf78d20b58f7815b585791647 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <thomas@codesourcery.com> Date: Fri, 27 Aug 2021 07:49:35 +0200 Subject: [PATCH] Fix 'OMP_CLAUSE_TILE' operands handling in 'gcc/tree.c:walk_tree_1' In r245300 (commit 02889d23ee3b02854dff203dd87b9a25e30b61b4) "OpenACC tile clause support" that one had changed to three operands, similar to 'OMP_CLAUSE_COLLAPSE'. There is no (existing) test case where this seems to matter (likewise for 'OMP_CLAUSE_COLLAPSE'), but it's good to be consistent. gcc/ * tree.c (walk_tree_1) <OMP_CLAUSE_TILE>: Handle three operands. (cherry picked from commit 92dc5d844a2088db79bc4521be3ecb4e2f284444) --- gcc/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/tree.c b/gcc/tree.c index e0183b73e31..8bc81d66821 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -12299,7 +12299,6 @@ walk_tree_1 (tree *tp, walk_tree_fn func, void *data, case OMP_CLAUSE_BIND: case OMP_CLAUSE_AUTO: case OMP_CLAUSE_SEQ: - case OMP_CLAUSE_TILE: case OMP_CLAUSE__SIMT_: case OMP_CLAUSE_IF_PRESENT: case OMP_CLAUSE_FINALIZE: @@ -12311,6 +12310,7 @@ walk_tree_1 (tree *tp, walk_tree_fn func, void *data, WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); case OMP_CLAUSE_COLLAPSE: + case OMP_CLAUSE_TILE: { int i; for (i = 0; i < 3; i++) -- 2.30.2 From 82631dd97a3762e59bf5b9623f3c8c999aba7d80 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <thomas@codesourcery.com> Date: Fri, 27 Aug 2021 07:49:35 +0200 Subject: [PATCH] Fix 'OMP_CLAUSE_TILE' operands handling in 'gcc/tree.c:walk_tree_1' In r245300 (commit 02889d23ee3b02854dff203dd87b9a25e30b61b4) "OpenACC tile clause support" that one had changed to three operands, similar to 'OMP_CLAUSE_COLLAPSE'. There is no (existing) test case where this seems to matter (likewise for 'OMP_CLAUSE_COLLAPSE'), but it's good to be consistent. gcc/ * tree.c (walk_tree_1) <OMP_CLAUSE_TILE>: Handle three operands. (cherry picked from commit 92dc5d844a2088db79bc4521be3ecb4e2f284444) --- gcc/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/tree.c b/gcc/tree.c index b43bc809823..d82c308f14c 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -12191,7 +12191,6 @@ walk_tree_1 (tree *tp, walk_tree_fn func, void *data, case OMP_CLAUSE_BIND: case OMP_CLAUSE_AUTO: case OMP_CLAUSE_SEQ: - case OMP_CLAUSE_TILE: case OMP_CLAUSE__SIMT_: case OMP_CLAUSE_IF_PRESENT: case OMP_CLAUSE_FINALIZE: @@ -12203,6 +12202,7 @@ walk_tree_1 (tree *tp, walk_tree_fn func, void *data, WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); case OMP_CLAUSE_COLLAPSE: + case OMP_CLAUSE_TILE: { int i; for (i = 0; i < 3; i++) -- 2.30.2 From 1514a668b96a9b66539646ec3d2a6ef9c6f39fb2 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <thomas@codesourcery.com> Date: Fri, 27 Aug 2021 07:49:35 +0200 Subject: [PATCH] Fix 'OMP_CLAUSE_TILE' operands handling in 'gcc/tree.c:walk_tree_1' In r245300 (commit 02889d23ee3b02854dff203dd87b9a25e30b61b4) "OpenACC tile clause support" that one had changed to three operands, similar to 'OMP_CLAUSE_COLLAPSE'. There is no (existing) test case where this seems to matter (likewise for 'OMP_CLAUSE_COLLAPSE'), but it's good to be consistent. gcc/ * tree.c (walk_tree_1) <OMP_CLAUSE_TILE>: Handle three operands. (cherry picked from commit 92dc5d844a2088db79bc4521be3ecb4e2f284444) --- gcc/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/tree.c b/gcc/tree.c index be311754393..99f4318306a 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -12340,7 +12340,6 @@ walk_tree_1 (tree *tp, walk_tree_fn func, void *data, case OMP_CLAUSE_DEFAULTMAP: case OMP_CLAUSE_AUTO: case OMP_CLAUSE_SEQ: - case OMP_CLAUSE_TILE: case OMP_CLAUSE__SIMT_: case OMP_CLAUSE_IF_PRESENT: case OMP_CLAUSE_FINALIZE: @@ -12352,6 +12351,7 @@ walk_tree_1 (tree *tp, walk_tree_fn func, void *data, WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); case OMP_CLAUSE_COLLAPSE: + case OMP_CLAUSE_TILE: { int i; for (i = 0; i < 3; i++) -- 2.30.2
Index: tree.c =================================================================== --- tree.c (revision 241809) +++ tree.c (working copy) @@ -327,7 +327,7 @@ unsigned const char omp_clause_num_ops[] = 1, /* OMP_CLAUSE_NUM_GANGS */ 1, /* OMP_CLAUSE_NUM_WORKERS */ 1, /* OMP_CLAUSE_VECTOR_LENGTH */ - 1, /* OMP_CLAUSE_TILE */ + 3, /* OMP_CLAUSE_TILE */ 2, /* OMP_CLAUSE__GRIDDIM_ */ }; Index: tree.h =================================================================== --- tree.h (revision 241809) +++ tree.h (working copy) @@ -1654,6 +1654,10 @@ extern void protected_set_expr_location (tree, loc #define OMP_CLAUSE_TILE_LIST(NODE) \ OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_TILE), 0) +#define OMP_CLAUSE_TILE_ITERVAR(NODE) \ + OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_TILE), 1) +#define OMP_CLAUSE_TILE_COUNT(NODE) \ + OMP_CLAUSE_OPERAND (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE_TILE), 2) #define OMP_CLAUSE__GRIDDIM__DIMENSION(NODE) \ (OMP_CLAUSE_SUBCODE_CHECK (NODE, OMP_CLAUSE__GRIDDIM_)\ Index: tree-nested.c =================================================================== --- tree-nested.c (revision 241809) +++ tree-nested.c (working copy) @@ -1274,6 +1274,7 @@ convert_nonlocal_omp_clauses (tree *pclauses, stru case OMP_CLAUSE_DEFAULT: case OMP_CLAUSE_COPYIN: case OMP_CLAUSE_COLLAPSE: + case OMP_CLAUSE_TILE: case OMP_CLAUSE_UNTIED: case OMP_CLAUSE_MERGEABLE: case OMP_CLAUSE_PROC_BIND: @@ -1286,8 +1287,6 @@ convert_nonlocal_omp_clauses (tree *pclauses, stru case OMP_CLAUSE_AUTO: break; - /* OpenACC tile clauses are discarded during gimplification. */ - case OMP_CLAUSE_TILE: /* The following clause belongs to the OpenACC cache directive, which is discarded during gimplification. */ case OMP_CLAUSE__CACHE_: @@ -1982,6 +1981,7 @@ convert_local_omp_clauses (tree *pclauses, struct case OMP_CLAUSE_DEFAULT: case OMP_CLAUSE_COPYIN: case OMP_CLAUSE_COLLAPSE: + case OMP_CLAUSE_TILE: case OMP_CLAUSE_UNTIED: case OMP_CLAUSE_MERGEABLE: case OMP_CLAUSE_PROC_BIND: @@ -1994,8 +1994,6 @@ convert_local_omp_clauses (tree *pclauses, struct case OMP_CLAUSE_AUTO: break; - /* OpenACC tile clauses are discarded during gimplification. */ - case OMP_CLAUSE_TILE: /* The following clause belongs to the OpenACC cache directive, which is discarded during gimplification. */ case OMP_CLAUSE__CACHE_: Index: gimplify.c =================================================================== --- gimplify.c (revision 241809) +++ gimplify.c (working copy) @@ -8138,20 +8138,11 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_se remove = true; break; - case OMP_CLAUSE_TILE: - for (tree list = OMP_CLAUSE_TILE_LIST (c); !remove && list; - list = TREE_CHAIN (list)) - { - if (gimplify_expr (&TREE_VALUE (list), pre_p, NULL, - is_gimple_val, fb_rvalue) == GS_ERROR) - remove = true; - } - break; - case OMP_CLAUSE_NOWAIT: case OMP_CLAUSE_ORDERED: case OMP_CLAUSE_UNTIED: case OMP_CLAUSE_COLLAPSE: + case OMP_CLAUSE_TILE: case OMP_CLAUSE_AUTO: case OMP_CLAUSE_SEQ: case OMP_CLAUSE_INDEPENDENT: @@ -8927,13 +8918,7 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, gi case OMP_CLAUSE_VECTOR: case OMP_CLAUSE_AUTO: case OMP_CLAUSE_SEQ: - break; - case OMP_CLAUSE_TILE: - /* We're not yet making use of the information provided by OpenACC - tile clauses. Discard these here, to simplify later middle end - processing. */ - remove = true; break; default: @@ -9388,10 +9373,23 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) (OMP_FOR_INIT (for_stmt)) * 2); } - int collapse = 1; - c = find_omp_clause (OMP_FOR_CLAUSES (for_stmt), OMP_CLAUSE_COLLAPSE); - if (c) - collapse = tree_to_shwi (OMP_CLAUSE_COLLAPSE_EXPR (c)); + int collapse = 0; + /* Find the first of COLLAPSE or TILE. */ + for (c = OMP_FOR_CLAUSES (for_stmt); c; c = TREE_CHAIN (c)) + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_COLLAPSE) + { + collapse = tree_to_shwi (OMP_CLAUSE_COLLAPSE_EXPR (c)); + if (collapse == 1) + /* Not really collapsing. */ + collapse = 0; + break; + } + else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TILE) + { + collapse = list_length (OMP_CLAUSE_TILE_LIST (c)); + break; + } + for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)); i++) { t = TREE_VEC_ELT (OMP_FOR_INIT (for_stmt), i); @@ -9807,7 +9805,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) OMP_CLAUSE_LINEAR_STEP (c2) = OMP_CLAUSE_LINEAR_STEP (c); } - if ((var != decl || collapse > 1) && orig_for_stmt == for_stmt) + if ((var != decl || collapse) && orig_for_stmt == for_stmt) { for (c = OMP_FOR_CLAUSES (for_stmt); c ; c = OMP_CLAUSE_CHAIN (c)) if (((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE @@ -9817,7 +9815,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) && OMP_CLAUSE_LINEAR_GIMPLE_SEQ (c) == NULL)) && OMP_CLAUSE_DECL (c) == decl) { - if (is_doacross && (collapse == 1 || i >= collapse)) + if (is_doacross && (!collapse || i >= collapse)) t = var; else {