Commit graph

2475 commits

Author SHA1 Message Date
GCC Administrator
d776b20148 Daily bump. 2025-04-18 00:16:59 +00:00
Jakub Jelinek
5d05d496b2 libgomp: Don't test ompx::allocator::gnu_pinned_mem on non-linux targets.
The libgomp.c/alloc-pinned*.c test have
/* { dg-skip-if "Pinning not implemented on this host" { ! *-*-linux-gnu* } } */
so they are only run on Linux targets right now.  Duplicating the tests or
reworking them into headers looked like too much work for me right now this
late in stage4, so I've just #ifdefed the uses at least for now.

2025-04-17  Jakub Jelinek  <jakub@redhat.com>

	PR libgomp/119849
	* testsuite/libgomp.c++/allocator-1.C (test_inequality, main): Guard
	ompx::allocator::gnu_pinned_mem uses with #ifdef __gnu_linux__.
	* testsuite/libgomp.c++/allocator-2.C (main): Likewise.
2025-04-17 12:14:15 +02:00
Tobias Burnus
4bff3f0b89 libgomp.texi: For HIP interop, mention cpp defines to set
The HIP header files recognize the used compiler, defaulting to either AMD
or Nvidia/CUDA; thus, the alternative way of explicitly defining a macro is
less prominently documented. With GCC, the user has to define the
preprocessor macro manually. Hence, as a service to the user, mention
__HIP_PLATFORM_AMD__ and __HIP_PLATFORM_NVIDIA__ in the interop documentation,
even though it has only indirectly to do with GCC and its interop support.

Note to commit-log readers, only: For Fortran, the hipfort modules can be
used; when compiling the hipfort package (defaults to use gfortran), it
generates the module (*.mod) files in include/hipfort/{amdgcn,nvidia}/ such
that the choice is made by setting the respective include path.

libgomp/ChangeLog:

	* libgomp.texi (gcn interop, nvptx interop): For HIP with C/C++, add
	a note about setting a preprocessor define.
2025-04-17 10:21:05 +02:00
GCC Administrator
5e3646a3cb Daily bump. 2025-04-17 00:18:03 +00:00
Thomas Schwinge
518efed8cb Remove 'ALWAYS_INLINE' workaround in 'libgomp.c++/target-exceptions-pr118794-1.C'
With commit ca9cffe737
"For nvptx offloading, make sure to emit C++ constructor, destructor aliases [PR97106]",
we're able to remove the 'ALWAYS_INLINE' workaround added in
commit fe283dba77
"GCN, nvptx: Support '-mfake-exceptions', and use it for offloading compilation [PR118794]".

	libgomp/
	* testsuite/libgomp.c++/target-exceptions-pr118794-1.C: Remove
	'ALWAYS_INLINE' workaround.
2025-04-16 18:31:03 +02:00
Thomas Schwinge
0b2a2490be Add 'libgomp.c++/pr106445-1{,-O0}.C' [PR106445]
PR target/106445
	libgomp/
	* testsuite/libgomp.c++/pr106445-1.C: New.
	* testsuite/libgomp.c++/pr106445-1-O0.C: Likewise.
2025-04-16 16:07:07 +02:00
Thomas Schwinge
ca9cffe737 For nvptx offloading, make sure to emit C++ constructor, destructor aliases [PR97106]
PR target/97106
	gcc/
	* config/nvptx/nvptx.cc (nvptx_asm_output_def_from_decls)
	[ACCEL_COMPILER]: Make sure to emit C++ constructor, destructor
	aliases.
	libgomp/
	* testsuite/libgomp.c++/pr96390.C: Un-XFAIL nvptx offloading.
	* testsuite/libgomp.c-c++-common/pr96390.c: Adjust.
2025-04-16 16:03:04 +02:00
GCC Administrator
60130b2d33 Daily bump. 2025-04-16 00:18:18 +00:00
Tobias Burnus
1ff4a22103 libgomp.texi (gcn, nvptx): Mention self_maps alongside USM
libgomp/ChangeLog:

	* libgomp.texi (gcn, nvptx): Mention self_maps clause
	besides unified_shared_memory in the requirements item.
2025-04-15 23:19:50 +02:00
waffl3x
99835bd68e OpenMP: omp.h omp::allocator C++ Allocator interface
The implementation of each allocator is simplified by inheriting from
__detail::__allocator_templ.  At the moment, none of the implementations
diverge in any way, simply passing in the allocator handle to be used when
an allocation is made.  In the future, const_mem will need special handling
added to it to support constant memory space.

libgomp/ChangeLog:

	* omp.h.in: Add omp::allocator::* and ompx::allocator::* allocators.
	(__detail::__allocator_templ<T, omp_allocator_handle_t>):
	New struct template.
	(null_allocator<T>): New struct template.
	(default_mem<T>): Likewise.
	(large_cap_mem<T>): Likewise.
	(const_mem<T>): Likewise.
	(high_bw_mem<T>): Likewise.
	(low_lat_mem<T>): Likewise.
	(cgroup_mem<T>): Likewise.
	(pteam_mem<T>): Likewise.
	(thread_mem<T>): Likewise.
	(ompx::allocator::gnu_pinned_mem<T>): Likewise.
	* testsuite/libgomp.c++/allocator-1.C: New test.
	* testsuite/libgomp.c++/allocator-2.C: New test.

Signed-off-by: waffl3x <waffl3x@baylibre.com>
2025-04-15 14:34:38 -06:00
Tobias Burnus
99cd28c473 Fortran/OpenMP: Support automatic mapping allocatable components (deep mapping)
When mapping an allocatable variable (or derived-type component), explicitly
or implicitly, all its allocated allocatable components will automatically be
mapped. The patch implements the target hooks, added for this feature to
omp-low.cc with commit r15-3895-ge4a58b6f28383c.

Namely, there is a check whether there are allocatable components at all:
gfc_omp_deep_mapping_p. Then gfc_omp_deep_mapping_cnt, counting the number
of required mappings; this is a dynamic value as it depends on array
bounds and whether an allocatable is allocated or not.
And, finally, the actual mapping: gfc_omp_deep_mapping.

Polymorphic variables are partially supported: the mapping of the _data
component is fully supported, but only components of the declared type
are processed for additional allocatables. Additionally, _vptr is not
touched. This means that everything needing _vtab information requires
unified shared memory; in particular, _size data is required when
accessing elements of polymorphic arrays.
However, for scalar arrays, accessing components of the declare type
should work just fine.

As polymorphic variables are not (really) supported and OpenMP 6
explicitly disallows them, there is now a warning (-Wopenmp) when
they are encountered. Unlimited polymorphics are rejected (error).

Additionally, PRIVATE and FIRSTPRIVATE are not quite supported for
allocatable components, polymorphic components and as polymorphic
variable. Thus, those are now rejected as well.

gcc/fortran/ChangeLog:

	* f95-lang.cc (LANG_HOOKS_OMP_DEEP_MAPPING,
	LANG_HOOKS_OMP_DEEP_MAPPING_P, LANG_HOOKS_OMP_DEEP_MAPPING_CNT):
	Define.
	* openmp.cc (gfc_match_omp_clause_reduction): Fix location setting.
	(resolve_omp_clauses): Permit allocatable components, reject
	them and polymorphic variables in PRIVATE/FIRSTPRIVATE.
	* trans-decl.cc (add_clause): Set clause location.
	* trans-openmp.cc (gfc_has_alloc_comps): Add ptr_ok and
	shallow_alloc_only Boolean arguments.
	(gfc_omp_replace_alloc_by_to_mapping): New.
	(gfc_omp_private_outer_ref, gfc_walk_alloc_comps,
	gfc_omp_clause_default_ctor, gfc_omp_clause_copy_ctor,
	gfc_omp_clause_assign_op, gfc_omp_clause_dtor): Update call to it.
	(gfc_omp_finish_clause): Minor cleanups, improve location data,
	handle allocatable components.
	(gfc_omp_deep_mapping_map, gfc_omp_deep_mapping_item,
	gfc_omp_deep_mapping_comps, gfc_omp_gen_simple_loop,
	gfc_omp_get_array_size, gfc_omp_elmental_loop,
	gfc_omp_deep_map_kind_p, gfc_omp_deep_mapping_int_p,
	gfc_omp_deep_mapping_p, gfc_omp_deep_mapping_do,
	gfc_omp_deep_mapping_cnt, gfc_omp_deep_mapping): New.
	(gfc_trans_omp_array_section): Save array descriptor in case
	deep-mapping lang hook will need it.
	(gfc_trans_omp_clauses): Likewise; use better clause location data.
	* trans.h (gfc_omp_deep_mapping_p, gfc_omp_deep_mapping_cnt,
	gfc_omp_deep_mapping): Add function prototypes.

libgomp/ChangeLog:

	* libgomp.texi (5.0 Impl. Status): Mark mapping alloc comps as 'Y'.
	* testsuite/libgomp.fortran/allocatable-comp.f90: New test.
	* testsuite/libgomp.fortran/map-alloc-comp-3.f90: New test.
	* testsuite/libgomp.fortran/map-alloc-comp-4.f90: New test.
	* testsuite/libgomp.fortran/map-alloc-comp-5.f90: New test.
	* testsuite/libgomp.fortran/map-alloc-comp-6.f90: New test.
	* testsuite/libgomp.fortran/map-alloc-comp-7.f90: New test.
	* testsuite/libgomp.fortran/map-alloc-comp-8.f90: New test.
	* testsuite/libgomp.fortran/map-alloc-comp-9.f90: New test.

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/map-alloc-comp-1.f90: Remove dg-error.
	* gfortran.dg/gomp/polymorphic-mapping-2.f90: Update warn wording.
	* gfortran.dg/gomp/polymorphic-mapping.f90: Change expected
	diagnostic; some tests moved to ...
	* gfortran.dg/gomp/polymorphic-mapping-1.f90: ... here as new test.
	* gfortran.dg/gomp/polymorphic-mapping-3.f90: New test.
	* gfortran.dg/gomp/polymorphic-mapping-4.f90: New test.
	* gfortran.dg/gomp/polymorphic-mapping-5.f90: New test.
2025-04-15 16:42:42 +02:00
GCC Administrator
9f3d2506e4 Daily bump. 2025-04-15 00:19:09 +00:00
Thomas Schwinge
fe283dba77 GCN, nvptx: Support '-mfake-exceptions', and use it for offloading compilation [PR118794]
With '-mfake-exceptions' enabled, the user-visible behavior in presence of
exception handling constructs changes such that the compile-time
'sorry, unimplemented: exception handling not supported' is skipped, code
generation proceeds, and instead, exception handling constructs 'abort' at
run time.  (..., or don't, if they're in dead code.)

	PR target/118794
	gcc/
	* config/gcn/gcn.opt (-mfake-exceptions): Support.
	* config/nvptx/nvptx.opt (-mfake-exceptions): Likewise.
	* config/gcn/gcn.md (define_expand "exception_receiver"): Use it.
	* config/nvptx/nvptx.md (define_expand "exception_receiver"):
	Likewise.
	* config/gcn/mkoffload.cc (main): Set it.
	* config/nvptx/mkoffload.cc (main): Likewise.
	* config/nvptx/nvptx.cc (nvptx_assemble_integer)
	<in_section == exception_section>: Special handling for
	'SYMBOL_REF's.
	* except.cc (expand_dw2_landing_pad_for_region): Don't generate
	bogus code for (default)
	'#define EH_RETURN_DATA_REGNO(N) INVALID_REGNUM'.
	libgcc/
	* config/gcn/unwind-gcn.c (_Unwind_Resume): New.
	* config/nvptx/unwind-nvptx.c (_Unwind_Resume): Likewise.
	gcc/testsuite/
	* g++.target/gcn/exceptions-bad_cast-2.C: Set
	'-mno-fake-exceptions'.
	* g++.target/gcn/exceptions-pr118794-1.C: Likewise.
	* g++.target/gcn/exceptions-throw-2.C: Likewise.
	* g++.target/nvptx/exceptions-bad_cast-2.C: Likewise.
	* g++.target/nvptx/exceptions-pr118794-1.C: Likewise.
	* g++.target/nvptx/exceptions-throw-2.C: Likewise.
	* g++.target/gcn/exceptions-bad_cast-2_-mfake-exceptions.C: New.
	* g++.target/gcn/exceptions-pr118794-1_-mfake-exceptions.C:
	Likewise.
	* g++.target/gcn/exceptions-throw-2_-mfake-exceptions.C: Likewise.
	* g++.target/nvptx/exceptions-bad_cast-2_-mfake-exceptions.C:
	Likewise.
	* g++.target/nvptx/exceptions-pr118794-1_-mfake-exceptions.C:
	Likewise.
	* g++.target/nvptx/exceptions-throw-2_-mfake-exceptions.C:
	Likewise.
	libgomp/
	* testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C:
	Set '-foffload-options=-mno-fake-exceptions'.
	* testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-nvptx.C:
	Likewise.
	* testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C:
	Likewise.
	* testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-nvptx.C:
	Likewise.
	* testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-GCN.C:
	Likewise.
	* testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-nvptx.C:
	Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-GCN.C:
	Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-nvptx.C:
	Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-GCN.C:
	Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-nvptx.C:
	Likewise.
	* testsuite/libgomp.c++/target-exceptions-bad_cast-2.C: Adjust.
	* testsuite/libgomp.c++/target-exceptions-pr118794-1.C: Likewise.
	* testsuite/libgomp.c++/target-exceptions-throw-2.C: Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C: Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-throw-2.C: Likewise.
	* testsuite/libgomp.c++/target-exceptions-throw-2-O0.C: New.
2025-04-14 23:56:05 +02:00
Thomas Schwinge
6c0ea84026 Add 'throw', dead code test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloading
gcc/testsuite/
	* g++.target/gcn/exceptions-throw-3.C: New.
	* g++.target/nvptx/exceptions-throw-3.C: Likewise.
	libgomp/
	* testsuite/libgomp.c++/target-exceptions-throw-3.C: New.
	* testsuite/libgomp.oacc-c++/exceptions-throw-3.C: Likewise.
2025-04-14 23:54:54 +02:00
Thomas Schwinge
1daf570498 Add 'throw', caught test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloading
gcc/testsuite/
	* g++.target/gcn/exceptions-throw-2.C: New.
	* g++.target/nvptx/exceptions-throw-2.C: Likewise.
	libgomp/
	* testsuite/libgomp.c++/target-exceptions-throw-2.C: New.
	* testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-GCN.C: Likewise.
	* testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-nvptx.C: Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-throw-2.C: Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-GCN.C: Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-nvptx.C: Likewise.
2025-04-14 23:54:54 +02:00
Thomas Schwinge
1362d9d494 Add 'throw' test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloading
gcc/testsuite/
	* g++.target/gcn/exceptions-throw-1.C: New.
	* g++.target/nvptx/exceptions-throw-1.C: Likewise.
	libgomp/
	* testsuite/libgomp.c++/target-exceptions-throw-1.C: New.
	* testsuite/libgomp.c++/target-exceptions-throw-1-O0.C: Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-throw-1.C: Likewise.
2025-04-14 23:54:53 +02:00
Thomas Schwinge
27f88cc799 Add 'std::bad_cast' exception, dead code test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloading
gcc/testsuite/
	* g++.target/gcn/exceptions-bad_cast-3.C: New.
	* g++.target/nvptx/exceptions-bad_cast-3.C: Likewise.
	libgomp/
	* testsuite/libgomp.c++/target-exceptions-bad_cast-3.C: New.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C: Likewise.
2025-04-14 23:54:53 +02:00
Thomas Schwinge
00cde164ee Add 'std::bad_cast' exception, caught test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloading
gcc/testsuite/
	* g++.target/gcn/exceptions-bad_cast-2.C: New.
	* g++.target/nvptx/exceptions-bad_cast-2.C: Likewise.
	libgomp/
	* testsuite/libgomp.c++/target-exceptions-bad_cast-2.C: New.
	* testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C: Likewise.
	* testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-nvptx.C: Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C: Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-GCN.C: Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-nvptx.C: Likewise.
2025-04-14 23:54:53 +02:00
Thomas Schwinge
0e68f49db9 Add 'std::bad_cast' exception test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloading
gcc/testsuite/
	* g++.target/gcn/exceptions-bad_cast-1.C: New.
	* g++.target/nvptx/exceptions-bad_cast-1.C: Likewise.
	libgomp/
	* testsuite/libgomp.c++/target-exceptions-bad_cast-1.C: New.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C: Likewise.
2025-04-14 23:54:53 +02:00
Thomas Schwinge
aa3e72f943 Add test cases for exception handling constructs in dead code for GCN, nvptx target and OpenMP 'target' offloading [PR118794]
PR target/118794
	gcc/testsuite/
	* g++.target/gcn/exceptions-pr118794-1.C: New.
	* g++.target/nvptx/exceptions-pr118794-1.C: Likewise.
	libgomp/
	* testsuite/libgomp.c++/target-exceptions-pr118794-1.C: New.
	* testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C:
	Likewise.
	* testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-nvptx.C:
	Likewise.
2025-04-14 23:54:48 +02:00
Thomas Schwinge
a304c88b6f Add PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' offloading" test cases [PR119692]
... documenting the status quo.

	PR c++/119692
	gcc/testsuite/
	* g++.target/gcn/pr119692-1-1.C: New.
	* g++.target/nvptx/pr119692-1-1.C: Likewise.
	libgomp/
	* testsuite/libgomp.c++/pr119692-1-1.C: New.
	* testsuite/libgomp.c++/pr119692-1-2.C: Likewise.
	* testsuite/libgomp.c++/pr119692-1-3.C: Likewise.
	* testsuite/libgomp.c++/pr119692-1-4.C: Likewise.
	* testsuite/libgomp.c++/pr119692-1-5.C: Likewise.
	* testsuite/libgomp.oacc-c++/pr119692-1-1.C: Likewise.
	* testsuite/libgomp.oacc-c++/pr119692-1-2.C: Likewise.
	* testsuite/libgomp.oacc-c++/pr119692-1-3.C: Likewise.
2025-04-14 23:54:48 +02:00
GCC Administrator
2fb903387b Daily bump. 2025-04-11 00:17:32 +00:00
Richard Sandiford
733a6a4c11 libgomp: Update SVE tests
The new SVE tests didn't explicitly force SVE to be enabled,
which meant that they wouldn't work on targets that aren't
configured for SVE by default.  The least invasive way of
fixing that is to add a pragma, which works for most tests.
However, for udr-sve.c, the global:

 #pragma omp declare reduction (+:svint32_t: omp_out = svadd_s32_z (svptrue_b32(), omp_in, omp_out)) \
		    initializer (omp_priv = svindex_s32 (0, 0))

does not work with an earlier:

 #pragma GCC target "+sve"

which is interesting, and maybe worthy of a PR if there isn't one
already.  It seems we have to force SVE (and thus an architecture)
on the command line instead.

However, with that fixed, udr-sve.c fails execution.  One problem
seems to be a missing accumulation in for_reduction.  Fixing that
is enough to reach the final inscan_reduction_incl, but that fails
for reasons I haven't investigated yet.  I would need to read up
more to understand what the loop is doing.

It also looks like there might be a missing "+" in simd_reduction:

  #pragma omp simd reduction (+:va, i)
  for (j = 0; j < 16; j++)
    va = svld1_s32 (svptrue_b32 (), a);

  res = svaddv_s32 (svptrue_b32 (), va);

  if (res != 8)
    __builtin_abort ();

since AFAICT the loop is not doing a reduction as things stand.
But perhaps that's deliberate, since it does match the != 8 test.

libgomp/
	* testsuite/libgomp.c-target/aarch64/firstprivate.c: Add +sve pragma.
	* testsuite/libgomp.c-target/aarch64/lastprivate.c: Likewise.
	* testsuite/libgomp.c-target/aarch64/private.c: Likewise.
	* testsuite/libgomp.c-target/aarch64/shared.c: Likewise.
	* testsuite/libgomp.c-target/aarch64/simd-aligned.c: Likewise.
	* testsuite/libgomp.c-target/aarch64/simd-nontemporal.c: Likewise.
	* testsuite/libgomp.c-target/aarch64/threadprivate.c: Likewise.
	* testsuite/libgomp.c-target/aarch64/udr-sve.c: Add an -march option.
	(for_reduction): Use "+=" in the reduction loop.
2025-04-10 21:09:07 +01:00
GCC Administrator
ca4e6e6317 Daily bump. 2025-04-09 00:18:02 +00:00
Tobias Burnus
0f77d88fdf OpenMP: Fix append_args handling in modify_call_for_omp_dispatch
At tree level, the addr ref is also required for array dummy arguments,
contrary to C; the GOMP_interop calls in modify_call_for_omp_dispatch
were updated accordingly (using build_fold_addr_expr).

