Commit 6c7ae8c5 by Jakub Jelinek Committed by Jakub Jelinek

tree-core.h (enum omp_clause_code): Add OMP_CLAUSE__CONDTEMP_.

	* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE__CONDTEMP_.
	* tree.h (OMP_CLAUSE_DECL): Use OMP_CLAUSE__CONDTEMP_ instead of
	OMP_CLAUSE__REDUCTEMP_.
	* tree.c (omp_clause_num_ops, omp_clause_code_name): Add
	OMP_CLAUSE__CONDTEMP_.
	(walk_tree_1): Handle OMP_CLAUSE__CONDTEMP_.
	* tree-pretty-print.c (dump_omp_clause): Likewise.
	* tree-nested.c (convert_nonlocal_omp_clauses,
	convert_local_omp_clauses): Likewise.
	* gimplify.c (enum gimplify_omp_var_data): Use hexadecimal constants
	instead of decimal.  Add GOVD_LASTPRIVATE_CONDITIONAL.
	(gimplify_scan_omp_clauses): Don't reject lastprivate conditional
	on OMP_FOR.
	(gimplify_omp_for): Warn and disable conditional modifier from
	lastprivate on loop iterators.
	* omp-general.h (struct omp_for_data): Add lastprivate_conditional
	member.
	* omp-general.c (omp_extract_for_data): Initialize it.
	* omp-low.c (struct omp_context): Add lastprivate_conditional_map
	member.
	(delete_omp_context): Delete it.
	(lower_lastprivate_conditional_clauses): New function.
	(lower_lastprivate_clauses): Add BODY_P and CSTMT_LIST arguments,
	handle lastprivate conditional clauses.
	(lower_reduction_clauses): Add CLIST argument, emit it into
	the critical section if any.
	(lower_omp_sections): Adjust lower_lastprivate_clauses and
	lower_reduction_clauses callers.
	(lower_omp_for_lastprivate): Add CLIST argument, pass it through
	to lower_lastprivate_clauses.
	(lower_omp_for): Call lower_lastprivate_conditional_clauses, adjust
	lower_omp_for_lastprivate and lower_reduction_clauses callers, emit
	clist into a critical section if not emitted there already by
	lower_reduction_clauses.
	(lower_omp_taskreg, lower_omp_teams): Adjust lower_reduction_clauses
	callers.
	(lower_omp_1): Handle GIMPLE_ASSIGNs storing into lastprivate
	conditional variables.
	* omp-expand.c (determine_parallel_type): Punt if OMP_CLAUSE__CONDTEMP_
	clause is present.
	(expand_omp_for_generic, expand_omp_for_static_nochunk,
	expand_omp_for_static_chunk): Handle lastprivate conditional.
	(expand_omp_for): Handle fd.lastprivate_conditional like
	fd.have_reductemp.
gcc/testsuite/
	* c-c++-common/gomp/lastprivate-conditional-2.c (foo): Don't expect
	sorry for omp for.
	* c-c++-common/gomp/lastprivate-conditional-3.c: New test.
libgomp/
	* testsuite/libgomp.c-c++-common/lastprivate-conditional-1.c: New test.
	* testsuite/libgomp.c-c++-common/lastprivate-conditional-2.c: New test.

