gcc/libgomp
Jakub Jelinek 8122fbff77 openmp: Implement OpenMP 5.1 atomics, so far for C only
This patch implements OpenMP 5.1 atomics (with clarifications from upcoming 5.2).
The most important changes are that it is now possible to write (for C/C++,
for Fortran it was possible before already) min/max atomics and more importantly
compare and exchange in various forms.
Also, acq_rel is now allowed on read/write and acq_rel/acquire are allowed on
update, and there are new compare, weak and fail clauses.

2021-09-10  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* tree-core.h (enum omp_memory_order): Add OMP_MEMORY_ORDER_MASK,
	OMP_FAIL_MEMORY_ORDER_UNSPECIFIED, OMP_FAIL_MEMORY_ORDER_RELAXED,
	OMP_FAIL_MEMORY_ORDER_ACQUIRE, OMP_FAIL_MEMORY_ORDER_RELEASE,
	OMP_FAIL_MEMORY_ORDER_ACQ_REL, OMP_FAIL_MEMORY_ORDER_SEQ_CST and
	OMP_FAIL_MEMORY_ORDER_MASK enumerators.
	(OMP_FAIL_MEMORY_ORDER_SHIFT): Define.
	* gimple-pretty-print.c (dump_gimple_omp_atomic_load,
	dump_gimple_omp_atomic_store): Print [weak] for weak atomic
	load/store.
	* gimple.h (enum gf_mask): Change GF_OMP_ATOMIC_MEMORY_ORDER
	to 6-bit mask, adjust GF_OMP_ATOMIC_NEED_VALUE value and add
	GF_OMP_ATOMIC_WEAK.
	(gimple_omp_atomic_weak_p, gimple_omp_atomic_set_weak): New inline
	functions.
	* tree.h (OMP_ATOMIC_WEAK): Define.
	* tree-pretty-print.c (dump_omp_atomic_memory_order): Adjust for
	fail memory order being encoded in the same enum and also print
	fail clause if present.
	(dump_generic_node): Print weak clause if OMP_ATOMIC_WEAK.
	* gimplify.c (goa_stabilize_expr): Add target_expr and rhs arguments,
	handle pre_p == NULL case as a test mode that only returns value
	but doesn't change gimplify nor change anything otherwise, adjust
	recursive calls, add MODIFY_EXPR, ADDR_EXPR, COND_EXPR, TARGET_EXPR
	and CALL_EXPR handling, adjust COMPOUND_EXPR handling for
	__builtin_clear_padding calls, for !rhs gimplify as lvalue rather
	than rvalue.
	(gimplify_omp_atomic): Adjust goa_stabilize_expr caller.  Handle
	COND_EXPR rhs.  Set weak flag on gimple load/store for
	OMP_ATOMIC_WEAK.
	* omp-expand.c (omp_memory_order_to_fail_memmodel): New function.
	(omp_memory_order_to_memmodel): Adjust for fail clause encoded
	in the same enum.
	(expand_omp_atomic_cas): New function.
	(expand_omp_atomic_pipeline): Use omp_memory_order_to_fail_memmodel
	function.
	(expand_omp_atomic): Attempt to optimize atomic compare and exchange
	using expand_omp_atomic_cas.
gcc/c-family/
	* c-common.h (c_finish_omp_atomic): Add r and weak arguments.
	* c-omp.c: Include gimple-fold.h.
	(c_finish_omp_atomic): Add r and weak arguments.  Add support for
	OpenMP 5.1 atomics.
gcc/c/
	* c-parser.c (c_parser_conditional_expression): If omp_atomic_lhs and
	cond.value is >, < or == with omp_atomic_lhs as one of the operands,
	don't call build_conditional_expr, instead build a COND_EXPR directly.
	(c_parser_binary_expression): Avoid calling parser_build_binary_op
	if omp_atomic_lhs even in more cases for >, < or ==.
	(c_parser_omp_atomic): Update function comment for OpenMP 5.1 atomics,
	parse OpenMP 5.1 atomics and fail, compare and weak clauses, allow
	acq_rel on atomic read/write and acq_rel/acquire clauses on update.
	* c-typeck.c (build_binary_op): For flag_openmp only handle
	MIN_EXPR/MAX_EXPR.
gcc/cp/
	* parser.c (cp_parser_omp_atomic): Allow acq_rel on atomic read/write
	and acq_rel/acquire clauses on update.
	* semantics.c (finish_omp_atomic): Adjust c_finish_omp_atomic caller.
gcc/testsuite/
	* c-c++-common/gomp/atomic-17.c (foo): Add tests for atomic read,
	write or update with acq_rel clause and atomic update with acquire clause.
	* c-c++-common/gomp/atomic-18.c (foo): Adjust expected diagnostics
	wording, remove tests moved to atomic-17.c.
	* c-c++-common/gomp/atomic-21.c: Expect only 2 omp atomic release and
	2 omp atomic acq_rel directives instead of 4 omp atomic release.
	* c-c++-common/gomp/atomic-25.c: New test.
	* c-c++-common/gomp/atomic-26.c: New test.
	* c-c++-common/gomp/atomic-27.c: New test.
	* c-c++-common/gomp/atomic-28.c: New test.
	* c-c++-common/gomp/atomic-29.c: New test.
	* c-c++-common/gomp/atomic-30.c: New test.
	* c-c++-common/goacc-gomp/atomic.c: Expect 1 omp atomic release and
	1 omp atomic_acq_rel instead of 2 omp atomic release directives.
	* gcc.dg/gomp/atomic-5.c: Adjust expected error diagnostic wording.
	* g++.dg/gomp/atomic-18.C:Expect 4 omp atomic release and
	1 omp atomic_acq_rel instead of 5 omp atomic release directives.
libgomp/
	* testsuite/libgomp.c-c++-common/atomic-19.c: New test.
	* testsuite/libgomp.c-c++-common/atomic-20.c: New test.
	* testsuite/libgomp.c-c++-common/atomic-21.c: New test.