As the GOMP_interop calls had no location data associated with them,
the init call happened as soon as executing the previous line of code,
which was confusing; solution: use the location data of the function
call itself.

	PR middle-end/119662

gcc/ChangeLog:

	* gimplify.cc (modify_call_for_omp_dispatch): Fix GOMP_interop
	arg passing; add location info to function calls.

libgomp/ChangeLog:

	* testsuite/libgomp.c/append-args-fr-1.c: New test.
	* testsuite/libgomp.c/append-args-fr.h: New test.

gcc/testsuite/ChangeLog:
	* c-c++-common/gomp/append-args-interop.c: Update for fixed
	GOMP_interop call.
	* g++.dg/gomp/append-args-8.C: Likewise.
	* gfortran.dg/gomp/append-args-interop.f90: Likewise.
2025-04-08 13:47:53 +02:00
Tobias Burnus
649b3cf32a libgomp: Add -Wno-c-binding-type for omp_lib.f90 compilation
Silence the overeager "Warning: Variable 'depobj_list' at (1) is a dummy
argument of the BIND(C) procedure ... but may not be C interoperable
[-Wc-binding-type]" when compiling omp_lib.f90(.in).

The argument is of integer kind 'omp_depend_kind = @OMP_DEPEND_KIND@'.

libgomp/ChangeLog:

	* Makefile.am (%.mod): Add -Wno-c-binding-type.
	* Makefile.in: Regenerate.
2025-04-08 12:04:59 +02:00
Tejas Belagod
a9bbb60b7c libgomp: Add AArch64 SVE target tests to libgomp.
Add AArch64 SVE target exectute tests to test various workshare constructs and
clauses with SVE types.

libgomp/ChangeLog:

	* testsuite/libgomp.c-target/aarch64/aarch64.exp: Test driver.
	* testsuite/libgomp.c-target/aarch64/firstprivate.c: New test.
	* testsuite/libgomp.c-target/aarch64/lastprivate.c: Likewise.
	* testsuite/libgomp.c-target/aarch64/private.c: Likewise.
	* testsuite/libgomp.c-target/aarch64/shared.c: Likewise.
	* testsuite/libgomp.c-target/aarch64/simd-aligned.c: Likewise.
	* testsuite/libgomp.c-target/aarch64/simd-nontemporal.c: Likewise.
	* testsuite/libgomp.c-target/aarch64/threadprivate.c: Likewise.
	* testsuite/libgomp.c-target/aarch64/udr-sve.c: Likewise.
2025-04-08 11:50:50 +05:30
GCC Administrator
0980a6ff7a Daily bump. 2025-04-08 00:17:33 +00:00
Tobias Burnus
0c63c7524b libgomp.texi: Add GCN doc for omp_target_memcpy_rect
libgomp/ChangeLog:

	* libgomp.texi (omp_target_memcpy_rect_async,
	omp_target_memcpy_rect): Add @ref to 'Offload-Target Specifics'.
	(AMD Radeon (GCN)): Document how memcpy_rect is implemented.
	(nvptx): Move item about memcpy_rect item down; use present tense.
2025-04-07 09:04:53 +02:00
GCC Administrator
c7604808d1 Daily bump. 2025-03-27 00:19:18 +00:00
Thomas Schwinge
3b36e96b57 driver: Forward '-lstdc++' to offloading compilation [PR101544]
..., so that users don't manually need to specify '-foffload-options=-lstdc++'
in addition to '-lstdc++' (specified manually, or implicitly by the driver).
Do like commit 4bcb46b3ad
"driver: Forward '-lgfortran', '-lm' to offloading compilation".

	PR driver/101544
	gcc/
	* gcc.cc (driver_handle_option): Forward host '-lstdc++' to
	offloading compilation.
	* config/gcn/mkoffload.cc (main): Adjust.
	* config/nvptx/mkoffload.cc (main): Likewise.
	libgomp/
	* testsuite/libgomp.c++/pr101544-1-O0.C: Remove
	'-foffload-options=-lstdc++'.
	* testsuite/libgomp.c++/pr101544-1.C: Likewise.
	* testsuite/libgomp.oacc-c++/pr101544-1.C: Likewise.
2025-03-26 14:20:20 +01:00
Tobias Burnus
2e7c1b589b libgomp.texi: Document supported OpenMP 'interop' types for nvptx and gcn
Note that this commit also updates the API interface to OpenMP 6.0;
while 5.1 and 5.2 use 'int *' for the the ret_code argument,
OpenMP 6.0 changed this to omp_interop_rc_t *; this enum also exists in
OpenMP 5.1. However, C++ does not like this change such that unless NULL
is passed (i.e. the argument is ignored), OpenMP 5.x and 6.x are not
compatible.

Note that GCC's omp.h already follows OpenMP 6.0 and is now in sync with
the documentation.

libgomp/ChangeLog:

	* libgomp.texi (OpenMP 5.1): Add @ref to offload-target specifics
	for 'interop'.
	(OpenMP 6.0): Mark dispatch's interop clause as implemented.
	(omp_get_interop_int, omp_get_interop_str,
	omp_get_interop_ptr, omp_get_interop_type_desc): Add @ref to
	Offload-Target Specifics; change ret_code argument type to
	'omp_interop_rc_t *'.
	(Offload-Target Specifics): Document the supported OpenMP
	interop foreign runtimes on AMD and Nvidia GPUs.