From-SVN: r271610
parent 09b4000c
2019-05-24 Jakub Jelinek <jakub@redhat.com>
* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE__CONDTEMP_.
* tree.h (OMP_CLAUSE_DECL): Use OMP_CLAUSE__CONDTEMP_ instead of
OMP_CLAUSE__REDUCTEMP_.
* tree.c (omp_clause_num_ops, omp_clause_code_name): Add
OMP_CLAUSE__CONDTEMP_.
(walk_tree_1): Handle OMP_CLAUSE__CONDTEMP_.
* tree-pretty-print.c (dump_omp_clause): Likewise.
* tree-nested.c (convert_nonlocal_omp_clauses,
convert_local_omp_clauses): Likewise.
* gimplify.c (enum gimplify_omp_var_data): Use hexadecimal constants
instead of decimal. Add GOVD_LASTPRIVATE_CONDITIONAL.
(gimplify_scan_omp_clauses): Don't reject lastprivate conditional
on OMP_FOR.
(gimplify_omp_for): Warn and disable conditional modifier from
lastprivate on loop iterators.
* omp-general.h (struct omp_for_data): Add lastprivate_conditional
member.
* omp-general.c (omp_extract_for_data): Initialize it.
* omp-low.c (struct omp_context): Add lastprivate_conditional_map
member.
(delete_omp_context): Delete it.
(lower_lastprivate_conditional_clauses): New function.
(lower_lastprivate_clauses): Add BODY_P and CSTMT_LIST arguments,
handle lastprivate conditional clauses.
(lower_reduction_clauses): Add CLIST argument, emit it into
the critical section if any.
(lower_omp_sections): Adjust lower_lastprivate_clauses and
lower_reduction_clauses callers.
(lower_omp_for_lastprivate): Add CLIST argument, pass it through
to lower_lastprivate_clauses.
(lower_omp_for): Call lower_lastprivate_conditional_clauses, adjust
lower_omp_for_lastprivate and lower_reduction_clauses callers, emit
clist into a critical section if not emitted there already by
lower_reduction_clauses.
(lower_omp_taskreg, lower_omp_teams): Adjust lower_reduction_clauses
callers.
(lower_omp_1): Handle GIMPLE_ASSIGNs storing into lastprivate
conditional variables.
* omp-expand.c (determine_parallel_type): Punt if OMP_CLAUSE__CONDTEMP_
clause is present.
(expand_omp_for_generic, expand_omp_for_static_nochunk,
expand_omp_for_static_chunk): Handle lastprivate conditional.
(expand_omp_for): Handle fd.lastprivate_conditional like
fd.have_reductemp.
2019-05-24 Andrew Stubbs <ams@codesourcery.com> 2019-05-24 Andrew Stubbs <ams@codesourcery.com>
* config/gcn/gcn-run.c (main): Set a non-zero return value if the * config/gcn/gcn-run.c (main): Set a non-zero return value if the
......
...@@ -71,47 +71,50 @@ static hash_set<tree> *asan_poisoned_variables = NULL; ...@@ -71,47 +71,50 @@ static hash_set<tree> *asan_poisoned_variables = NULL;
enum gimplify_omp_var_data enum gimplify_omp_var_data
{ {
GOVD_SEEN = 1, GOVD_SEEN = 0x000001,
GOVD_EXPLICIT = 2, GOVD_EXPLICIT = 0x000002,
GOVD_SHARED = 4, GOVD_SHARED = 0x000004,
GOVD_PRIVATE = 8, GOVD_PRIVATE = 0x000008,
GOVD_FIRSTPRIVATE = 16, GOVD_FIRSTPRIVATE = 0x000010,
GOVD_LASTPRIVATE = 32, GOVD_LASTPRIVATE = 0x000020,
GOVD_REDUCTION = 64, GOVD_REDUCTION = 0x000040,
GOVD_LOCAL = 128, GOVD_LOCAL = 0x00080,
GOVD_MAP = 256, GOVD_MAP = 0x000100,
GOVD_DEBUG_PRIVATE = 512, GOVD_DEBUG_PRIVATE = 0x000200,
GOVD_PRIVATE_OUTER_REF = 1024, GOVD_PRIVATE_OUTER_REF = 0x000400,
GOVD_LINEAR = 2048, GOVD_LINEAR = 0x000800,
GOVD_ALIGNED = 4096, GOVD_ALIGNED = 0x001000,
/* Flag for GOVD_MAP: don't copy back. */ /* Flag for GOVD_MAP: don't copy back. */
GOVD_MAP_TO_ONLY = 8192, GOVD_MAP_TO_ONLY = 0x002000,
/* Flag for GOVD_LINEAR or GOVD_LASTPRIVATE: no outer reference. */ /* Flag for GOVD_LINEAR or GOVD_LASTPRIVATE: no outer reference. */
GOVD_LINEAR_LASTPRIVATE_NO_OUTER = 16384, GOVD_LINEAR_LASTPRIVATE_NO_OUTER = 0x004000,
GOVD_MAP_0LEN_ARRAY = 32768, GOVD_MAP_0LEN_ARRAY = 0x008000,
/* Flag for GOVD_MAP, if it is always, to or always, tofrom mapping. */ /* Flag for GOVD_MAP, if it is always, to or always, tofrom mapping. */
GOVD_MAP_ALWAYS_TO = 65536, GOVD_MAP_ALWAYS_TO = 0x010000,
/* Flag for shared vars that are or might be stored to in the region. */ /* Flag for shared vars that are or might be stored to in the region. */
GOVD_WRITTEN = 131072, GOVD_WRITTEN = 0x020000,
/* Flag for GOVD_MAP, if it is a forced mapping. */ /* Flag for GOVD_MAP, if it is a forced mapping. */
GOVD_MAP_FORCE = 262144, GOVD_MAP_FORCE = 0x040000,
/* Flag for GOVD_MAP: must be present already. */ /* Flag for GOVD_MAP: must be present already. */
GOVD_MAP_FORCE_PRESENT = 524288, GOVD_MAP_FORCE_PRESENT = 0x080000,
/* Flag for GOVD_MAP: only allocate. */ /* Flag for GOVD_MAP: only allocate. */
GOVD_MAP_ALLOC_ONLY = 1048576, GOVD_MAP_ALLOC_ONLY = 0x100000,
/* Flag for GOVD_MAP: only copy back. */ /* Flag for GOVD_MAP: only copy back. */
GOVD_MAP_FROM_ONLY = 2097152, GOVD_MAP_FROM_ONLY = 0x200000,
GOVD_NONTEMPORAL = 4194304, GOVD_NONTEMPORAL = 0x400000,
/* Flag for GOVD_LASTPRIVATE: conditional modifier. */
GOVD_LASTPRIVATE_CONDITIONAL = 0x800000,
GOVD_DATA_SHARE_CLASS = (GOVD_SHARED | GOVD_PRIVATE | GOVD_FIRSTPRIVATE GOVD_DATA_SHARE_CLASS = (GOVD_SHARED | GOVD_PRIVATE | GOVD_FIRSTPRIVATE
| GOVD_LASTPRIVATE | GOVD_REDUCTION | GOVD_LINEAR | GOVD_LASTPRIVATE | GOVD_REDUCTION | GOVD_LINEAR
...@@ -8139,9 +8142,17 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, ...@@ -8139,9 +8142,17 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c) = 0; OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c) = 0;
} }
if (OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c)) if (OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c))
sorry_at (OMP_CLAUSE_LOCATION (c), {
"%<conditional%> modifier on %<lastprivate%> clause " if (code == OMP_FOR)
"not supported yet"); flags |= GOVD_LASTPRIVATE_CONDITIONAL;
else
{
sorry_at (OMP_CLAUSE_LOCATION (c),
"%<conditional%> modifier on %<lastprivate%> "
"clause not supported yet");
OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c) = 0;
}
}
if (outer_ctx if (outer_ctx
&& (outer_ctx->region_type == ORT_COMBINED_PARALLEL && (outer_ctx->region_type == ORT_COMBINED_PARALLEL
|| ((outer_ctx->region_type & ORT_COMBINED_TEAMS) || ((outer_ctx->region_type & ORT_COMBINED_TEAMS)
...@@ -10770,7 +10781,22 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) ...@@ -10770,7 +10781,22 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
1 + (TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)) 1 + (TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt))
!= 1)); != 1));
if (n != NULL && (n->value & GOVD_DATA_SHARE_CLASS) != 0) if (n != NULL && (n->value & GOVD_DATA_SHARE_CLASS) != 0)
omp_notice_variable (gimplify_omp_ctxp, decl, true); {
omp_notice_variable (gimplify_omp_ctxp, decl, true);
if (n->value & GOVD_LASTPRIVATE_CONDITIONAL)
for (tree c3 = omp_find_clause (OMP_FOR_CLAUSES (for_stmt),
OMP_CLAUSE_LASTPRIVATE);
c3; c3 = omp_find_clause (OMP_CLAUSE_CHAIN (c3),
OMP_CLAUSE_LASTPRIVATE))
if (OMP_CLAUSE_DECL (c3) == decl)
{
warning_at (OMP_CLAUSE_LOCATION (c3), 0,
"conditional %<lastprivate%> on loop "
"iterator %qD ignored", decl);
OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c3) = 0;
n->value &= ~GOVD_LASTPRIVATE_CONDITIONAL;
}
}
else if (TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)) == 1) else if (TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)) == 1)
{ {
c = build_omp_clause (input_location, OMP_CLAUSE_LINEAR); c = build_omp_clause (input_location, OMP_CLAUSE_LINEAR);
...@@ -11005,7 +11031,24 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) ...@@ -11005,7 +11031,24 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
} }
} }
else if (omp_is_private (gimplify_omp_ctxp, decl, 0)) else if (omp_is_private (gimplify_omp_ctxp, decl, 0))
omp_notice_variable (gimplify_omp_ctxp, decl, true); {
omp_notice_variable (gimplify_omp_ctxp, decl, true);
splay_tree_node n = splay_tree_lookup (gimplify_omp_ctxp->variables,
(splay_tree_key) decl);
if (n && (n->value & GOVD_LASTPRIVATE_CONDITIONAL))
for (tree c3 = omp_find_clause (OMP_FOR_CLAUSES (for_stmt),
OMP_CLAUSE_LASTPRIVATE);
c3; c3 = omp_find_clause (OMP_CLAUSE_CHAIN (c3),
OMP_CLAUSE_LASTPRIVATE))
if (OMP_CLAUSE_DECL (c3) == decl)
{
warning_at (OMP_CLAUSE_LOCATION (c3), 0,
"conditional %<lastprivate%> on loop "
"iterator %qD ignored", decl);
OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c3) = 0;
n->value &= ~GOVD_LASTPRIVATE_CONDITIONAL;
}
}
else else
omp_add_variable (gimplify_omp_ctxp, decl, GOVD_PRIVATE | GOVD_SEEN); omp_add_variable (gimplify_omp_ctxp, decl, GOVD_PRIVATE | GOVD_SEEN);
......
...@@ -168,6 +168,7 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd, ...@@ -168,6 +168,7 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
fd->have_nowait = distribute || simd; fd->have_nowait = distribute || simd;
fd->have_ordered = false; fd->have_ordered = false;
fd->have_reductemp = false; fd->have_reductemp = false;
fd->lastprivate_conditional = 0;
fd->tiling = NULL_TREE; fd->tiling = NULL_TREE;
fd->collapse = 1; fd->collapse = 1;
fd->ordered = 0; fd->ordered = 0;
...@@ -220,6 +221,11 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd, ...@@ -220,6 +221,11 @@ omp_extract_for_data (gomp_for *for_stmt, struct omp_for_data *fd,
break; break;
case OMP_CLAUSE__REDUCTEMP_: case OMP_CLAUSE__REDUCTEMP_:
fd->have_reductemp = true; fd->have_reductemp = true;
break;
case OMP_CLAUSE_LASTPRIVATE:
if (OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (t))
fd->lastprivate_conditional++;
break;
default: default:
break; break;
} }
......
...@@ -63,6 +63,7 @@ struct omp_for_data ...@@ -63,6 +63,7 @@ struct omp_for_data
int collapse; /* Collapsed loops, 1 for a non-collapsed loop. */ int collapse; /* Collapsed loops, 1 for a non-collapsed loop. */
int ordered; int ordered;
bool have_nowait, have_ordered, simd_schedule, have_reductemp; bool have_nowait, have_ordered, simd_schedule, have_reductemp;
int lastprivate_conditional;
unsigned char sched_modifiers; unsigned char sched_modifiers;
enum omp_clause_schedule_kind sched_kind; enum omp_clause_schedule_kind sched_kind;
struct omp_for_data_loop *loops; struct omp_for_data_loop *loops;
......
2019-05-24 Jakub Jelinek <jakub@redhat.com>
* c-c++-common/gomp/lastprivate-conditional-2.c (foo): Don't expect
sorry for omp for.
* c-c++-common/gomp/lastprivate-conditional-3.c: New test.
2019-05-24 Richard Biener <rguenther@suse.de> 2019-05-24 Richard Biener <rguenther@suse.de>
PR testsuite/90607 PR testsuite/90607
......
...@@ -4,7 +4,7 @@ foo (int *p) ...@@ -4,7 +4,7 @@ foo (int *p)
int a = -1, b = -1, c = -1, d = -1, e = -1, f = -1, g = -1, h = -1; int a = -1, b = -1, c = -1, d = -1, e = -1, f = -1, g = -1, h = -1;
int i; int i;
#pragma omp parallel #pragma omp parallel
#pragma omp for lastprivate (conditional: a) /* { dg-message "not supported yet" } */ #pragma omp for lastprivate (conditional: a)
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
if (p[i]) if (p[i])
a = i; a = i;
......
void
foo (int *p)
{
int i, j, k;
#pragma omp parallel
{
#pragma omp for lastprivate (conditional: i) /* { dg-warning "conditional 'lastprivate' on loop iterator 'i' ignored" } */
for (i = 0; i < 32; i++)
;
#pragma omp for collapse (3) lastprivate (conditional: i) /* { dg-warning "conditional 'lastprivate' on loop iterator 'i' ignored" } */
for (i = 0; i < 32; i++)
for (j = 0; j < 32; ++j)
for (k = 0; k < 2; ++k)
;
#pragma omp for collapse (3) lastprivate (conditional: j) /* { dg-warning "conditional 'lastprivate' on loop iterator 'j' ignored" } */
for (i = 0; i < 32; i++)
for (j = 0; j < 32; ++j)
for (k = 0; k < 2; ++k)
;
#pragma omp for collapse (3) lastprivate (conditional: k) /* { dg-warning "conditional 'lastprivate' on loop iterator 'k' ignored" } */
for (i = 0; i < 32; i++)
for (j = 0; j < 32; ++j)
for (k = 0; k < 2; ++k)
;
}
}
...@@ -343,6 +343,9 @@ enum omp_clause_code { ...@@ -343,6 +343,9 @@ enum omp_clause_code {
/* Internal clause: temporary for task reductions. */ /* Internal clause: temporary for task reductions. */
OMP_CLAUSE__REDUCTEMP_, OMP_CLAUSE__REDUCTEMP_,
/* Internal clause: temporary for lastprivate(conditional:). */
OMP_CLAUSE__CONDTEMP_,
/* OpenACC/OpenMP clause: if (scalar-expression). */ /* OpenACC/OpenMP clause: if (scalar-expression). */
OMP_CLAUSE_IF, OMP_CLAUSE_IF,
......
...@@ -1369,6 +1369,7 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) ...@@ -1369,6 +1369,7 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi)
function decomposition happens before that. */ function decomposition happens before that. */
case OMP_CLAUSE__LOOPTEMP_: case OMP_CLAUSE__LOOPTEMP_:
case OMP_CLAUSE__REDUCTEMP_: case OMP_CLAUSE__REDUCTEMP_:
case OMP_CLAUSE__CONDTEMP_:
case OMP_CLAUSE__SIMDUID_: case OMP_CLAUSE__SIMDUID_:
case OMP_CLAUSE__GRIDDIM_: case OMP_CLAUSE__GRIDDIM_:
case OMP_CLAUSE__SIMT_: case OMP_CLAUSE__SIMT_:
...@@ -2096,6 +2097,7 @@ convert_local_omp_clauses (tree *pclauses, struct walk_stmt_info *wi) ...@@ -2096,6 +2097,7 @@ convert_local_omp_clauses (tree *pclauses, struct walk_stmt_info *wi)
function decomposition happens before that. */ function decomposition happens before that. */
case OMP_CLAUSE__LOOPTEMP_: case OMP_CLAUSE__LOOPTEMP_:
case OMP_CLAUSE__REDUCTEMP_: case OMP_CLAUSE__REDUCTEMP_:
case OMP_CLAUSE__CONDTEMP_:
case OMP_CLAUSE__SIMDUID_: case OMP_CLAUSE__SIMDUID_:
case OMP_CLAUSE__GRIDDIM_: case OMP_CLAUSE__GRIDDIM_:
case OMP_CLAUSE__SIMT_: case OMP_CLAUSE__SIMT_:
......
...@@ -466,6 +466,9 @@ dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags) ...@@ -466,6 +466,9 @@ dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
case OMP_CLAUSE__REDUCTEMP_: case OMP_CLAUSE__REDUCTEMP_:
name = "_reductemp_"; name = "_reductemp_";
goto print_remap; goto print_remap;
case OMP_CLAUSE__CONDTEMP_:
name = "_condtemp_";
goto print_remap;
case OMP_CLAUSE_TO_DECLARE: case OMP_CLAUSE_TO_DECLARE:
name = "to"; name = "to";
goto print_remap; goto print_remap;
......
...@@ -308,6 +308,7 @@ unsigned const char omp_clause_num_ops[] = ...@@ -308,6 +308,7 @@ unsigned const char omp_clause_num_ops[] =
0, /* OMP_CLAUSE_SEQ */ 0, /* OMP_CLAUSE_SEQ */
1, /* OMP_CLAUSE__LOOPTEMP_ */ 1, /* OMP_CLAUSE__LOOPTEMP_ */
1, /* OMP_CLAUSE__REDUCTEMP_ */ 1, /* OMP_CLAUSE__REDUCTEMP_ */
1, /* OMP_CLAUSE__CONDTEMP_ */
1, /* OMP_CLAUSE_IF */ 1, /* OMP_CLAUSE_IF */
1, /* OMP_CLAUSE_NUM_THREADS */ 1, /* OMP_CLAUSE_NUM_THREADS */
1, /* OMP_CLAUSE_SCHEDULE */ 1, /* OMP_CLAUSE_SCHEDULE */
...@@ -385,6 +386,7 @@ const char * const omp_clause_code_name[] = ...@@ -385,6 +386,7 @@ const char * const omp_clause_code_name[] =
"seq", "seq",
"_looptemp_", "_looptemp_",
"_reductemp_", "_reductemp_",
"_condtemp_",
"if", "if",
"num_threads", "num_threads",
"schedule", "schedule",
...@@ -12304,6 +12306,7 @@ walk_tree_1 (tree *tp, walk_tree_fn func, void *data, ...@@ -12304,6 +12306,7 @@ walk_tree_1 (tree *tp, walk_tree_fn func, void *data,
case OMP_CLAUSE_IS_DEVICE_PTR: case OMP_CLAUSE_IS_DEVICE_PTR:
case OMP_CLAUSE__LOOPTEMP_: case OMP_CLAUSE__LOOPTEMP_:
case OMP_CLAUSE__REDUCTEMP_: case OMP_CLAUSE__REDUCTEMP_:
case OMP_CLAUSE__CONDTEMP_:
case OMP_CLAUSE__SIMDUID_: case OMP_CLAUSE__SIMDUID_:
WALK_SUBTREE (OMP_CLAUSE_OPERAND (*tp, 0)); WALK_SUBTREE (OMP_CLAUSE_OPERAND (*tp, 0));
/* FALLTHRU */ /* FALLTHRU */
......
...@@ -1439,7 +1439,7 @@ class auto_suppress_location_wrappers ...@@ -1439,7 +1439,7 @@ class auto_suppress_location_wrappers
#define OMP_CLAUSE_DECL(NODE) \ #define OMP_CLAUSE_DECL(NODE) \
OMP_CLAUSE_OPERAND (OMP_CLAUSE_RANGE_CHECK (OMP_CLAUSE_CHECK (NODE), \ OMP_CLAUSE_OPERAND (OMP_CLAUSE_RANGE_CHECK (OMP_CLAUSE_CHECK (NODE), \
OMP_CLAUSE_PRIVATE, \ OMP_CLAUSE_PRIVATE, \
OMP_CLAUSE__REDUCTEMP_), 0) OMP_CLAUSE__CONDTEMP_), 0)
#define OMP_CLAUSE_HAS_LOCATION(NODE) \ #define OMP_CLAUSE_HAS_LOCATION(NODE) \
(LOCATION_LOCUS ((OMP_CLAUSE_CHECK (NODE))->omp_clause.locus) \ (LOCATION_LOCUS ((OMP_CLAUSE_CHECK (NODE))->omp_clause.locus) \
!= UNKNOWN_LOCATION) != UNKNOWN_LOCATION)
......
2019-05-24 Jakub Jelinek <jakub@redhat.com> 2019-05-24 Jakub Jelinek <jakub@redhat.com>
* testsuite/libgomp.c-c++-common/lastprivate-conditional-1.c: New test.
* testsuite/libgomp.c-c++-common/lastprivate-conditional-2.c: New test.
PR libgomp/90585 PR libgomp/90585
* plugin/plugin-hsa.c: Include gstdint.h. Include inttypes.h only if * plugin/plugin-hsa.c: Include gstdint.h. Include inttypes.h only if
HAVE_INTTYPES_H is defined. HAVE_INTTYPES_H is defined.
......
/* { dg-do run } */
/* { dg-require-effective-target tls_runtime } */
/* { dg-additional-options "-std=gnu99" {target c } } */
#include <omp.h>
#include <stdlib.h>
int r, s, u, v, r2, s2, u2, v2, r3, s3, u3, v3;
long long w, w2, w3, p, p2, p3;
int *x, *x2, *x3;
short y, y2, y3;
int z;
int thr1, thr2;
#pragma omp threadprivate (thr1, thr2)
void
foo (int *a, long long int b, long long int c)
{
int i;
long long j;
#pragma omp for lastprivate (conditional: u, x) nowait
for (i = 15; i < 64; i++)
{
if ((a[i] % 5) == 3)
u = i;
if ((a[i] % 7) == 2)
x = &a[i];
}
#pragma omp for nowait lastprivate (conditional: v) reduction (+:r, s) schedule (nonmonotonic: static)
for (i = -3; i < 119; i += 2)
{
++s;
if ((a[i + 4] % 11) == 9)
v = i;
else
++r;
}
#pragma omp for schedule (monotonic: static) lastprivate (conditional: w) nowait
for (j = b; j < b + 115 * c; j += (b & 3) + 7)
if ((a[j] % 13) == 5)
w = j * 2;
#pragma omp for schedule (auto) lastprivate (conditional: p) collapse(3)
for (i = -5; i < (int) (b + 5); i += 2)
for (j = b + 12 + c; j > b; --j)
for (int k = 0; k < 5; k += c)
if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6)
p = i * 10000 + j * 100 + k;
#pragma omp for schedule (nonmonotonic: static, 2) nowait lastprivate (conditional: u2, x2)
for (i = 15; i < 64; i++)
{
if ((a[i] % 5) == 3)
u2 = i;
if ((a[i] % 7) == 2)
x2 = &a[i];
}
#pragma omp for schedule (static, 3) lastprivate (conditional: v2) reduction (+:r2, s2)
for (i = -3; i < 119; i += 2)
{
++s2;
if ((a[i + 4] % 11) == 9)
v2 = i;
else
++r2;
}
#pragma omp for lastprivate (conditional: w2) schedule (static, 1) nowait
for (j = b; j < b + 115 * c; j += (b & 3) + 7)
if ((a[j] % 13) == 5)
w2 = j * 2;
#pragma omp for schedule (static, 3) collapse (3) lastprivate (conditional: p2)
for (i = -5; i < (int) (b + 5); i += 2)
for (j = b + 12 + c; j > b; --j)
for (int k = 0; k < 5; k += c)
if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6)
p2 = i * 10000 + j * 100 + k;
#pragma omp for lastprivate (conditional: u3, x3) nowait schedule (runtime)
for (i = 15; i < 64; i++)
{
if ((a[i] % 5) == 3)
u3 = i;
if ((a[i] % 7) == 2)
x3 = &a[i];
}
#pragma omp for nowait lastprivate (conditional: v3) reduction (+:r3, s3) schedule (nonmonotonic: dynamic)
for (i = -3; i < 119; i += 2)
{
++s3;
if ((a[i + 4] % 11) == 9)
v3 = i;
else
++r3;
}
#pragma omp for schedule (monotonic: guided, 3) lastprivate (conditional: w3) nowait
for (j = b; j < b + 115 * c; j += (b & 3) + 7)
if ((a[j] % 13) == 5)
w3 = j * 2;
#pragma omp for schedule (dynamic, 4) lastprivate (conditional: p3) collapse(3)
for (i = -5; i < (int) (b + 5); i += 2)
for (j = b + 12 + c; j > b; --j)
for (int k = 0; k < 5; k += c)
if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6)
p3 = i * 10000 + j * 100 + k;
/* Nasty testcase, verify that even a no-op assignment is accounted
for in lastprivate(conditional:). */
#pragma omp for schedule (monotonic: static, 2) firstprivate (z) \
lastprivate (conditional: z)
for (int k = -2000; k < 8000; ++k)
{
if (k < 3000 && (k & 3) == 1)
{
z = k;
thr1 = k;
}
else if (k == 7931)
{
z = z;
thr2 = 1;
}
}
if (thr2 && z != thr1)
abort ();
}
int
main ()
{
int a[128], i;
volatile int j = 0;
for (i = 0; i < 128; i++)
a[i] = i;
w = 1234;
#pragma omp parallel
foo (a, j, j + 1);
if (u != 63 || v != 115 || w != 140 || x != &a[58] || r != 55 || s != 61 || p != 30104)
abort ();
if (u2 != 63 || v2 != 115 || w2 != 140 || x2 != &a[58] || r2 != 55 || s2 != 61 || p2 != 30104)
abort ();
if (u3 != 63 || v3 != 115 || w3 != 140 || x3 != &a[58] || r3 != 55 || s3 != 61 || p3 != 30104)
abort ();
return 0;
}
/* { dg-do run } */
/* { dg-require-effective-target tls_runtime } */
/* { dg-additional-options "-std=gnu99" {target c } } */
#include <omp.h>
#include <stdlib.h>
int r, s, u, v, r2, s2, u2, v2, r3, s3, u3, v3, t;
long long w, w2, w3, p, p2, p3;
int *x, *x2, *x3;
short y, y2, y3;
int z;
int thr1, thr2;
#pragma omp threadprivate (thr1, thr2)
void
foo (int *a, long long int b, long long int c)
{
int i;
long long j;
#pragma omp for lastprivate (conditional: u, x) reduction (task, +: t)
for (i = 15; i < 64; i++)
{
++t;
if ((a[i] % 5) == 3)
u = i;
if ((a[i] % 7) == 2)
x = &a[i];
}
#pragma omp for lastprivate (conditional: v) reduction (+:r, s) schedule (nonmonotonic: static) reduction (task, +: t)
for (i = -3; i < 119; i += 2)
{
++s;
++t;
if ((a[i + 4] % 11) == 9)
v = i;
else
++r;
}
#pragma omp for schedule (monotonic: static) lastprivate (conditional: w) reduction (task, +: t)
for (j = b; j < b + 115 * c; j += (b & 3) + 7)
{
if ((a[j] % 13) == 5)
w = j * 2;
++t;
}
#pragma omp for schedule (auto) lastprivate (conditional: p) collapse(3) reduction (task, +: t)
for (i = -5; i < (int) (b + 5); i += 2)
for (j = b + 12 + c; j > b; --j)
for (int k = 0; k < 5; k += c)
{
++t;
if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6)
p = i * 10000 + j * 100 + k;
}
#pragma omp for schedule (nonmonotonic: static, 2) reduction (task, +: t) lastprivate (conditional: u2, x2)
for (i = 15; i < 64; i++)
{
if ((a[i] % 5) == 3)
u2 = i;
if ((a[i] % 7) == 2)
x2 = &a[i];
t++;
}
#pragma omp for schedule (static, 3) lastprivate (conditional: v2) reduction (+:r2, s2) reduction (task, +: t)
for (i = -3; i < 119; i += 2)
{
++s2;
if ((a[i + 4] % 11) == 9)
v2 = i;
else
++r2;
t++;
}
#pragma omp for lastprivate (conditional: w2) schedule (static, 1) reduction (task, +: t)
for (j = b; j < b + 115 * c; j += (b & 3) + 7)
{
if ((a[j] % 13) == 5)
w2 = j * 2;
t += 1;
}
#pragma omp for schedule (static, 3) collapse (3) reduction (task, +: t) lastprivate (conditional: p2)
for (i = -5; i < (int) (b + 5); i += 2)
for (j = b + 12 + c; j > b; --j)
for (int k = 0; k < 5; k += c)
{
++t;
if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6)
p2 = i * 10000 + j * 100 + k;
}
#pragma omp for lastprivate (conditional: u3, x3) reduction (task, +: t) schedule (runtime)
for (i = 15; i < 64; i++)
{
t = t + 1;
if ((a[i] % 5) == 3)
u3 = i;
if ((a[i] % 7) == 2)
x3 = &a[i];
}
#pragma omp for reduction (task, +: t) lastprivate (conditional: v3) reduction (+:r3, s3) schedule (nonmonotonic: dynamic)
for (i = -3; i < 119; i += 2)
{
++s3;
if ((a[i + 4] % 11) == 9)
v3 = i;
else
++r3;
++t;
}
#pragma omp for schedule (monotonic: guided, 3) lastprivate (conditional: w3) reduction (task, +: t)
for (j = b; j < b + 115 * c; j += (b & 3) + 7)
{
if ((a[j] % 13) == 5)
w3 = j * 2;
t++;
}
#pragma omp for schedule (dynamic, 4) lastprivate (conditional: p3) collapse(3) reduction (task, +: t)
for (i = -5; i < (int) (b + 5); i += 2)
for (j = b + 12 + c; j > b; --j)
for (int k = 0; k < 5; k += c)
{
++t;
if (((((i + 5) * 13 + (13 - j)) * 5 + k) % 17) == 6)
p3 = i * 10000 + j * 100 + k;
}
/* Nasty testcase, verify that even a no-op assignment is accounted
for in lastprivate(conditional:). */
#pragma omp for schedule (monotonic: static, 2) firstprivate (z) \
lastprivate (conditional: z) reduction (task, +: t)
for (int k = -2000; k < 8000; ++k)
{
t++;
if (k < 3000 && (k & 3) == 1)
{
z = k;
thr1 = k;
}
else if (k == 7931)
{
z = z;
thr2 = 1;
}
}
if (thr2 && z != thr1)
abort ();
}
int
main ()
{
int a[128], i;
volatile int j = 0;
for (i = 0; i < 128; i++)
a[i] = i;
w = 1234;
#pragma omp parallel
foo (a, j, j + 1);
if (u != 63 || v != 115 || w != 140 || x != &a[58] || r != 55 || s != 61 || p != 30104)
abort ();
if (u2 != 63 || v2 != 115 || w2 != 140 || x2 != &a[58] || r2 != 55 || s2 != 61 || p2 != 30104)
abort ();
if (u3 != 63 || v3 != 115 || w3 != 140 || x3 != &a[58] || r3 != 55 || s3 != 61 || p3 != 30104)
abort ();
if (t != 11356)
abort ();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment