Commit Graph

1491 Commits

Author SHA1 Message Date
Jakub Jelinek 0d973c0a0d openmp: Implement the error directive
This patch implements the error directive.  Depending on clauses it is either
a compile time diagnostics (in that case diagnosed right away) or runtime
diagnostics (libgomp API call that diagnoses at runtime), and either fatal
or warning (error or warning at compile time or fatal error vs. error at
runtime) and either has no message or user supplied message (this kind of
e.g. deprecated attribute).  The directive is also stand-alone directive
when at runtime while utility (thus disappears from the IL as if it wasn't
there for parsing like nothing directive) at compile time.

There are some clarifications in the works ATM, so this patch doesn't yet
require that for compile time diagnostics the user message must be a constant
string literal, there are uncertainities on what exactly is valid argument
of message clause (whether just const char * type, convertible to const char *,
qualified/unqualified const char * or char * or what else) and what to do
in templates.  Currently even in templates it is diagnosed right away for
compile time diagnostics, if we'll need to substitute it, we'd need to queue
something into the IL, have pt.c handle it and diagnose only later.

2021-08-20  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* omp-builtins.def (BUILT_IN_GOMP_WARNING, BUILT_IN_GOMP_ERROR): New
	builtins.
gcc/c-family/
	* c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_ERROR.
	* c-pragma.c (omp_pragmas): Add error directive.
	* c-omp.c (omp_directives): Uncomment error directive entry.
gcc/c/
	* c-parser.c (c_parser_omp_error): New function.
	(c_parser_pragma): Handle PRAGMA_OMP_ERROR.
gcc/cp/
	* parser.c (cp_parser_handle_statement_omp_attributes): Determine if
	PRAGMA_OMP_ERROR directive is C_OMP_DIR_STANDALONE.
	(cp_parser_omp_error): New function.
	(cp_parser_pragma): Handle PRAGMA_OMP_ERROR.
gcc/fortran/
	* types.def (BT_FN_VOID_CONST_PTR_SIZE): New DEF_FUNCTION_TYPE_2.
	* f95-lang.c (ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST): Define.
gcc/testsuite/
	* c-c++-common/gomp/error-1.c: New test.
	* c-c++-common/gomp/error-2.c: New test.
	* c-c++-common/gomp/error-3.c: New test.
	* g++.dg/gomp/attrs-1.C (bar): Add error directive test.
	* g++.dg/gomp/attrs-2.C (bar): Add error directive test.
	* g++.dg/gomp/attrs-13.C: New test.
	* g++.dg/gomp/error-1.C: New test.
libgomp/
	* libgomp.map (GOMP_5.1): Add GOMP_error and GOMP_warning.
	* libgomp_g.h (GOMP_warning, GOMP_error): Declare.
	* error.c (GOMP_warning, GOMP_error): New functions.
	* testsuite/libgomp.c-c++-common/error-1.c: New test.
2021-08-20 11:36:52 +02:00
GCC Administrator 6e529985d8 Daily bump. 2021-08-19 00:16:42 +00:00
Tobias Burnus 76bb3c50dd Fortran/OpenMP: Add memory routines existing for C/C++
This patch adds the Fortran interface for omp_alloc/omp_free
and the omp_target_* memory routines, which were added in
OpenMP 5.0 for C/C++ but only OpenMP 5.1 added them for Fortran.

Those functions use BIND(C), i.e. on the libgomp side, the same
interface as for C/C++ is used.

Note: By using BIND(C) in omp_lib.h, files including this file
no longer compiler with -std=f95 but require at least -std=f2003.

libgomp/ChangeLog:

	* omp_lib.f90.in (omp_alloc, omp_free, omp_target_alloc,
	omp_target_free. omp_target_is_present, omp_target_memcpy,
	omp_target_memcpy_rect, omp_target_associate_ptr,
	omp_target_disassociate_ptr): Add interface.
	* omp_lib.h.in (omp_alloc, omp_free, omp_target_alloc,
	omp_target_free. omp_target_is_present, omp_target_memcpy,
	omp_target_memcpy_rect, omp_target_associate_ptr,
	omp_target_disassociate_ptr): Add interface.
	* testsuite/libgomp.fortran/alloc-1.F90: Remove local
	interface block for omp_alloc + omp_free.
	* testsuite/libgomp.fortran/alloc-4.f90: Likewise.
	* testsuite/libgomp.fortran/refcount-1.f90: New test.
	* testsuite/libgomp.fortran/target-12.f90: New test.
2021-08-18 11:15:47 +02:00
Jakub Jelinek 5079b7781a openmp: Add nothing directive support
As has been clarified, it is intentional that nothing directive is accepted
in substatements of selection and looping statements and after labels and
is handled as if the directive just isn't there, so that
void
foo (int x)
{
  if (x)
    #pragma omp metadirective when (...:nothing) when (...:parallel)
    bar ();
}
behaves consistently; declarative and stand-alone directives aren't allowed
at that point, but constructs are parsed with the following statement as
the construct body and nothing or missing default on metadirective therefore
should handle the following statement as part of the if substatement instead
of having nothing as the substatement and bar done unconditionally after the
if.

2021-08-18  Jakub Jelinek  <jakub@redhat.com>

gcc/c-family/
	* c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_NOTHING.
	* c-pragma.c (omp_pragmas): Add nothing directive.
	* c-omp.c (omp_directives): Uncomment nothing directive entry.
gcc/c/
	* c-parser.c (c_parser_omp_nothing): New function.
	(c_parser_pragma): Handle PRAGMA_OMP_NOTHING.
gcc/cp/
	* parser.c (cp_parser_omp_nothing): New function.
	(cp_parser_pragma): Handle PRAGMA_OMP_NOTHING.
gcc/testsuite/
	* c-c++-common/gomp/nothing-1.c: New test.
	* g++.dg/gomp/attrs-1.C (bar): Add nothing directive test.
	* g++.dg/gomp/attrs-2.C (bar): Likewise.
	* g++.dg/gomp/attrs-9.C: Likewise.
libgomp/
	* testsuite/libgomp.c-c++-common/nothing-1.c: New test.
2021-08-18 11:10:43 +02:00
GCC Administrator 2d14d64bf2 Daily bump. 2021-08-18 00:16:48 +00:00
Tobias Burnus f8d535f3fe Fortran: Implement OpenMP 5.1 scope construct
Fortran version to commit e45483c7c4,
which implemented OpenMP's scope construct for C and C++.
Most testcases are based on the C testcases; it also contains some
testcases which existed previously but had no Fortran equivalent.

gcc/fortran/ChangeLog:

	* dump-parse-tree.c (show_omp_node, show_code_node): Handle
	EXEC_OMP_SCOPE.
	* gfortran.h (enum gfc_statement): Add ST_OMP_(END_)SCOPE.
	(enum gfc_exec_op): Add EXEC_OMP_SCOPE.
	* match.h (gfc_match_omp_scope): New.
	* openmp.c (OMP_SCOPE_CLAUSES): Define
	(gfc_match_omp_scope): New.
	(gfc_match_omp_cancellation_point, gfc_match_omp_end_nowait):
	Improve error diagnostic.
	(omp_code_to_statement): Handle ST_OMP_SCOPE.
	(gfc_resolve_omp_directive): Handle EXEC_OMP_SCOPE.
	* parse.c (decode_omp_directive, next_statement,
	gfc_ascii_statement, parse_omp_structured_block,
	parse_executable): Handle OpenMP's scope construct.
	* resolve.c (gfc_resolve_blocks): Likewise
	* st.c (gfc_free_statement): Likewise
	* trans-openmp.c (gfc_trans_omp_scope): New.
	(gfc_trans_omp_directive): Call it.
	* trans.c (trans_code): handle EXEC_OMP_SCOPE.

libgomp/ChangeLog:

	* testsuite/libgomp.fortran/scope-1.f90: New test.
	* testsuite/libgomp.fortran/task-reduction-16.f90: New test.

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/scan-1.f90:
	* gfortran.dg/gomp/cancel-1.f90: New test.
	* gfortran.dg/gomp/cancel-4.f90: New test.
	* gfortran.dg/gomp/loop-4.f90: New test.
	* gfortran.dg/gomp/nesting-1.f90: New test.
	* gfortran.dg/gomp/nesting-2.f90: New test.
	* gfortran.dg/gomp/nesting-3.f90: New test.
	* gfortran.dg/gomp/nowait-1.f90: New test.
	* gfortran.dg/gomp/reduction-task-1.f90: New test.
	* gfortran.dg/gomp/reduction-task-2.f90: New test.
	* gfortran.dg/gomp/reduction-task-2a.f90: New test.
	* gfortran.dg/gomp/reduction-task-3.f90: New test.
	* gfortran.dg/gomp/scope-1.f90: New test.
	* gfortran.dg/gomp/scope-2.f90: New test.
2021-08-17 15:51:03 +02:00
Jakub Jelinek e45483c7c4 openmp: Implement OpenMP 5.1 scope construct
This patch implements the OpenMP 5.1 scope construct, which is similar
to worksharing constructs in many regards, but isn't one of them.
The body of the construct is encountered by all threads though, it can
be nested in itself or intermixed with taskgroup and worksharing etc.
constructs can appear inside of it (but it can't be nested in
worksharing etc. constructs).  The main purpose of the construct
is to allow reductions (normal and task ones) without the need to
close the parallel and reopen another one.

If it doesn't have task reductions, it can be implemented without
any new library support, with nowait it just does the privatizations
at the start if any and reductions before the end of the body, with
without nowait emits a normal GOMP_barrier{,_cancel} at the end too.

For task reductions, we need to ensure only one thread initializes
the task reduction library data structures and other threads copy from that,
so a new GOMP_scope_start routine is added to the library for that.
It acts as if the start of the scope construct is a nowait worksharing
construct (that is ok, it can't be nested in other worksharing
constructs and all threads need to encounter the start in the same
order) which does the task reduction initialization, but as the body
can have other scope constructs and/or worksharing constructs, that is
all where we use this dummy worksharing construct.  With task reductions,
the construct must not have nowait and ends with a GOMP_barrier{,_cancel},
followed by task reductions followed by GOMP_workshare_task_reduction_unregister.

Only C/C++ FE support is done.

2021-08-17  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* tree.def (OMP_SCOPE): New tree code.
	* tree.h (OMP_SCOPE_BODY, OMP_SCOPE_CLAUSES): Define.
	* tree-nested.c (convert_nonlocal_reference_stmt,
	convert_local_reference_stmt, convert_gimple_call): Handle
	GIMPLE_OMP_SCOPE.
	* tree-pretty-print.c (dump_generic_node): Handle OMP_SCOPE.
	* gimple.def (GIMPLE_OMP_SCOPE): New gimple code.
	* gimple.c (gimple_build_omp_scope): New function.
	(gimple_copy): Handle GIMPLE_OMP_SCOPE.
	* gimple.h (gimple_build_omp_scope): Declare.
	(gimple_has_substatements): Handle GIMPLE_OMP_SCOPE.
	(gimple_omp_scope_clauses, gimple_omp_scope_clauses_ptr,
	gimple_omp_scope_set_clauses): New inline functions.
	(CASE_GIMPLE_OMP): Add GIMPLE_OMP_SCOPE.
	* gimple-pretty-print.c (dump_gimple_omp_scope): New function.
	(pp_gimple_stmt_1): Handle GIMPLE_OMP_SCOPE.
	* gimple-walk.c (walk_gimple_stmt): Likewise.
	* gimple-low.c (lower_stmt): Likewise.
	* gimplify.c (is_gimple_stmt): Handle OMP_MASTER.
	(gimplify_scan_omp_clauses): For task reductions, handle OMP_SCOPE
	like ORT_WORKSHARE constructs.  Adjust diagnostics for %<scope%>
	allowing task reductions.  Reject inscan reductions on scope.
	(omp_find_stores_stmt): Handle GIMPLE_OMP_SCOPE.
	(gimplify_omp_workshare, gimplify_expr): Handle OMP_SCOPE.
	* tree-inline.c (remap_gimple_stmt): Handle GIMPLE_OMP_SCOPE.
	(estimate_num_insns): Likewise.
	* omp-low.c (build_outer_var_ref): Look through GIMPLE_OMP_SCOPE
	contexts if var isn't privatized there.
	(check_omp_nesting_restrictions): Handle GIMPLE_OMP_SCOPE.
	(scan_omp_1_stmt): Likewise.
	(maybe_add_implicit_barrier_cancel): Look through outer
	scope constructs.
	(lower_omp_scope): New function.
	(lower_omp_task_reductions): Handle OMP_SCOPE.
	(lower_omp_1): Handle GIMPLE_OMP_SCOPE.
	(diagnose_sb_1, diagnose_sb_2): Likewise.
	* omp-expand.c (expand_omp_single): Support also GIMPLE_OMP_SCOPE.
	(expand_omp): Handle GIMPLE_OMP_SCOPE.
	(omp_make_gimple_edges): Likewise.
	* omp-builtins.def (BUILT_IN_GOMP_SCOPE_START): New built-in.
gcc/c-family/
	* c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_SCOPE.
	* c-pragma.c (omp_pragmas): Add scope construct.
	* c-omp.c (omp_directives): Uncomment scope directive entry.
gcc/c/
	* c-parser.c (OMP_SCOPE_CLAUSE_MASK): Define.
	(c_parser_omp_scope): New function.
	(c_parser_omp_construct): Handle PRAGMA_OMP_SCOPE.
gcc/cp/
	* parser.c (OMP_SCOPE_CLAUSE_MASK): Define.
	(cp_parser_omp_scope): New function.
	(cp_parser_omp_construct, cp_parser_pragma): Handle PRAGMA_OMP_SCOPE.
	* pt.c (tsubst_expr): Handle OMP_SCOPE.
gcc/testsuite/
	* c-c++-common/gomp/nesting-2.c (foo): Add scope and masked
	construct tests.
	* c-c++-common/gomp/scan-1.c (f3): Add scope construct test..
	* c-c++-common/gomp/cancel-1.c (f2): Add scope and masked
	construct tests.
	* c-c++-common/gomp/reduction-task-2.c (bar): Add scope construct
	test.  Adjust diagnostics for the addition of scope.
	* c-c++-common/gomp/loop-1.c (f5): Add master, masked and scope
	construct tests.
	* c-c++-common/gomp/clause-dups-1.c (f1): Add scope construct test.
	* gcc.dg/gomp/nesting-1.c (f1, f2, f3): Add scope construct tests.
	* c-c++-common/gomp/scope-1.c: New test.
	* c-c++-common/gomp/scope-2.c: New test.
	* g++.dg/gomp/attrs-1.C (bar): Add scope construct tests.
	* g++.dg/gomp/attrs-2.C (bar): Likewise.
	* gfortran.dg/gomp/reduction4.f90: Adjust expected diagnostics.
	* gfortran.dg/gomp/reduction7.f90: Likewise.
libgomp/
	* Makefile.am (libgomp_la_SOURCES): Add scope.c
	* Makefile.in: Regenerated.
	* libgomp_g.h (GOMP_scope_start): Declare.
	* libgomp.map: Add GOMP_scope_start@@GOMP_5.1.
	* scope.c: New file.
	* testsuite/libgomp.c-c++-common/scope-1.c: New test.
	* testsuite/libgomp.c-c++-common/task-reduction-16.c: New test.
2021-08-17 09:30:09 +02:00
GCC Administrator 9d1d9fc8b4 Daily bump. 2021-08-17 00:16:32 +00:00
Thomas Schwinge a2ab2f0dfb Address '?:' issues in 'libgomp.oacc-c-c++-common/mode-transitions.c'
[...]/libgomp.oacc-c-c++-common/mode-transitions.c: In function ‘t3’:
    [...]/libgomp.oacc-c-c++-common/mode-transitions.c:127:43: warning: ‘?:’ using integer constants in boolean context, the expression will always evaluate to ‘true’ [-Wint-in-bool-context]
      127 |     assert (arr[i] == ((i % 64) < 32) ? 1 : -1);
          |                                           ^

    [...]/libgomp.oacc-c-c++-common/mode-transitions.c: In function ‘t9’:
    [...]/libgomp.oacc-c-c++-common/mode-transitions.c:359:46: warning: ‘?:’ using integer constants in boolean context, the expression will always evaluate to ‘true’ [-Wint-in-bool-context]
      359 |         assert (arr[i] == ((i % 3) == 0) ? 1 : 2);
          |                                              ^

..., and PR101862 "[C, C++] Potential '?:' diagnostic for always-true
expressions in boolean context".

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/mode-transitions.c: Address
	'?:' issues.
2021-08-16 12:12:09 +02:00
Tobias Burnus 53d5b59cb3 Fortran/OpenMP: Add support for OpenMP 5.1 masked construct
Commit r12-2891-gd0befed793b94f3f407be44e6f69f81a02f5f073 added C/C++
support for the masked construct. This patch extends it to
Fortran.

gcc/fortran/ChangeLog:

	* dump-parse-tree.c (show_omp_clauses): Handle 'filter' clause.
	(show_omp_node, show_code_node): Handle (combined) omp masked construct.
	* frontend-passes.c (gfc_code_walker): Likewise.
	* gfortran.h (enum gfc_statement): Add ST_OMP_*_MASKED*.
	(enum gfc_exec_op): Add EXEC_OMP_*_MASKED*.
	* match.h (gfc_match_omp_masked, gfc_match_omp_masked_taskloop,
	gfc_match_omp_masked_taskloop_simd, gfc_match_omp_parallel_masked,
	gfc_match_omp_parallel_masked_taskloop,
	gfc_match_omp_parallel_masked_taskloop_simd): New prototypes.
	* openmp.c (enum omp_mask1): Add OMP_CLAUSE_FILTER.
	(gfc_match_omp_clauses): Match it.
	(OMP_MASKED_CLAUSES, gfc_match_omp_parallel_masked,
	gfc_match_omp_parallel_masked_taskloop,
	gfc_match_omp_parallel_masked_taskloop_simd,
	gfc_match_omp_masked, gfc_match_omp_masked_taskloop,
	gfc_match_omp_masked_taskloop_simd): New.
	(resolve_omp_clauses): Resolve filter clause.
	(gfc_resolve_omp_parallel_blocks, resolve_omp_do,
	omp_code_to_statement, gfc_resolve_omp_directive): Handle
	omp masked constructs.
	* parse.c (decode_omp_directive, case_exec_markers,
	gfc_ascii_statement, parse_omp_do, parse_omp_structured_block,
	parse_executable): Likewise.
	* resolve.c (gfc_resolve_blocks, gfc_resolve_code): Likewise.
	* st.c (gfc_free_statement): Likewise.
	* trans-openmp.c (gfc_trans_omp_clauses): Handle filter clause.
	(GFC_OMP_SPLIT_MASKED, GFC_OMP_MASK_MASKED): New enum values.
	(gfc_trans_omp_masked): New.
	(gfc_split_omp_clauses): Handle combined masked directives.
	(gfc_trans_omp_master_taskloop): Rename to ...
	(gfc_trans_omp_master_masked_taskloop): ... this; handle also
	combined masked directives.
	(gfc_trans_omp_parallel_master): Rename to ...
	(gfc_trans_omp_parallel_master_masked): ... this; handle
	combined masked directives.
	(gfc_trans_omp_directive): Handle EXEC_OMP_*_MASKED*.
	* trans.c (trans_code): Likewise.

libgomp/ChangeLog:

	* testsuite/libgomp.fortran/masked-1.f90: New test.

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/masked-1.f90: New test.
	* gfortran.dg/gomp/masked-2.f90: New test.
	* gfortran.dg/gomp/masked-3.f90: New test.
	* gfortran.dg/gomp/masked-combined-1.f90: New test.
	* gfortran.dg/gomp/masked-combined-2.f90: New test.
2021-08-16 09:26:26 +02:00
GCC Administrator 261512fa6d Daily bump. 2021-08-14 00:16:29 +00:00
Thomas Schwinge 2cc65fcbd4 Adjust 'libgomp.oacc-c-c++-common/static-variable-1.c'
... for 'gcc/gimplify.c:gimplify_scan_omp_clauses' changes in recent
commit d0befed793 "openmp: Add support
for OpenMP 5.1 masked construct".

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/static-variable-1.c: Adjust.
2021-08-13 22:53:58 +02:00
GCC Administrator 72be20e202 Daily bump. 2021-08-13 00:16:43 +00:00
Jakub Jelinek d0befed793 openmp: Add support for OpenMP 5.1 masked construct
This construct has been introduced as a replacement for master
construct, but unlike that construct is slightly more general,
has an optional clause which allows to choose which thread
will be the one running the region, it can be some other thread
than the master (primary) thread with number 0, or it could be no
threads or multiple threads (then of course one needs to be careful
about data races).

It is way too early to deprecate the master construct though, we don't
even have OpenMP 5.0 fully implemented, it has been deprecated in 5.1,
will be also in 5.2 and removed in 6.0.  But even then it will likely
be a good idea to just -Wdeprecated warn about it and still accept it.

The patch also contains something I should have done much earlier,
for clauses that accept some integral expression where we only care
about the value, forces during gimplification that value into
either a min invariant (as before), SSA_NAME or a fresh temporary,
but never e.g. a user VAR_DECL, so that for those clauses we don't
need to worry about adjusting it.

2021-08-12  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* tree.def (OMP_MASKED): New tree code.
	* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_FILTER.
	* tree.h (OMP_MASKED_BODY, OMP_MASKED_CLAUSES, OMP_MASKED_COMBINED,
	OMP_CLAUSE_FILTER_EXPR): Define.
	* tree.c (omp_clause_num_ops): Add OMP_CLAUSE_FILTER entry.
	(omp_clause_code_name): Likewise.
	(walk_tree_1): Handle OMP_CLAUSE_FILTER.
	* tree-nested.c (convert_nonlocal_omp_clauses,
	convert_local_omp_clauses): Handle OMP_CLAUSE_FILTER.
	(convert_nonlocal_reference_stmt, convert_local_reference_stmt,
	convert_gimple_call): Handle GIMPLE_OMP_MASTER.
	* tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_FILTER.
	(dump_generic_node): Handle OMP_MASTER.
	* gimple.def (GIMPLE_OMP_MASKED): New gimple code.
	* gimple.c (gimple_build_omp_masked): New function.
	(gimple_copy): Handle GIMPLE_OMP_MASKED.
	* gimple.h (gimple_build_omp_masked): Declare.
	(gimple_has_substatements): Handle GIMPLE_OMP_MASKED.
	(gimple_omp_masked_clauses, gimple_omp_masked_clauses_ptr,
	gimple_omp_masked_set_clauses): New inline functions.
	(CASE_GIMPLE_OMP): Add GIMPLE_OMP_MASKED.
	* gimple-pretty-print.c (dump_gimple_omp_masked): New function.
	(pp_gimple_stmt_1): Handle GIMPLE_OMP_MASKED.
	* gimple-walk.c (walk_gimple_stmt): Likewise.
	* gimple-low.c (lower_stmt): Likewise.
	* gimplify.c (is_gimple_stmt): Handle OMP_MASTER.
	(gimplify_scan_omp_clauses): Handle OMP_CLAUSE_FILTER.  For clauses
	that take one expression rather than decl or constant, force
	gimplification of that into a SSA_NAME or temporary unless min
	invariant.
	(gimplify_adjust_omp_clauses): Handle OMP_CLAUSE_FILTER.
	(gimplify_expr): Handle OMP_MASKED.
	* tree-inline.c (remap_gimple_stmt): Handle GIMPLE_OMP_MASKED.
	(estimate_num_insns): Likewise.
	* omp-low.c (scan_sharing_clauses): Handle OMP_CLAUSE_FILTER.
	(check_omp_nesting_restrictions): Handle GIMPLE_OMP_MASKED.  Adjust
	diagnostics for existence of masked construct.
	(scan_omp_1_stmt, lower_omp_master, lower_omp_1, diagnose_sb_1,
	diagnose_sb_2): Handle GIMPLE_OMP_MASKED.
	* omp-expand.c (expand_omp_synch, expand_omp, omp_make_gimple_edges):
	Likewise.
gcc/c-family/
	* c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_MASKED.
	(enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_FILTER.
	* c-pragma.c (omp_pragmas_simd): Add masked construct.
	* c-common.h (enum c_omp_clause_split): Add C_OMP_CLAUSE_SPLIT_MASKED
	enumerator.
	(c_finish_omp_masked): Declare.
	* c-omp.c (c_finish_omp_masked): New function.
	(c_omp_split_clauses): Handle combined masked constructs.
gcc/c/
	* c-parser.c (c_parser_omp_clause_name): Parse filter clause name.
	(c_parser_omp_clause_filter): New function.
	(c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_FILTER.
	(OMP_MASKED_CLAUSE_MASK): Define.
	(c_parser_omp_masked): New function.
	(c_parser_omp_parallel): Handle parallel masked.
	(c_parser_omp_construct): Handle PRAGMA_OMP_MASKED.
	* c-typeck.c (c_finish_omp_clauses): Handle OMP_CLAUSE_FILTER.
gcc/cp/
	* parser.c (cp_parser_omp_clause_name): Parse filter clause name.
	(cp_parser_omp_clause_filter): New function.
	(cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_FILTER.
	(OMP_MASKED_CLAUSE_MASK): Define.
	(cp_parser_omp_masked): New function.
	(cp_parser_omp_parallel): Handle parallel masked.
	(cp_parser_omp_construct, cp_parser_pragma): Handle PRAGMA_OMP_MASKED.
	* semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_FILTER.
	* pt.c (tsubst_omp_clauses): Likewise.
	(tsubst_expr): Handle OMP_MASKED.
gcc/testsuite/
	* c-c++-common/gomp/clauses-1.c (bar): Add tests for combined masked
	constructs with clauses.
	* c-c++-common/gomp/clauses-5.c (foo): Add testcase for filter clause.
	* c-c++-common/gomp/clause-dups-1.c (f1): Likewise.
	* c-c++-common/gomp/masked-1.c: New test.
	* c-c++-common/gomp/masked-2.c: New test.
	* c-c++-common/gomp/masked-combined-1.c: New test.
	* c-c++-common/gomp/masked-combined-2.c: New test.
	* c-c++-common/goacc/uninit-if-clause.c: Remove xfails.
	* g++.dg/gomp/block-11.C: New test.
	* g++.dg/gomp/tpl-masked-1.C: New test.
	* g++.dg/gomp/attrs-1.C (bar): Add tests for masked construct and
	combined masked constructs with clauses in attribute syntax.
	* g++.dg/gomp/attrs-2.C (bar): Likewise.
	* gcc.dg/gomp/nesting-1.c (f1, f2): Add tests for masked construct
	nesting.
	* gfortran.dg/goacc/host_data-tree.f95: Allow also SSA_NAMEs in if
	clause.
	* gfortran.dg/goacc/kernels-tree.f95: Likewise.
libgomp/
	* testsuite/libgomp.c-c++-common/masked-1.c: New test.
2021-08-12 22:41:17 +02:00
Tobias Burnus 432de08498 OpenMP 5.1: Add proc-bind 'primary' support
In OpenMP 5.1 "master thread" was changed to "primary thread" and
the proc_bind clause and the OMP_PROC_BIND environment variable
now take 'primary' as argument as alias for 'master', while the
latter is deprecated.
This commit accepts 'primary' and adds the named constant
omp_proc_bind_primary and changes 'master thread' in the
documentation; however, given that not even OpenMP 5.0 is
fully supported, omp_display_env and the dumps currently
still output 'master' and there is no deprecation warning
when using the 'master' in the proc_bind clause.

gcc/c/ChangeLog:

	* c-parser.c (c_parser_omp_clause_proc_bind): Accept
	'primary' as alias for 'master'.

gcc/cp/ChangeLog:

	* parser.c (cp_parser_omp_clause_proc_bind): Accept
	'primary' as alias for 'master'.

gcc/fortran/ChangeLog:

	* gfortran.h (gfc_omp_proc_bind_kind): Add OMP_PROC_BIND_PRIMARY.
	* dump-parse-tree.c (show_omp_clauses): Add TODO comment to
	change 'master' to 'primary' in proc_bind for OpenMP 5.1.
	* intrinsic.texi (OMP_LIB): Mention OpenMP 5.1; add
	omp_proc_bind_primary.
	* openmp.c (gfc_match_omp_clauses): Accept
	'primary' as alias for 'master'.
	* trans-openmp.c (gfc_trans_omp_clauses): Handle
	OMP_PROC_BIND_PRIMARY.

gcc/ChangeLog:

	* tree-core.h (omp_clause_proc_bind_kind): Add
	OMP_CLAUSE_PROC_BIND_PRIMARY.
	* tree-pretty-print.c (dump_omp_clause): Add TODO comment to
	change 'master' to 'primary' in proc_bind for OpenMP 5.1.

libgomp/ChangeLog:

	* env.c (parse_bind_var): Accept 'primary' as alias for
	'master'.
	(omp_display_env): Add TODO comment to
	change 'master' to 'primary' in proc_bind for OpenMP 5.1.
	* libgomp.texi: Change 'master thread' to 'primary thread'
	in line with OpenMP 5.1.
	(omp_get_proc_bind): Add omp_proc_bind_primary and note that
	omp_proc_bind_master is an alias of it.
	(OMP_PROC_BIND): Mention 'PRIMARY'.
	* omp.h.in (__GOMP_DEPRECATED_5_1): Define.
	(omp_proc_bind_primary): Add.
	(omp_proc_bind_master): Deprecate for OpenMP 5.1.
	* omp_lib.f90.in (omp_proc_bind_primary): Add.
	(omp_proc_bind_master): Deprecate for OpenMP 5.1.
	* omp_lib.h.in (omp_proc_bind_primary): Add.
	* testsuite/libgomp.c/affinity-1.c: Check that
	'primary' works and is identical to 'master'.

gcc/testsuite/ChangeLog:

	* c-c++-common/gomp/pr61486-2.c: Duplicate one proc_bind(master)
	testcase and test proc_bind(primary) instead.
	* gfortran.dg/gomp/affinity-1.f90: Likewise.
2021-08-12 15:49:49 +02:00
GCC Administrator 377681505f Daily bump. 2021-08-10 00:16:28 +00:00
Julian Brown c408512e1f amdgcn: Enable OpenACC worker partitioning for AMD GCN
gcc/
	* config/gcn/gcn.c (gcn_init_builtins): Override decls for
	BUILT_IN_GOACC_SINGLE_START, BUILT_IN_GOACC_SINGLE_COPY_START,
	BUILT_IN_GOACC_SINGLE_COPY_END and BUILT_IN_GOACC_BARRIER.
	(gcn_goacc_validate_dims): Turn on worker partitioning unconditionally.
	(gcn_fork_join): Update comment.
	* config/gcn/gcn.opt (flag_worker_partitioning): Remove.
	(macc_experimental_workers): Remove unused option.
	libgomp/
	* plugin/plugin-gcn.c (gcn_exec): Change default number of workers to
	16.
	* testsuite/libgomp.oacc-c-c++-common/acc_prof-kernels-1.c
	[acc_device_radeon]: Update.
	* testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c
	[ACC_DEVICE_TYPE_radeon]: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/parallel-dims.c
	[acc_device_radeon]: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/routine-wv-2.c
	[ACC_DEVICE_TYPE_radeon]: Likewise.
	* testsuite/libgomp.oacc-fortran/optional-reduction.f90: XFAIL for
	'openacc_radeon_accel_selected' and '-O0'.
	* testsuite/libgomp.oacc-fortran/reduction-7.f90: Likewise.

Co-Authored-By: Kwok Cheung Yeung <kcy@codesourcery.com>
Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com>
2021-08-09 15:08:44 +02:00
GCC Administrator 8ebf4fb54a Daily bump. 2021-08-06 00:16:29 +00:00
Chung-Lin Tang 0bac793ed6 openmp: Implement omp_get_device_num routine
This patch implements the omp_get_device_num library routine, specified in
OpenMP 5.0.

GOMP_DEVICE_NUM_VAR is a macro symbol which defines name of a "device number"
variable, is defined on the device-side libgomp, has it's address returned to
host-side libgomp during device initialization, and the host libgomp then
sets its value to the designated device number.

libgomp/ChangeLog:

	* icv-device.c (omp_get_device_num): New API function, host side.
	* fortran.c (omp_get_device_num_): New interface function.
	* libgomp-plugin.h (GOMP_DEVICE_NUM_VAR): Define macro symbol.
	* libgomp.map (OMP_5.0.2): New version space with omp_get_device_num,
	omp_get_device_num_.
	* libgomp.texi (omp_get_device_num): Add documentation for new API
	function.
	* omp.h.in (omp_get_device_num): Add declaration.
	* omp_lib.f90.in (omp_get_device_num): Likewise.
	* omp_lib.h.in (omp_get_device_num): Likewise.
	* target.c (gomp_load_image_to_device): If additional entry for device
	number exists at end of returned entries from 'load_image_func' hook,
	copy the assigned device number over to the device variable.

	* config/gcn/icv-device.c (GOMP_DEVICE_NUM_VAR): Define static global.
	(omp_get_device_num): New API function, device side.
	* plugin/plugin-gcn.c ("symcat.h"): Add include.
	(GOMP_OFFLOAD_load_image): Add addresses of device GOMP_DEVICE_NUM_VAR
	at end of returned 'target_table' entries.

	* config/nvptx/icv-device.c (GOMP_DEVICE_NUM_VAR): Define static global.
	(omp_get_device_num): New API function, device side.
	* plugin/plugin-nvptx.c ("symcat.h"): Add include.
	(GOMP_OFFLOAD_load_image): Add addresses of device GOMP_DEVICE_NUM_VAR
	at end of returned 'target_table' entries.

	* testsuite/lib/libgomp.exp
	(check_effective_target_offload_target_intelmic): New function for
	testing for intelmic offloading.
	* testsuite/libgomp.c-c++-common/target-45.c: New test.
	* testsuite/libgomp.fortran/target10.f90: New test.
2021-08-05 23:29:03 +08:00
Martin Liska 872c1a56e3 ChangeLog: add problematic commit 2e96b5f14e.
gcc/ChangeLog:

	* ChangeLog: Add manually.

libgomp/ChangeLog:

	* ChangeLog: Add manually.

gcc/testsuite/ChangeLog:

	* ChangeLog: Add manually.
2021-08-03 09:57:21 +02:00
GCC Administrator 4d17ca1bc7 Daily bump. 2021-08-03 07:49:16 +00:00
Thomas Schwinge 28665ddc7e [libgomp] Restore offloading 'libgomp/fortran.c'
GCN:

    ld: error: undefined symbol: gomp_ialias_omp_display_env
    >>> referenced by fortran.c:744 ([...]/source-gcc/libgomp/fortran.c:744)
    >>>               fortran.o:(omp_display_env_) in archive [...]/build-gcc-offload-amdgcn-amdhsa/amdgcn-amdhsa/libgomp/.libs/libgomp.a
    >>> referenced by fortran.c:744 ([...]/source-gcc/libgomp/fortran.c:744)
    >>>               fortran.o:(omp_display_env_) in archive [...]/build-gcc-offload-amdgcn-amdhsa/amdgcn-amdhsa/libgomp/.libs/libgomp.a
    >>> referenced by fortran.c:750 ([...]/source-gcc/libgomp/fortran.c:750)
    >>>               fortran.o:(omp_display_env_8_) in archive [...]/build-gcc-offload-amdgcn-amdhsa/amdgcn-amdhsa/libgomp/.libs/libgomp.a
    >>> referenced by fortran.c:750 ([...]/source-gcc/libgomp/fortran.c:750)
    >>>               fortran.o:(omp_display_env_8_) in archive [...]/build-gcc-offload-amdgcn-amdhsa/amdgcn-amdhsa/libgomp/.libs/libgomp.a
    collect2: error: ld returned 1 exit status
    mkoffload: fatal error: build-gcc/gcc/x86_64-pc-linux-gnu-accel-amdgcn-amdhsa-gcc returned 1 exit status

nvptx:

    unresolved symbol omp_display_env
    collect2: error: ld returned 1 exit status
    mkoffload: fatal error: [...]/build-gcc/./gcc/x86_64-pc-linux-gnu-accel-nvptx-none-gcc returned 1 exit status

Fix-up for commit 7123ae2455
"Implement OpenMP 5.1 section 3.15: omp_display_env".

	libgomp/
	* fortran.c (omp_display_env_, omp_display_env_8_): Only
	'#ifndef LIBGOMP_OFFLOADED_ONLY'.

Co-Authored-By: Ulrich Drepper <drepper@redhat.com>
2021-07-30 12:02:15 +02:00
Thomas Schwinge 0829ab79d3 [OpenACC] Extract 'pass_oacc_loop_designation' out of 'pass_oacc_device_lower'
This really is a separate step -- and another pass to be added between the two,
later on.

	gcc/
	* omp-offload.c (oacc_loop_xform_head_tail, oacc_loop_process):
	'update_stmt' after modification.
	(pass_oacc_loop_designation): New function, extracted out of...
	(pass_oacc_device_lower): ... this.
	(pass_data_oacc_loop_designation, pass_oacc_loop_designation)
	(make_pass_oacc_loop_designation): New
	* passes.def: Add it.
	* tree-parloops.c (create_parallel_loop): Adjust.
	* tree-pass.h (make_pass_oacc_loop_designation): New.
	gcc/testsuite/
	* c-c++-common/goacc/classify-kernels-unparallelized.c:
	's%oaccdevlow%oaccloops%g'.
	* c-c++-common/goacc/classify-kernels.c: Likewise.
	* c-c++-common/goacc/classify-parallel.c: Likewise.
	* c-c++-common/goacc/classify-routine-nohost.c: Likewise.
	* c-c++-common/goacc/classify-routine.c: Likewise.
	* c-c++-common/goacc/classify-serial.c: Likewise.
	* c-c++-common/goacc/routine-nohost-1.c: Likewise.
	* g++.dg/goacc/template.C: Likewise.
	* gcc.dg/goacc/loop-processing-1.c: Likewise.
	* gfortran.dg/goacc/classify-kernels-unparallelized.f95: Likewise.
	* gfortran.dg/goacc/classify-kernels.f95: Likewise.
	* gfortran.dg/goacc/classify-parallel.f95: Likewise.
	* gfortran.dg/goacc/classify-routine-nohost.f95: Likewise.
	* gfortran.dg/goacc/classify-routine.f95: Likewise.
	* gfortran.dg/goacc/classify-serial.f95: Likewise.
	* gfortran.dg/goacc/routine-multiple-directives-1.f90: Likewise.
	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/pr85486-2.c:
	's%oaccdevlow%oaccloops%g'.
	* testsuite/libgomp.oacc-c-c++-common/pr85486-3.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/pr85486.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/vector-length-128-1.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/vector-length-128-2.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/vector-length-128-3.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/vector-length-128-4.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/vector-length-128-5.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/vector-length-128-6.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/vector-length-128-7.c:
	Likewise.
	* testsuite/libgomp.oacc-fortran/routine-nohost-1.f90: Likewise.

Co-Authored-By: Julian Brown <julian@codesourcery.com>
Co-Authored-By: Kwok Cheung Yeung <kcy@codesourcery.com>
2021-07-29 09:19:44 +02:00
Aldy Hernandez 2e96b5f14e Backwards jump threader rewrite with ranger.
This is a rewrite of the backwards threader with a ranger based solver.

The code is divided into two parts: the path solver in
gimple-range-path.*, and the path discovery bits in
tree-ssa-threadbackward.c.

The legacy code is still available with --param=threader-mode=legacy,
but will be removed shortly after.

gcc/ChangeLog:

	* Makefile.in (tree-ssa-loop-im.o-warn): New.
	* flag-types.h (enum threader_mode): New.
	* params.opt: Add entry for --param=threader-mode.
	* tree-ssa-threadbackward.c (THREADER_ITERATIVE_MODE): New.
	(class back_threader): New.
	(back_threader::back_threader): New.
	(back_threader::~back_threader): New.
	(back_threader::maybe_register_path): New.
	(back_threader::find_taken_edge): New.
	(back_threader::find_taken_edge_switch): New.
	(back_threader::find_taken_edge_cond): New.
	(back_threader::resolve_def): New.
	(back_threader::resolve_phi): New.
	(back_threader::find_paths_to_names): New.
	(back_threader::find_paths): New.
	(dump_path): New.
	(debug): New.
	(thread_jumps::find_jump_threads_backwards): Call ranger threader.
	(thread_jumps::find_jump_threads_backwards_with_ranger): New.
	(pass_thread_jumps::execute): Abstract out code...
	(try_thread_blocks): ...here.
	* tree-ssa-threadedge.c (jump_threader::thread_outgoing_edges):
	Abstract out threading candidate code to...
	(single_succ_to_potentially_threadable_block): ...here.
	* tree-ssa-threadedge.h (single_succ_to_potentially_threadable_block):
	New.
	* tree-ssa-threadupdate.c (register_jump_thread): Return boolean.
	* tree-ssa-threadupdate.h (class jump_thread_path_registry):
	Return bool from register_jump_thread.

libgomp/ChangeLog:

	* testsuite/libgomp.graphite/force-parallel-4.c: Adjust for
	threader.
	* testsuite/libgomp.graphite/force-parallel-8.c: Same.

gcc/testsuite/ChangeLog:

	* g++.dg/debug/dwarf2/deallocator.C: Adjust for threader.
	* gcc.c-torture/compile/pr83510.c: Same.
	* dg.dg/analyzer/pr94851-2.c: Same.
	* gcc.dg/loop-unswitch-2.c: Same.
	* gcc.dg/old-style-asm-1.c: Same.
	* gcc.dg/pr68317.c: Same.
	* gcc.dg/pr97567-2.c: Same.
	* gcc.dg/predict-9.c: Same.
	* gcc.dg/shrink-wrap-loop.c: Same.
	* gcc.dg/sibcall-1.c: Same.
	* gcc.dg/tree-ssa/builtin-sprintf-3.c: Same.
	* gcc.dg/tree-ssa/pr21001.c: Same.
	* gcc.dg/tree-ssa/pr21294.c: Same.
	* gcc.dg/tree-ssa/pr21417.c: Same.
	* gcc.dg/tree-ssa/pr21458-2.c: Same.
	* gcc.dg/tree-ssa/pr21563.c: Same.
	* gcc.dg/tree-ssa/pr49039.c: Same.
	* gcc.dg/tree-ssa/pr61839_1.c: Same.
	* gcc.dg/tree-ssa/pr61839_3.c: Same.
	* gcc.dg/tree-ssa/pr77445-2.c: Same.
	* gcc.dg/tree-ssa/split-path-4.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-11.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-12.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-14.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-18.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-6.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Same.
	* gcc.dg/tree-ssa/ssa-fre-48.c: Same.
	* gcc.dg/tree-ssa/ssa-thread-11.c: Same.
	* gcc.dg/tree-ssa/ssa-thread-12.c: Same.
	* gcc.dg/tree-ssa/ssa-thread-14.c: Same.
	* gcc.dg/tree-ssa/vrp02.c: Same.
	* gcc.dg/tree-ssa/vrp03.c: Same.
	* gcc.dg/tree-ssa/vrp05.c: Same.
	* gcc.dg/tree-ssa/vrp06.c: Same.
	* gcc.dg/tree-ssa/vrp07.c: Same.
	* gcc.dg/tree-ssa/vrp09.c: Same.
	* gcc.dg/tree-ssa/vrp19.c: Same.
	* gcc.dg/tree-ssa/vrp20.c: Same.
	* gcc.dg/tree-ssa/vrp33.c: Same.
	* gcc.dg/uninit-pred-9_b.c: Same.
	* gcc.dg/uninit-pr61112.c: Same.
	* gcc.dg/vect/bb-slp-16.c: Same.
	* gcc.target/i386/avx2-vect-aggressive.c: Same.
	* gcc.dg/tree-ssa/ranger-threader-1.c: New test.
	* gcc.dg/tree-ssa/ranger-threader-2.c: New test.
	* gcc.dg/tree-ssa/ranger-threader-3.c: New test.
	* gcc.dg/tree-ssa/ranger-threader-4.c: New test.
	* gcc.dg/tree-ssa/ranger-threader-5.c: New test.
2021-07-29 08:24:50 +02:00
GCC Administrator af3f12e6e8 Daily bump. 2021-07-28 00:16:25 +00:00
Ulrich Drepper 7123ae2455 Implement OpenMP 5.1 section 3.15: omp_display_env
This is a new interface which is easily implemented using the
already existing code for the handling of the OMP_DISPLAY_ENV
environment variable.

libgomp/
	* env.c (wait_policy, stacksize): New static variables,
	move out of handle_omp_display_env.
	(omp_display_env): New function.  The meat of the old
	handle_omp_display_env function.
	(handle_omp_display_env): Change to not take parameters
	and instead use the global variables.  Only perform
	parsing, defer to omp_display_env for the implementation.
	(initialize_env): Remove local variables wait_policy and
	stacksize.  Don't pass parameters to handle_omp_display_env.
	* fortran.c: Add ialias_redirect for omp_display_env.
	(omp_display_env_, omp_display_env_8_): New functions.
	* libgomp.map (OMP_5.1): New version.  Add omp_display_env,
	omp_display_env_, and omp_display_env_8_.
	* omp.h.in: Declare omp_display_env.
	* omp_lib.f90.in: Likewise.
	* omp_lib.h.in: Likewise.
2021-07-27 21:08:41 +02:00
Thomas Schwinge d88a695158 Don't use libgomp 'cbuf' buffering with OpenACC 'async'
The host data might not be computed yet (by an earlier asynchronous compute
region, for example.

	libgomp/
	* target.c (gomp_coalesce_buf_add): Update comment.
	(gomp_copy_host2dev, gomp_map_vars_internal): Don't expect to see
	'aq && cbuf'.
	(gomp_map_vars_internal): Only 'if (!aq)', do
	'gomp_coalesce_buf_add'.
	* testsuite/libgomp.oacc-c-c++-common/async-data-1-2.c: Remove
	XFAIL.

Co-Authored-By: Julian Brown <julian@codesourcery.com>
2021-07-27 11:16:37 +02:00
Julian Brown 9c41f5b9cd Fix OpenACC "ephemeral" asynchronous host-to-device copies
This patch fixes several places in libgomp/target.c where "ephemeral" data
(on the stack or in temporary heap locations) may be used as the source of
an asynchronous host-to-device copy that may not complete before the host
data disappears.

An existing, but flawed, workaround for this problem in the AMD GCN
libgomp offloading plugin is currently present on mainline, and was
posted for the og9 branch here:

  https://gcc.gnu.org/legacy-ml/gcc-patches/2019-08/msg00901.html

and previous versions of this patch were posted here (for mainline/og9):

  https://gcc.gnu.org/legacy-ml/gcc-patches/2019-11/msg01482.html
  https://gcc.gnu.org/legacy-ml/gcc-patches/2019-09/msg01026.html

libgomp/
	* libgomp.h (gomp_copy_host2dev): Update prototype.
	* oacc-mem.c (memcpy_tofrom_device, update_dev_host): Add new
	argument to gomp_copy_host2dev (false).
	* plugin/plugin-gcn.c (struct copy_data): Remove free_src field.
	(copy_data): Don't free src.
	(queue_push_copy): Remove free_src handling.
	(GOMP_OFFLOAD_dev2dev): Update call to queue_push_copy.
	(GOMP_OFFLOAD_openacc_async_host2dev): Remove source-data
	snapshotting.
	(GOMP_OFFLOAD_openacc_async_dev2host): Update call to
	queue_push_copy.
	* target.c (goacc_device_copy_async): Add SRCADDR_ORIG parameter.
	(gomp_copy_host2dev): Add EPHEMERAL parameter.  Snapshot source
	data when true, and set up deferred freeing of temporary buffer.
	(gomp_copy_dev2host): Update call to goacc_device_copy_async.
	(gomp_map_vars_existing, gomp_map_pointer, gomp_attach_pointer)
	(gomp_detach_pointer, gomp_map_vars_internal, gomp_update): Update
	calls to gomp_copy_host2dev with appropriate ephemeral argument.
	* testsuite/libgomp.oacc-c-c++-common/async-data-1-1.c: Remove
	XFAIL.

Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com>
2021-07-27 11:16:27 +02:00
Thomas Schwinge 88c40c36db Add 'libgomp.oacc-c-c++-common/async-data-1-{1,2}.c'
libgomp/
	* testsuite/libgomp.oacc-c-c++-common/async-data-1-1.c: New file.
	* testsuite/libgomp.oacc-c-c++-common/async-data-1-2.c: Likewise.

Co-Authored-By: Tom de Vries <tom@codesourcery.com>
2021-07-27 11:16:26 +02:00
Thomas Schwinge 29ddaf43f7 [OpenACC] Clarify sequencing of 'async' data copying vs. profiling events in 'libgomp.oacc-c-c++-common/acc_prof-{init,parallel}-1.c'
... as noticed with GCN offloading.

Fix-up for r271346 (commit 5fae049dc2)
"OpenACC Profiling Interface (incomplete)".

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/acc_prof-init-1.c: Clarify
	sequencing of 'async' data copying vs. profiling events.
	* testsuite/libgomp.oacc-c-c++-common/acc_prof-parallel-1.c:
	Likewise.
2021-07-27 11:16:25 +02:00
Thomas Schwinge 599e275d7e Fix OpenACC 'async'/'wait' issues in 'libgomp.oacc-c-c++-common/lib-{94,95}.c', 'libgomp.oacc-fortran/lib-16{,-2}.f90'
Fix-up for r265842 (commit 58168bbf6f)
"[OpenACC 2.5, libgomp] Add *_async versions of runtime library API functions".

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/lib-94.c: Fix OpenACC
	'async'/'wait' issue.
	* testsuite/libgomp.oacc-c-c++-common/lib-95.c: Likewise.
	* testsuite/libgomp.oacc-fortran/lib-16-2.f90: Likewise.
	* testsuite/libgomp.oacc-fortran/lib-16.f90: Likewise.

Co-Authored-By: Julian Brown <julian@codesourcery.com>
2021-07-27 11:16:24 +02:00
GCC Administrator 419c6c68e6 Daily bump. 2021-07-22 00:16:46 +00:00
Thomas Schwinge a61f6afbee OpenACC 'nohost' clause
Do not "compile a version of this procedure for the host".

	gcc/
	* tree-core.h (omp_clause_code): Add 'OMP_CLAUSE_NOHOST'.
	* tree.c (omp_clause_num_ops, omp_clause_code_name, walk_tree_1):
	Handle it.
	* tree-pretty-print.c (dump_omp_clause): Likewise.
	* omp-general.c (oacc_verify_routine_clauses): Likewise.
	* gimplify.c (gimplify_scan_omp_clauses)
	(gimplify_adjust_omp_clauses): Likewise.
	* tree-nested.c (convert_nonlocal_omp_clauses)
	(convert_local_omp_clauses): Likewise.
	* omp-low.c (scan_sharing_clauses): Likewise.
	* omp-offload.c (execute_oacc_device_lower): Update.
	gcc/c-family/
	* c-pragma.h (pragma_omp_clause): Add 'PRAGMA_OACC_CLAUSE_NOHOST'.
	gcc/c/
	* c-parser.c (c_parser_omp_clause_name): Handle 'nohost'.
	(c_parser_oacc_all_clauses): Handle 'PRAGMA_OACC_CLAUSE_NOHOST'.
	(OACC_ROUTINE_CLAUSE_MASK): Add 'PRAGMA_OACC_CLAUSE_NOHOST'.
	* c-typeck.c (c_finish_omp_clauses): Handle 'OMP_CLAUSE_NOHOST'.
	gcc/cp/
	* parser.c (cp_parser_omp_clause_name): Handle 'nohost'.
	(cp_parser_oacc_all_clauses): Handle 'PRAGMA_OACC_CLAUSE_NOHOST'.
	(OACC_ROUTINE_CLAUSE_MASK): Add 'PRAGMA_OACC_CLAUSE_NOHOST'.
	* pt.c (tsubst_omp_clauses): Handle 'OMP_CLAUSE_NOHOST'.
	* semantics.c (finish_omp_clauses): Likewise.
	gcc/fortran/
	* dump-parse-tree.c (show_attr): Update.
	* gfortran.h (symbol_attribute): Add 'oacc_routine_nohost' member.
	(gfc_omp_clauses): Add 'nohost' member.
	* module.c (ab_attribute): Add 'AB_OACC_ROUTINE_NOHOST'.
	(attr_bits, mio_symbol_attribute): Update.
	* openmp.c (omp_mask2): Add 'OMP_CLAUSE_NOHOST'.
	(gfc_match_omp_clauses): Handle 'OMP_CLAUSE_NOHOST'.
	(OACC_ROUTINE_CLAUSES): Add 'OMP_CLAUSE_NOHOST'.
	(gfc_match_oacc_routine): Update.
	* trans-decl.c (add_attributes_to_decl): Update.
	* trans-openmp.c (gfc_trans_omp_clauses): Likewise.
	gcc/testsuite/
	* c-c++-common/goacc/classify-routine-nohost.c: New file.
	* c-c++-common/goacc/classify-routine.c: Update.
	* c-c++-common/goacc/routine-2.c: Likewise.
	* c-c++-common/goacc/routine-nohost-1.c: New file.
	* c-c++-common/goacc/routine-nohost-2.c: Likewise.
	* g++.dg/goacc/template.C: Update.
	* gfortran.dg/goacc/classify-routine-nohost.f95: New file.
	* gfortran.dg/goacc/classify-routine.f95: Update.
	* gfortran.dg/goacc/pure-elemental-procedures-2.f90: Likewise.
	* gfortran.dg/goacc/routine-6.f90: Likewise.
	* gfortran.dg/goacc/routine-intrinsic-2.f: Likewise.
	* gfortran.dg/goacc/routine-module-1.f90: Likewise.
	* gfortran.dg/goacc/routine-module-2.f90: Likewise.
	* gfortran.dg/goacc/routine-module-3.f90: Likewise.
	* gfortran.dg/goacc/routine-module-mod-1.f90: Likewise.
	* gfortran.dg/goacc/routine-multiple-directives-1.f90: Likewise.
	* gfortran.dg/goacc/routine-multiple-directives-2.f90: Likewise.
	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c: New
	file.
	* testsuite/libgomp.oacc-c-c++-common/routine-nohost-2.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/routine-nohost-2_2.c:
	Likewise.
	* testsuite/libgomp.oacc-fortran/routine-nohost-1.f90: Likewise.

Co-Authored-By: Joseph Myers <joseph@codesourcery.com>
Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com>
2021-07-21 23:58:11 +02:00
GCC Administrator 92d4550991 Daily bump. 2021-07-21 00:16:54 +00:00
Thomas Schwinge 8168338684 [gcn] Work-around libgomp 'error: array subscript 0 is outside array bounds of ‘__lds struct gomp_thread * __lds[0]’ [-Werror=array-bounds]' some more [PR101484]
With yesterday's commit 9f2bc5077d "[gcn]
Work-around libgomp 'error: array subscript 0 is outside array bounds of
‘__lds struct gomp_thread * __lds[0]’ [-Werror=array-bounds]' [PR101484]",
I did defuse the "unexpected" '-Werror=array-bounds' diagnostics that we see
as of commit a110855667 "Correct handling of
variable offset minus constant in -Warray-bounds [PR100137]".  However, these
'#pragma GCC diagnostic [...]' directives cause some code generation changes
(that seems unexpected, problematic!), which results in a lot (ten thousands)
of 'GCN team arena exhausted' run-time diagnostics, also leading to a few
FAILs:

    PASS: libgomp.c/../libgomp.c-c++-common/for-11.c (test for excess errors)
    [-PASS:-]{+FAIL:+} libgomp.c/../libgomp.c-c++-common/for-11.c execution test

    PASS: libgomp.c/../libgomp.c-c++-common/for-12.c (test for excess errors)
    [-PASS:-]{+FAIL:+} libgomp.c/../libgomp.c-c++-common/for-12.c execution test

    PASS: libgomp.c/../libgomp.c-c++-common/for-3.c (test for excess errors)
    [-PASS:-]{+FAIL:+} libgomp.c/../libgomp.c-c++-common/for-3.c execution test

    PASS: libgomp.c/../libgomp.c-c++-common/for-5.c (test for excess errors)
    [-PASS:-]{+FAIL:+} libgomp.c/../libgomp.c-c++-common/for-5.c execution test

    PASS: libgomp.c/../libgomp.c-c++-common/for-6.c (test for excess errors)
    [-PASS:-]{+FAIL:+} libgomp.c/../libgomp.c-c++-common/for-6.c execution test

    PASS: libgomp.c/../libgomp.c-c++-common/for-9.c (test for excess errors)
    [-PASS:-]{+FAIL:+} libgomp.c/../libgomp.c-c++-common/for-9.c execution test

Same for 'libgomp.c++'.

It remains to be analyzed how '#pragma GCC diagnostic [...]' directives can
cause code generation changes; for now I'm working around the "unexpected"
'-Werror=array-bounds' diagnostics differently.

Overall, still awaiting a different solution, of course.

	libgomp/
	PR target/101484
	* configure.tgt [amdgcn*-*-*] (XCFLAGS): Add
	'-Wno-error=array-bounds'.
	* config/gcn/team.c: Remove '-Werror=array-bounds' work-around.
	* libgomp.h [__AMDGCN__]: Likewise.
2021-07-20 09:14:28 +02:00
GCC Administrator 21ea2f9320 Daily bump. 2021-07-20 00:16:38 +00:00
Thomas Schwinge 9f2bc5077d [gcn] Work-around libgomp 'error: array subscript 0 is outside array bounds of ‘__lds struct gomp_thread * __lds[0]’ [-Werror=array-bounds]' [PR101484]
... seen as of commit a110855667 "Correct
handling of variable offset minus constant in -Warray-bounds [PR100137]".

Awaiting a different solution, of course.

	libgomp/
	PR target/101484
	* config/gcn/team.c: Apply '-Werror=array-bounds' work-around.
	* libgomp.h [__AMDGCN__]: Likewise.
2021-07-19 10:26:12 +02:00
GCC Administrator 0e7754560f Daily bump. 2021-07-14 00:16:44 +00:00
Jakub Jelinek 42f10ba5b5 libgomp: Don't include limits.h instead of hidden visibility block
sem.h is included in between # pragma GCC visibility push(hidden)
and # pragma GCC visibility pop and includes limits.h there, which
since the introduction of sysconf declaration in recent glibcs
in there causes trouble.  libgomp assumes it is compiled by gcc,
so we don't really need to include limits.h there and can use
-__INT_MAX__ - 1 instead (which clang and icc support too for years).

2021-07-13  Jakub Jelinek  <jakub@redhat.com>
	    Florian Weimer  <fweimer@redhat.com>

	* config/linux/sem.h: Don't include limits.h.
	(SEM_WAIT): Define to -__INT_MAX__ - 1 instead of INT_MIN.
	* config/linux/affinity.c: Include limits.h.
2021-07-13 09:50:49 +02:00
GCC Administrator bea7c16a46 Daily bump. 2021-07-02 00:16:47 +00:00
Jakub Jelinek 91c771ec8a openmp - Fix up && and || reductions [PR94366]
As the testcase shows, the special treatment of && and || reduction combiners
where we expand them as omp_out = (omp_out != 0) && (omp_in != 0) (or with ||)
is not needed just for &&/|| on floating point or complex types, but for all
&&/|| reductions - when expanded as omp_out = omp_out && omp_in (not in C but
GENERIC) it is actually gimplified into NOP_EXPRs to bool from both operands,
which turns non-zero values multiple of 2 into 0 rather than 1.

This patch just treats all &&/|| the same and furthermore uses bool type
instead of int for the comparisons.

2021-07-01  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/94366
gcc/
	* omp-low.c (lower_rec_input_clauses): Rename is_fp_and_or to
	is_truth_op, set it for TRUTH_*IF_EXPR regardless of new_var's type,
	use boolean_type_node instead of integer_type_node as NE_EXPR type.
	(lower_reduction_clauses): Likewise.
libgomp/
	* testsuite/libgomp.c-c++-common/pr94366.c: New test.
2021-07-01 08:55:49 +02:00
GCC Administrator 6bc18203dd Daily bump. 2021-06-30 00:16:52 +00:00
Tobias Burnus 33c4e46624 Add 'default' to -foffload=; document that flag [PR67300]
As -foffload={options,targets,targets=options} is very convoluted,
it has been split into -foffload=targets (supporting the old syntax
for backward compatibilty) and -foffload-options={options,target=options}.

Only the new syntax is documented.

Additionally, -foffload=default is supported, which can reset the
devices after -foffload=disable / -foffload=targets to the default,
if needed.

gcc/ChangeLog:

	PR other/67300
	* common.opt (-foffload=): Update description.
	(-foffload-options=): New.
	* doc/invoke.texi (C Language Options): Document
	-foffload and -foffload-options.
	* gcc.c (check_offload_target_name): New, split off from
	handle_foffload_option.
	(check_foffload_target_names): New.
	(handle_foffload_option): Handle -foffload=default.
	(driver_handle_option): Update for -foffload-options.
	* lto-opts.c (lto_write_options): Use -foffload-options
	instead of -foffload.
	* lto-wrapper.c (merge_and_complain, append_offload_options):
	Likewise.
	* opts.c (common_handle_option): Likewise.

libgomp/ChangeLog:

	PR other/67300
	* testsuite/libgomp.c-c++-common/reduction-16.c: Replace
	-foffload=nvptx-none= by -foffload-options=nvptx-none= to
	avoid disabling other offload targets.
	* testsuite/libgomp.c-c++-common/reduction-5.c: Likewise.
	* testsuite/libgomp.c-c++-common/reduction-6.c: Likewise.
	* testsuite/libgomp.c/target-44.c: Likewise.
2021-06-29 16:00:04 +02:00
Tobias Burnus 489c5dcf7b libgomp.fortran/defaultmap-8.f90: Fix non-shared memory handling
Disable some more parts of the test as firstprivate does not work yet
due to PR fortran/90742.

libgomp/
	* testsuite/libgomp.fortran/defaultmap-8.f90 (bar): Determine whether
	target has shared memory and disable some scalar pointer/allocatable
	checks if not as firstprivate does not work.
2021-06-29 15:50:23 +02:00
GCC Administrator 90708f87b8 Daily bump. 2021-06-26 00:16:39 +00:00
Chung-Lin Tang e067201737 testsuite/101114: Adjust libgomp.c-c++-common/struct-elem-5.c testcase
The dg-shouldfail testcase libgomp.c-c++-common/struct-elem-5.c does not
properly fail for non-shared address space offloading. Adjust testcase
to limit testing only for "target offload_device_nonshared_as".

libgomp/ChangeLog:

	PR testsuite/101114
	* testsuite/libgomp.c-c++-common/struct-elem-5.c:
	Add "target offload_device_nonshared_as" condition for enabling test.
2021-06-26 00:46:11 +08:00
GCC Administrator 9aa8327e86 Daily bump. 2021-06-25 00:16:53 +00:00
Jakub Jelinek 7619d33471 openmp: in_reduction clause support on target construct
This patch adds support for in_reduction clause on target construct, though
for now only for synchronous targets (without nowait clause).
The encountering thread in that case runs the target task and blocks until
the target region ends, so it is implemented by remapping it before entering
the target, initializing the private copy if not yet initialized for the
current thread and then using the remapped addresses for the mapping
addresses.
For nowait combined with in_reduction the patch contains a hack where the
nowait clause is ignored.  To implement it correctly, I think we would need
to create a new private variable for the in_reduction and initialize it before
doing the async target and adjust the map addresses to that private variable
and then pass a function pointer to the library routine with code where the callback
would remap the address to the current threads private variable and use in_reduction
combiner to combine the private variable we've created into the thread's copy.
The library would then need to make sure that the routine is called in some thread
participating in the parallel (and not in an unshackeled thread).

2021-06-24  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* tree.h (OMP_CLAUSE_MAP_IN_REDUCTION): Document meaning for OpenMP.
	* gimplify.c (gimplify_scan_omp_clauses): For OpenMP map clauses
	with OMP_CLAUSE_MAP_IN_REDUCTION flag partially defer gimplification
	of non-decl OMP_CLAUSE_DECL.  For OMP_CLAUSE_IN_REDUCTION on
	OMP_TARGET user outer_ctx instead of ctx for placeholders and
	initializer/combiner gimplification.
	* omp-low.c (scan_sharing_clauses): Handle OMP_CLAUSE_MAP_IN_REDUCTION
	on target constructs.
	(lower_rec_input_clauses): Likewise.
	(lower_omp_target): Likewise.
	* omp-expand.c (expand_omp_target): Temporarily ignore nowait clause
	on target if in_reduction is present.
gcc/c-family/
	* c-common.h (enum c_omp_region_type): Add C_ORT_TARGET and
	C_ORT_OMP_TARGET.
	* c-omp.c (c_omp_split_clauses): For OMP_CLAUSE_IN_REDUCTION on
	combined target constructs also add map (always, tofrom:) clause.
gcc/c/
	* c-parser.c (omp_split_clauses): Pass C_ORT_OMP_TARGET instead of
	C_ORT_OMP for clauses on target construct.
	(OMP_TARGET_CLAUSE_MASK): Add in_reduction clause.
	(c_parser_omp_target): For non-combined target add
	map (always, tofrom:) clauses for OMP_CLAUSE_IN_REDUCTION.  Pass
	C_ORT_OMP_TARGET to c_finish_omp_clauses.
	* c-typeck.c (handle_omp_array_sections): Adjust ort handling
	for addition of C_ORT_OMP_TARGET and simplify, mapping clauses are
	never present on C_ORT_*DECLARE_SIMD.
	(c_finish_omp_clauses): Likewise.  Handle OMP_CLAUSE_IN_REDUCTION
	on C_ORT_OMP_TARGET, set OMP_CLAUSE_MAP_IN_REDUCTION on
	corresponding map clauses.
gcc/cp/
	* parser.c (cp_omp_split_clauses): Pass C_ORT_OMP_TARGET instead of
	C_ORT_OMP for clauses on target construct.
	(OMP_TARGET_CLAUSE_MASK): Add in_reduction clause.
	(cp_parser_omp_target): For non-combined target add
	map (always, tofrom:) clauses for OMP_CLAUSE_IN_REDUCTION.  Pass
	C_ORT_OMP_TARGET to finish_omp_clauses.
	* semantics.c (handle_omp_array_sections_1): Adjust ort handling
	for addition of C_ORT_OMP_TARGET and simplify, mapping clauses are
	never present on C_ORT_*DECLARE_SIMD.
	(handle_omp_array_sections): Likewise.
	(finish_omp_clauses): Likewise.  Handle OMP_CLAUSE_IN_REDUCTION
	on C_ORT_OMP_TARGET, set OMP_CLAUSE_MAP_IN_REDUCTION on
	corresponding map clauses.
	* pt.c (tsubst_expr): Pass C_ORT_OMP_TARGET instead of C_ORT_OMP for
	clauses on target construct.
gcc/testsuite/
	* c-c++-common/gomp/target-in-reduction-1.c: New test.
	* c-c++-common/gomp/clauses-1.c: Add in_reduction clauses on
	target or combined target constructs.
libgomp/
	* testsuite/libgomp.c-c++-common/target-in-reduction-1.c: New test.
	* testsuite/libgomp.c-c++-common/target-in-reduction-2.c: New test.
	* testsuite/libgomp.c++/target-in-reduction-1.C: New test.
	* testsuite/libgomp.c++/target-in-reduction-2.C: New test.
2021-06-24 11:35:08 +02:00
GCC Administrator fcf617f0d2 Daily bump. 2021-06-24 00:16:30 +00:00
Jakub Jelinek 679506c383 openmp: Fix up *_reduction clause handling with UDRs on PARM_DECLs [PR101167]
The following testcase FAILs, because the UDR combiner is invoked incorrectly.
lower_omp_rec_clauses expects that when it sets
DECL_VALUE_EXPR/DECL_HAS_VALUE_EXPR_P
for both the placeholder and the var that everything will be properly
regimplified, but as the variable in question is a PARM_DECL rather than
VAR_DECL, lower_omp_regimplify_p doesn't say that it should be regimplified
and so it is not.

2021-06-23  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/101167
	* omp-low.c (lower_omp_regimplify_p): Regimplify also PARM_DECLs
	and RESULT_DECLs that have DECL_HAS_VALUE_EXPR_P set.

	* testsuite/libgomp.c-c++-common/task-reduction-15.c: New test.
2021-06-23 10:03:28 +02:00