2025-03-26 11:27:56 +01:00
GCC Administrator
7d414e11ac Daily bump. 2025-03-26 00:17:07 +00:00
Sandra Loosemore
f016ee8995 OpenMP: Create additional interop objects with append_args.
This patch adds support for the case where #pragma omp declare variant
with append_args is used inside a #pragma omp dispatch interop that
specifies fewer interop args than required by the variant; new interop
objects are implicitly created and then destroyed around the call to the
variant, using the GOMP_interop builtin.

gcc/fortran/ChangeLog
	* trans-openmp.cc (gfc_trans_omp_declare_variant): Remove accidental
	redeclaration of pref.

gcc/ChangeLog
	* gimplify.cc (modify_call_for_omp_dispatch): Adjust arguments.
	Remove the "sorry" for the case where new interop objects must be
	constructed, and add code to make it work instead.
	(expand_variant_call_expr): Adjust arguments and call to
	modify_call_for_omp_dispatch.
	(gimplify_variant_call_expr): Simplify logic for calling
	expand_variant_call_expr.

gcc/testsuite/ChangeLog
	* c-c++-common/gomp/append-args-1.c: Adjust expected behavior.
	* c-c++-common/gomp/append-args-interop.c: New.
	* c-c++-common/gomp/dispatch-11.c: Adjust expected behavior.
	* g++.dg/gomp/append-args-1.C: Likewise.
	* gfortran.dg/gomp/append-args-interop.f90: New.
	* gfortran.dg/gomp/declare-variant-mod-2.f90: Adjust expected behavior.

libgomp/ChangeLog
	* libgomp.texi (OpenMP 5.1): Mark append_args as fully supported.

Co-Authored-By: Tobias Burnus <tburnus@baylibre.com>
2025-03-25 16:22:59 +00:00
GCC Administrator
f2d4725af0 Daily bump. 2025-03-25 00:19:18 +00:00
Tobias Burnus
4d5d1a7326 libgomp: Save OpenMP device number when initializing the interop object
The interop object (opaque object to the user, used internally in libgomp)
already had a 'device_num' member, but it was missed to actually set it.

libgomp/ChangeLog:

	* target.c (gomp_interop_internal): Set the 'device_num' member
	when initializing an interop object.
2025-03-24 19:52:10 +01:00
Tobias Burnus
1c5a375c21 libgomp/plugin/plugin-nvptx.c: Fix device used for stream creation
libgomp/ChangeLog:

	* plugin/plugin-nvptx.c (GOMP_OFFLOAD_interop): Set context for
	stream creation to use the specified device.
2025-03-24 16:08:20 +01:00
Thomas Schwinge
332a08173a Add 'libgomp.c++/pr96835-1{,-O0}.C', 'libgomp.oacc-c++/pr96835-1.C' [PR96835]
PR libgomp/96835
	libgomp/
	* testsuite/libgomp.c++/pr96835-1.C: New.
	* testsuite/libgomp.c++/pr96835-1-O0.C: Likewise.
	* testsuite/libgomp.oacc-c++/pr96835-1.C: Likewise.
2025-03-24 09:39:21 +01:00
Thomas Schwinge
62312c778a Add 'libgomp.c++/pr101544-1{,-O0}.C', 'libgomp.oacc-c++/pr101544-1.C' [PR101544]
PR target/101544
	libgomp/
	* testsuite/libgomp.c++/pr101544-1.C: New.
	* testsuite/libgomp.c++/pr101544-1-O0.C: Likewise.
	* testsuite/libgomp.oacc-c++/pr101544-1.C: Likewise.
2025-03-24 09:39:21 +01:00
GCC Administrator
7a6bbab6ae Daily bump. 2025-03-22 09:25:44 +00:00
Tobias Burnus
c264df142a libgomp.fortran/get-mapped-ptr-1.f90: Use -6 for non-conf dev number
This is a fix for the GOMP_interop commit r15-8654-g99e2906ae255fc that
added GOMP_DEVICE_DEFAULT_OMP_61 alias omp_default_device, which is a
conforming device number. But that test used -5 as check for a
non-conforming device number.

libgomp/ChangeLog:

	* testsuite/libgomp.fortran/get-mapped-ptr-1.f90: Use -6
	not -5 as non-conforming device number.
2025-03-22 00:36:44 +01:00
Tobias Burnus
41b9c3b848 libgomp/plugin: Add initial interop support to nvptx + gcn
The interop directive operates on an opaque object that represents a
foreign runtime. This commit adds support for
this to the two offloading plugins.

For nvptx, it supports cuda, cuda_driver and hip; the latter is AMD's
version of CUDA which for Nvidia devices boils down to normal CUDA.
Thus, at the end for this limited use, cuda/cuda_driver/hip are all
the same - and for plugin-nvptx.c, the they differ only in terms of
what gets fr_id, fr_name and get_interop_type_desc return.

For gcn, it supports hip and hsa.

Regarding get-mapped-ptr-1.c: That's actually a fix for the
GOMP_interop commit r15-8654-g99e2906ae255fc that added
GOMP_DEVICE_DEFAULT_OMP_61 alias omp_default_device, which is
a conforming device number. But that test used -5 as check for a
non-conforming device number.