2021-09-10 20:41:33 +02:00
..
config Make the OpenMP 'error' directive work for nvptx offloading 2021-08-22 11:08:26 +02:00
plugin amdgcn: Enable OpenACC worker partitioning for AMD GCN 2021-08-09 15:08:44 +02:00
testsuite openmp: Implement OpenMP 5.1 atomics, so far for C only 2021-09-10 20:41:33 +02:00
.gitattributes libgomp: Fixes + cleanup for OpenACC's Fortran module + openacc_lib.h 2020-02-19 09:13:44 +01:00
acc_prof.h Update copyright years. 2021-01-04 10:26:59 +01:00
acinclude.m4 re PR other/79543 (Inappropriate "ld --version" checking) 2019-09-03 14:10:26 +00:00
aclocal.m4 libgomp: Regenerate configure files with automake 1.15.1 2020-10-02 12:08:47 +02:00
affinity-fmt.c Update copyright years. 2021-01-04 10:26:59 +01:00
affinity.c Update copyright years. 2021-01-04 10:26:59 +01:00
alloc.c Update copyright years. 2021-01-04 10:26:59 +01:00
allocator.c Update copyright years. 2021-01-04 10:26:59 +01:00
atomic.c Update copyright years. 2021-01-04 10:26:59 +01:00
barrier.c Update copyright years. 2021-01-04 10:26:59 +01:00
ChangeLog Daily bump. 2021-09-08 00:16:23 +00:00
ChangeLog.graphite
config.h.in offload-defaulted: Config option to silently ignore uninstalled offload compilers 2021-04-28 18:46:47 +02:00
configure offload-defaulted: Config option to silently ignore uninstalled offload compilers 2021-04-28 18:46:47 +02:00
configure.ac offload-defaulted: Config option to silently ignore uninstalled offload compilers 2021-04-28 18:46:47 +02:00
configure.tgt [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] 2021-07-20 09:14:28 +02:00
critical.c Update copyright years. 2021-01-04 10:26:59 +01:00
env.c OpenMP 5.1: Add proc-bind 'primary' support 2021-08-12 15:49:49 +02:00
error.c openmp: Implement the error directive 2021-08-20 11:36:52 +02:00
fortran.c openmp: Implement omp_get_device_num routine 2021-08-05 23:29:03 +08:00
hashtab.h libgomp: Structure element mapping for OpenMP 5.0 2021-06-17 21:34:59 +08:00
icv-device.c openmp: Implement omp_get_device_num routine 2021-08-05 23:29:03 +08:00
icv.c Update copyright years. 2021-01-04 10:26:59 +01:00
iter_ull.c Update copyright years. 2021-01-04 10:26:59 +01:00
iter.c Update copyright years. 2021-01-04 10:26:59 +01:00
libgomp_f.h.in Update copyright years. 2021-01-04 10:26:59 +01:00
libgomp_g.h openmp: Implement the error directive 2021-08-20 11:36:52 +02:00
libgomp-plugin.c Update copyright years. 2021-01-04 10:26:59 +01:00
libgomp-plugin.h openmp: Implement omp_get_device_num routine 2021-08-05 23:29:03 +08:00
libgomp.h Fix OpenACC "ephemeral" asynchronous host-to-device copies 2021-07-27 11:16:27 +02:00
libgomp.map openmp: Implement the error directive 2021-08-20 11:36:52 +02:00
libgomp.spec.in
libgomp.texi libgomp.texi: Extend OpenMP 5.0 Implementation Status 2021-09-07 18:30:25 +02:00
lock.c Update copyright years. 2021-01-04 10:26:59 +01:00
loop_ull.c Update copyright years. 2021-01-04 10:26:59 +01:00
loop.c Update copyright years. 2021-01-04 10:26:59 +01:00
Makefile.am openmp: Implement OpenMP 5.1 scope construct 2021-08-17 09:30:09 +02:00
Makefile.in openmp: Implement OpenMP 5.1 scope construct 2021-08-17 09:30:09 +02:00
oacc-async.c Update copyright years. 2021-01-04 10:26:59 +01:00
oacc-cuda.c Update copyright years. 2021-01-04 10:26:59 +01:00
oacc-host.c Update copyright years. 2021-01-04 10:26:59 +01:00
oacc-init.c Update copyright years. 2021-01-04 10:26:59 +01:00
oacc-int.h Update copyright years. 2021-01-04 10:26:59 +01:00
oacc-mem.c Fix OpenACC "ephemeral" asynchronous host-to-device copies 2021-07-27 11:16:27 +02:00
oacc-parallel.c libgomp: Structure element mapping for OpenMP 5.0 2021-06-17 21:34:59 +08:00
oacc-plugin.c Update copyright years. 2021-01-04 10:26:59 +01:00
oacc-plugin.h Update copyright years. 2021-01-04 10:26:59 +01:00
oacc-profiling.c Update copyright years. 2021-01-04 10:26:59 +01:00
oacc-target.c GCN libgomp port 2019-11-13 12:38:04 +00:00
omp_lib.f90.in Fortran/OpenMP: Add memory routines existing for C/C++ 2021-08-18 11:15:47 +02:00
omp_lib.h.in Fortran/OpenMP: Add memory routines existing for C/C++ 2021-08-18 11:15:47 +02:00
omp.h.in OpenMP 5.1: Add proc-bind 'primary' support 2021-08-12 15:49:49 +02:00
openacc_lib.h Update copyright years. 2021-01-04 10:26:59 +01:00
openacc.f90 Update copyright years. 2021-01-04 10:26:59 +01:00
openacc.h Update copyright years. 2021-01-04 10:26:59 +01:00
ordered.c Update copyright years. 2021-01-04 10:26:59 +01:00
parallel.c Update copyright years. 2021-01-04 10:26:59 +01:00
priority_queue.c openmp: Add support for the OpenMP 5.0 task detach clause 2021-01-16 12:58:13 -08:00
priority_queue.h openmp: Add support for the OpenMP 5.0 task detach clause 2021-01-16 12:58:13 -08:00
scope.c openmp: Implement OpenMP 5.1 scope construct 2021-08-17 09:30:09 +02:00
sections.c Update copyright years. 2021-01-04 10:26:59 +01:00
secure_getenv.h Update copyright years. 2021-01-04 10:26:59 +01:00
single.c Update copyright years. 2021-01-04 10:26:59 +01:00
splay-tree.c Update copyright years. 2021-01-04 10:26:59 +01:00
splay-tree.h Update copyright years. 2021-01-04 10:26:59 +01:00
target.c openmp: Implement omp_get_device_num routine 2021-08-05 23:29:03 +08:00
task.c openmp: Notify team barrier of pending tasks in omp_fulfill_event 2021-05-17 13:15:08 -07:00
taskloop.c openmp: Add support for strict modifier on grainsize/num_tasks clauses 2021-08-23 10:16:24 +02:00
team.c libgomp: Silence false positive -Wmaybe-uninitialized warning [PR99984] 2021-04-09 10:18:47 +02:00
teams.c Update copyright years. 2021-01-04 10:26:59 +01:00
work.c Update copyright years. 2021-01-04 10:26:59 +01:00