libgomp/ChangeLog:

	* plugin/plugin-gcn.c (_LIBGOMP_PLUGIN_INCLUDE): Define.
	(struct hsa_runtime_fn_info): Add two queue functions.
	(hipError_t, hipCtx_t, hipStream_s, hipStream_t): New types.
	(struct hip_runtime_fn_info): New.
	(hip_runtime_lib, hip_fns): New global vars.
	(init_environment_variables): Handle hip_runtime_lib.
	(init_hsa_runtime_functions): Load the two queue functions.
	(init_hip_runtime_functions, GOMP_OFFLOAD_interop,
	GOMP_OFFLOAD_get_interop_int, GOMP_OFFLOAD_get_interop_ptr,
	GOMP_OFFLOAD_get_interop_str,
	GOMP_OFFLOAD_get_interop_type_desc): New.
	* plugin/plugin-nvptx.c (_LIBGOMP_PLUGIN_INCLUDE): Define.
	(GOMP_OFFLOAD_interop, GOMP_OFFLOAD_get_interop_int,
	GOMP_OFFLOAD_get_interop_ptr, GOMP_OFFLOAD_get_interop_str,
	GOMP_OFFLOAD_get_interop_type_desc): New.
	* testsuite/libgomp.c/interop-fr-1.c: New test.
	* testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c: Use -6
	not -5 as non-conforming device number.
2025-03-21 21:39:42 +01:00
Paul-Antoine Arras
99e2906ae2 OpenMP: 'interop' construct - add ME support + target-independent libgomp
This patch partially enables use of the OpenMP interop construct by adding
middle end support, mostly in the omplower pass, and in the target-independent
part of the libgomp runtime. It follows up on previous patches for C, C++ and
Fortran front ends support. The full interop feature requires another patch to
enable foreign runtime support in libgomp plugins.

gcc/ChangeLog:

	* builtin-types.def
	(BT_FN_VOID_INT_INT_PTR_PTR_PTR_INT_PTR_INT_PTR_UINT_PTR): New.
	* gimple-low.cc (lower_stmt): Handle GIMPLE_OMP_INTEROP.
	* gimple-pretty-print.cc (dump_gimple_omp_interop): New function.
	(pp_gimple_stmt_1): Handle GIMPLE_OMP_INTEROP.
	* gimple.cc (gimple_build_omp_interop): New function.
	(gimple_copy): Handle GIMPLE_OMP_INTEROP.
	* gimple.def (GIMPLE_OMP_INTEROP): Define.
	* gimple.h (gimple_build_omp_interop): Declare.
	(gimple_omp_interop_clauses): New function.
	(gimple_omp_interop_clauses_ptr): Likewise.
	(gimple_omp_interop_set_clauses): Likewise.
	(gimple_return_set_retval): Handle GIMPLE_OMP_INTEROP.
	* gimplify.cc (gimplify_scan_omp_clauses): Handle OMP_CLAUSE_INIT,
	OMP_CLAUSE_USE and OMP_CLAUSE_DESTROY.
	(gimplify_omp_interop): New function.
	(gimplify_expr): Replace sorry with call to gimplify_omp_interop.
	* omp-builtins.def (BUILT_IN_GOMP_INTEROP): Define.
	* omp-low.cc (scan_sharing_clauses): Handle OMP_CLAUSE_INIT,
	OMP_CLAUSE_USE and OMP_CLAUSE_DESTROY.
	(scan_omp_1_stmt): Handle GIMPLE_OMP_INTEROP.
	(lower_omp_interop_action_clauses): New function.
	(lower_omp_interop): Likewise.
	(lower_omp_1): Handle GIMPLE_OMP_INTEROP.

gcc/c/ChangeLog:

	* c-parser.cc (c_parser_omp_clause_destroy): Make addressable.
	(c_parser_omp_clause_init): Make addressable.

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_omp_clause_init): Make addressable.

gcc/fortran/ChangeLog:

	* trans-openmp.cc (gfc_trans_omp_clauses): Make OMP_CLAUSE_DESTROY and
	OMP_CLAUSE_INIT addressable.
	* types.def (BT_FN_VOID_INT_INT_PTR_PTR_PTR_INT_PTR_INT_PTR_UINT_PTR):
	New.

include/ChangeLog:

	* gomp-constants.h (GOMP_DEVICE_DEFAULT_OMP_61, GOMP_INTEROP_TARGET,
	GOMP_INTEROP_TARGETSYNC, GOMP_INTEROP_FLAG_NOWAIT): Define.

libgomp/ChangeLog:

	* icv-device.c (omp_set_default_device): Check
	GOMP_DEVICE_DEFAULT_OMP_61.
	* libgomp-plugin.h (struct interop_obj_t): New.
	(enum gomp_interop_flag): New.
	(GOMP_OFFLOAD_interop): Declare.
	(GOMP_OFFLOAD_get_interop_int): Declare.
	(GOMP_OFFLOAD_get_interop_ptr): Declare.
	(GOMP_OFFLOAD_get_interop_str): Declare.
	(GOMP_OFFLOAD_get_interop_type_desc): Declare.
	* libgomp.h (_LIBGOMP_OMP_LOCK_DEFINED): Define.
	(struct gomp_device_descr): Add interop_func, get_interop_int_func,
	get_interop_ptr_func, get_interop_str_func, get_interop_type_desc_func.
	* libgomp.map: Add GOMP_interop.
	* libgomp_g.h (GOMP_interop): Declare.
	* target.c (resolve_device): Handle GOMP_DEVICE_DEFAULT_OMP_61.
	(omp_get_interop_int): Replace stub with actual implementation.
	(omp_get_interop_ptr): Likewise.
	(omp_get_interop_str): Likewise.
	(omp_get_interop_type_desc): Likewise.
	(struct interop_data_t): Define.
	(gomp_interop_internal): New function.
	(GOMP_interop): Likewise.
	(gomp_load_plugin_for_device): Load symbols for get_interop_int,
	get_interop_ptr, get_interop_str and get_interop_type_desc.
	* testsuite/libgomp.c-c++-common/interop-1.c: New test.

gcc/testsuite/ChangeLog:

	* c-c++-common/gomp/interop-1.c: Remove dg-prune-output "sorry".
	* c-c++-common/gomp/interop-2.c: Likewise.
	* c-c++-common/gomp/interop-3.c: Likewise.
	* c-c++-common/gomp/interop-4.c: Remove dg-message "not supported".
	* g++.dg/gomp/interop-5.C: Likewise.
	* gfortran.dg/gomp/interop-4.f90: Likewise.
	* c-c++-common/gomp/interop-5.c: New test.
	* gfortran.dg/gomp/interop-5.f90: New test.

Co-authored-by: Tobias Burnus <tburnus@baylibre.com>
2025-03-21 19:24:16 +01:00
Tobias Burnus
12db61156f testsuite/lib/libgomp.exp: compile with -fdiagnostics-plain-output
libgomp.exp added -fno-diagnostics-show-caret and -fdiagnostics-color=never
as 'additional_flags' for compilation. However, it turned out that this now
is insufficient as the [...] part of diagnostics have a hyperlink URL.

Solution: Use the -fdiagnostics-plain-output flag instead, added in commit
r11-2701-g129a1319c0ab73. This flag currently implies the following flags:
   -fno-diagnostics-show-caret
   -fno-diagnostics-show-line-numbers
   -fdiagnostics-color=never
   -fdiagnostics-urls=never
   -fdiagnostics-path-format=separate-events
   -fdiagnostics-text-art-charset=none
   -fno-diagnostics-show-event-links

libgomp/ChangeLog:

	* testsuite/lib/libgomp.exp (libgomp_init): Add
	-fdiagnostics-plain-output to additional_flags; remove
	-fno-diagnostics-show-caret and -fdiagnostics-color=never.
2025-03-21 13:54:49 +01:00
GCC Administrator
b5d82890c4 Daily bump. 2025-03-18 00:19:44 +00:00
Tobias Burnus
2d5c1e5149 Move gfortran.dg/gomp/declare-variant-mod-1*.f90 to libgomp.fortran/ [PR115271]
The test is a supposed to be a compile-only test but as dg-additional-sources
does not work with dg-compile (due to compiling with '-o'), dg-link had to
be used; as the code actually compiles (no diagnostic error), the linker
is actually invoked, which fails unless the system compiler by chance
provides the required files. Solution: move the test to libgomp.

	PR fortran/115271

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/declare-variant-mod-1-use.f90: Move to
	libgomp/testsuite/libgomp.fortran/.
	* gfortran.dg/gomp/declare-variant-mod-1.f90: Likewise.

libgomp/ChangeLog:

	* testsuite/libgomp.fortran/declare-variant-mod-1-use.f90: Moved
	from gcc/testsuite/gfortran.dg/gomp/.
	* testsuite/libgomp.fortran/declare-variant-mod-1.f90: Likewise.
2025-03-17 10:12:44 +01:00
GCC Administrator
4cc54ed1f0 Daily bump. 2025-02-23 00:17:00 +00:00
shynur
e759ff08e2 libgomp: Add '__attribute__((unused))' to variables used only in 'assert(...)'
Without this attribute, the building process will fail if GCC is configured
with 'CFLAGS=-DNDEBUG'.

libgomp/ChangeLog:

	* oacc-mem.c (acc_unmap_data, goacc_exit_datum_1, find_group_last,
	goacc_enter_data_internal): Add '__attribute__((unused))'.
	* target.c (gomp_unmap_vars_internal): Likewise.
2025-02-22 22:37:50 +01:00
GCC Administrator
1fb2146baa Daily bump. 2025-02-12 00:17:11 +00:00
Jason Merrill
556248d7d2 c++: don't default -frange-for-ext-temps in -std=gnu++20 [PR188574]
Since -frange-for-ext-temps has been causing trouble, let's not enable it
by default in pre-C++23 GNU modes for GCC 15, and also allow disabling it in
C++23 and up.

	PR c++/188574

gcc/c-family/ChangeLog:

	* c-opts.cc (c_common_post_options): Only enable
	-frange-for-ext-temps by default in C++23.

gcc/ChangeLog:

	* doc/invoke.texi: Adjust -frange-for-ext-temps documentation.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp23/range-for3.C: Use -frange-for-ext-temps.
	* g++.dg/cpp23/range-for4.C: Adjust expected result.

libgomp/ChangeLog:

	* testsuite/libgomp.c++/range-for-4.C: Adjust expected result.
2025-02-12 00:07:51 +01:00