Commit Graph

2353 Commits

Author SHA1 Message Date
GCC Administrator 9261339092 Daily bump. 2024-09-28 00:19:05 +00:00
Tobias Burnus cfdc0a384a libgomp.texi: Remove now duplicate TR13 item
Remove an item under "Other new TR 13 features" that since the last commit
(r15-3917-g6b7eaec20b046e) to this file is is covered by the added
  "New @code{storage} map-type modifier; context-dependent @code{alloc} and
   @code{release} are aliases"
  "Update of the map-type decay for mapping and @code{declare_mapper}"

libgomp/
	* libgomp.texi (TR13 status): Update semi-duplicated, semi-obsoleted
	item; remove left-over half-sentence.
2024-09-27 12:06:17 +02:00
Tobias Burnus 6b7eaec20b libgomp.texi: fix formatting; add post-TR13 OpenMP impl. status items
libgomp/
	* libgomp.texi (OpenMP Technical Report 13): Change @emph to @code;
	add two post-TR13 OpenMP 6.0 items.
2024-09-27 10:48:09 +02:00
GCC Administrator ff20f2b599 Daily bump. 2024-09-27 00:18:47 +00:00
Tobias Burnus 9ec258bf65 libgomp.texi: Fix deprecation note for omp_{get,set}_nested + OMP_NESTED
libgomp/ChangeLog:

	* libgomp.texi (omp_get_nested,omp_set_nested, OMP_NESTED): Fix
	note about deprecation - correct is 5.0 not 5.2.
2024-09-26 17:25:34 +02:00
GCC Administrator 2d8392c4e7 Daily bump. 2024-09-25 00:18:47 +00:00
Jakub Jelinek 650e915665 c++: Implement C++23 P2718R0 - Wording for P2644R1 Fix for Range-based for Loop [PR107637]
The following patch implements the C++23 P2718R0 paper
- Wording for P2644R1 Fix for Range-based for Loop.
The patch introduces a new option, -f{,no-}range-for-ext-temps so that
user can control the behavior even in older C++ versions.
The option is on by default in C++23 and later (-fno-range-for-ext-temps
is an error in that case) and in the -std=gnu++11 ... -std=gnu++20 modes
(one can use -fno-range-for-ext-temps to request previous behavior in that
case), and is not enabled by default in -std=c++11 ... -std=c++20 modes
but one can explicitly enable it with -frange-for-ext-temps.
As all the temporaries from __for_range initialization should have life
extended until the end of __for_range scope, this patch disables (for
-frange-for-ext-temps and if !processing_template_decl) CLEANUP_POINT_EXPR wrapping
of the __for_range declaration, also disables -Wdangling-reference warning
as well as the rest of extend_ref_init_temps (we know the __for_range temporary
is not TREE_STATIC and as all the temporaries from the initializer will be life
extended, we shouldn't try to handle temporaries referenced by references any
differently) and adds an extra push_stmt_list/pop_stmt_list before
cp_finish_decl of __for_range and after end of the for body and wraps all
that into CLEANUP_POINT_EXPR.
I had to repeat that also for OpenMP range loops because those are handled
differently.

2024-09-24  Jakub Jelinek  <jakub@redhat.com>

	PR c++/107637
gcc/
	* omp-general.cc (find_combined_omp_for, find_nested_loop_xform):
	Handle CLEANUP_POINT_EXPR like TRY_FINALLY_EXPR.
	* doc/invoke.texi (frange-for-ext-temps): Document.  Add
	-fconcepts to the C++ option list.
gcc/c-family/
	* c.opt (frange-for-ext-temps): New option.
	* c-opts.cc (c_common_post_options): Set flag_range_for_ext_temps
	for C++23 or later or for C++11 or later in !flag_iso mode if
	the option wasn't set by user.
	* c-cppbuiltin.cc (c_cpp_builtins): Change __cpp_range_based_for
	value for flag_range_for_ext_temps from 201603L to 202212L in C++17
	or later.
	* c-omp.cc (c_find_nested_loop_xform_r): Handle CLEANUP_POINT_EXPR
	like TRY_FINALLY_EXPR.
gcc/cp/
	* cp-tree.h: Implement C++23 P2718R0 - Wording for P2644R1 Fix for
	Range-based for Loop.
	(cp_convert_omp_range_for): Add bool tmpl_p argument.
	(find_range_for_decls): Declare.
	* parser.cc (cp_convert_range_for): For flag_range_for_ext_temps call
	push_stmt_list () before cp_finish_decl for range_temp and save it
	temporarily to FOR_INIT_STMT.
	(cp_convert_omp_range_for): Add tmpl_p argument.  If set, remember
	DECL_NAME of range_temp and for cp_finish_decl call restore it before
	clearing it again, if unset, don't adjust DECL_NAME of range_temp at
	all.
	(cp_parser_omp_loop_nest): For flag_range_for_ext_temps range for add
	CLEANUP_POINT_EXPR around sl.  Call find_range_for_decls and adjust
	DECL_NAMEs for range fors if not processing_template_decl.  Adjust
	cp_convert_omp_range_for caller.  Remove superfluous backslash at the
	end of line.
	* decl.cc (initialize_local_var): For flag_range_for_ext_temps
	temporarily clear stmts_are_full_exprs_p rather than set for
	for_range__identifier decls.
	* call.cc (extend_ref_init_temps): For flag_range_for_ext_temps return
	init early for for_range__identifier decls.
	* semantics.cc (find_range_for_decls): New function.
	(finish_for_stmt): Use it.  For flag_range_for_ext_temps if
	cp_convert_range_for set FOR_INIT_STMT, pop_stmt_list it and wrap
	into CLEANUP_POINT_EXPR.
	* pt.cc (tsubst_omp_for_iterator): Adjust tsubst_omp_for_iterator
	caller.
	(tsubst_stmt) <case OMP_FOR>: For flag_range_for_ext_temps if there
	are any range fors in the loop nest, add push_stmt_list starting
	before the initializations, pop_stmt_list it after the body and wrap
	into CLEANUP_POINT_EXPR.  Change DECL_NAME of range for temps from
	NULL to for_range_identifier.
gcc/testsuite/
	* g++.dg/cpp23/range-for1.C: New test.
	* g++.dg/cpp23/range-for2.C: New test.
	* g++.dg/cpp23/range-for3.C: New test.
	* g++.dg/cpp23/range-for4.C: New test.
	* g++.dg/cpp23/range-for5.C: New test.
	* g++.dg/cpp23/range-for6.C: New test.
	* g++.dg/cpp23/range-for7.C: New test.
	* g++.dg/cpp23/range-for8.C: New test.
	* g++.dg/cpp23/feat-cxx2b.C (__cpp_range_based_for): Check for
	202212L rather than 201603L.
	* g++.dg/cpp26/feat-cxx26.C (__cpp_range_based_for): Likewise.
	* g++.dg/warn/Wdangling-reference4.C: Don't expect warning for C++23
	or newer.  Use dg-additional-options rather than dg-options.
libgomp/
	* testsuite/libgomp.c++/range-for-1.C: New test.
	* testsuite/libgomp.c++/range-for-2.C: New test.
	* testsuite/libgomp.c++/range-for-3.C: New test.
	* testsuite/libgomp.c++/range-for-4.C: New test.
	* testsuite/libgomp.c++/range-for-5.C: New test.
2024-09-24 20:24:57 +02:00
Tobias Burnus 4cb20dc043 libgomp: with USM, init 'link' variables with host address
If requires unified_shared_memory or self_maps is set, make
'declare target link' variables to point initially to the host pointer.

libgomp/ChangeLog:

	* target.c (gomp_load_image_to_device): For requires
	unified_shared_memory, update 'link' vars to point to the host var.
	* testsuite/libgomp.c-c++-common/target-link-3.c: New test.
	* testsuite/libgomp.c-c++-common/target-link-4.c: New test.
2024-09-24 17:41:39 +02:00
Tobias Burnus b752eed3e3 OpenMP: Add support for 'self_maps' to the 'require' directive
'self_maps' implies 'unified_shared_memory', except that the latter
also permits that explicit maps copy data to device memory while
self_maps does not. In GCC, currently, both are handled identical.

gcc/c/ChangeLog:

	* c-parser.cc (c_parser_omp_requires): Handle self_maps clause.

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_omp_requires): Handle self_maps clause.

gcc/fortran/ChangeLog:

	* gfortran.h (enum gfc_omp_requires_kind): Add OMP_REQ_SELF_MAPS.
	(gfc_namespace): Enlarge omp_requires bitfield.
	* module.cc (enum ab_attribute, attr_bits): Add AB_OMP_REQ_SELF_MAPS.
	(mio_symbol_attribute): Handle it.
	* openmp.cc (gfc_check_omp_requires, gfc_match_omp_requires): Handle
	self_maps clause.
	* parse.cc (gfc_parse_file): Handle self_maps clause.

gcc/ChangeLog:

	* lto-cgraph.cc (output_offload_tables, omp_requires_to_name): Handle
	self_maps clause.
	* omp-general.cc (struct omp_ts_info, omp_context_selector_matches):
	Likewise for the associated trait.
	* omp-general.h (enum omp_requires): Add OMP_REQUIRES_SELF_MAPS.
	* omp-selectors.h (enum omp_ts_code): Add
	OMP_TRAIT_IMPLEMENTATION_SELF_MAPS.

include/ChangeLog:

	* gomp-constants.h (GOMP_REQUIRES_SELF_MAPS): #define.

libgomp/ChangeLog:

	* plugin/plugin-gcn.c (GOMP_OFFLOAD_get_num_devices):
	Accept self_maps clause.
	* plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_num_devices):
	Likewise.
	* libgomp.texi (TR13 Impl. Status): Set to 'Y'.
	* target.c (gomp_requires_to_name, GOMP_offload_register_ver,
	gomp_target_init): Handle self_maps clause.
	* testsuite/libgomp.fortran/self_maps.f90: New test.

gcc/testsuite/ChangeLog:

	* c-c++-common/gomp/declare-variant-1.c: Add self_maps test.
	* c-c++-common/gomp/requires-4.c: Likewise.
	* gfortran.dg/gomp/declare-variant-3.f90:  Likewise.
	* c-c++-common/gomp/requires-2.c: Update dg-error msg.
	* gfortran.dg/gomp/requires-2.f90: Likewise.
	* gfortran.dg/gomp/requires-self-maps-aux.f90: New.
	* gfortran.dg/gomp/requires-self-maps.f90: New.
2024-09-24 10:53:59 +02:00
GCC Administrator 4d6fa5b7f1 Daily bump. 2024-09-24 00:18:14 +00:00
Tobias Burnus cdb9aa0f62 OpenMP: Fix omp_get_device_from_uid, minor cleanup
In Fortran, omp_get_device_from_uid can also accept substrings, which are
then not NUL terminated.  Fixed by introducing a fortran.c wrapper function.
Additionally, in case of a fail the plugin functions now return NULL instead
of failing fatally such that a fall-back UID is generated.

gcc/ChangeLog:

	* omp-general.cc (omp_runtime_api_procname): Strip "omp_" from
	string; move get_device_from_uid as now a '_' suffix exists.

libgomp/ChangeLog:

	* fortran.c (omp_get_device_from_uid_): New function.
	* libgomp.map (GOMP_6.0): Add it.
	* oacc-host.c (host_dispatch): Init '.uid' and '.get_uid_func'.
	* omp_lib.f90.in: Make it used by removing bind(C).
	* omp_lib.h.in: Likewise.
	* target.c (omp_get_device_from_uid): Ensure the device is initialized.
	* plugin/plugin-gcn.c (GOMP_OFFLOAD_get_uid): Add function comment;
	return NULL in case of an error.
	* plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_uid): Likewise.
	* testsuite/libgomp.fortran/device_uid.f90: Update to test substrings.
2024-09-23 15:58:39 +02:00
GCC Administrator 442db842f3 Daily bump. 2024-09-20 17:36:00 +00:00
Tobias Burnus bf4a5efa80 OpenMP: Add get_device_from_uid/omp_get_uid_from_device routines
Those TR13/OpenMP 6.0 routines permit a reproducible offloading to
a specific device by mapping an OpenMP device number to a
unique ID (UID). The GPU device UIDs should be universally unique,
the one for the host is not.

gcc/ChangeLog:

	* omp-general.cc (omp_runtime_api_procname): Add
	get_device_from_uid and omp_get_uid_from_device routines.

include/ChangeLog:

	* cuda/cuda.h (cuDeviceGetUuid): Declare.
	(cuDeviceGetUuid_v2): Add prototype.

libgomp/ChangeLog:

	* config/gcn/target.c (omp_get_uid_from_device,
	omp_get_device_from_uid): Add stub implementation.
	* config/nvptx/target.c (omp_get_uid_from_device,
	omp_get_device_from_uid): Likewise.
	* fortran.c (omp_get_uid_from_device_,
	omp_get_uid_from_device_8_): New functions.
	* libgomp-plugin.h (GOMP_OFFLOAD_get_uid): Add prototype.
	* libgomp.h (struct gomp_device_descr): Add 'uid' and 'get_uid_func'.
	* libgomp.map (GOMP_6.0): New, includind the new UID routines.
	* libgomp.texi (OpenMP Technical Report 13): Mark UID routines as 'Y'.
	(Device Information Routines): Document new UID routines.
	(Offload-Target Specifics): Document UID format.
	* omp.h.in (omp_get_device_from_uid, omp_get_uid_from_device):
	New prototype.
	* omp_lib.f90.in (omp_get_device_from_uid, omp_get_uid_from_device):
	New interface.
	* omp_lib.h.in: Likewise.
	* plugin/cuda-lib.def: Add cuDeviceGetUuid and cuDeviceGetUuid_v2 via
	CUDA_ONE_CALL_MAYBE_NULL.
	* plugin/plugin-gcn.c (GOMP_OFFLOAD_get_uid): New.
	* plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_uid): New.
	* target.c (str_omp_initial_device): New static var.
	(STR_OMP_DEV_PREFIX): Define.
	(gomp_get_uid_for_device, omp_get_uid_from_device,
	omp_get_device_from_uid): New.
	(gomp_load_plugin_for_device): DLSYM_OPT the function 'get_uid'.
	(gomp_target_init): Set the device's 'uid' field to NULL.
	* testsuite/libgomp.c/device_uid.c: New test.
	* testsuite/libgomp.fortran/device_uid.f90: New test.
2024-09-20 09:25:33 +02:00
GCC Administrator 519ec1cfe9 Daily bump. 2024-09-03 00:21:29 +00:00
Andrew Stubbs 57af002207 amdgcn: remove gfx803 "Fiji" support
The gfx803 "Fiji" device was deprecated in GCC 14, removed from LLVM 18, and
hasn't worked properly with the drivers since about ROCm 4.

This patch removes the device from GCC options and documentation, and removes
the direct mentions from the internals.

The TARGET_GCN3 support in the back-end is now unused and can be removed (in a
follow-up patch).

gcc/ChangeLog:

	* config.gcc (amdgcn-*-*): Remove "fiji" from with_arch checks.
	* config/gcn/gcn-hsa.h (ABI_VERSION_SPEC): Remove fiji alternative.
	(NO_XNACK): Likewise.
	(NO_SRAM_ECC): Likewise.
	(ASM_SPEC): Remove "%{}" around ABI_VERSION_SPEC.
	* config/gcn/gcn-opts.h (enum processor_type): Remove PROCESSOR_FIJI.
	(TARGET_FIJI): Delete.
	* config/gcn/gcn.cc (gcn_option_override): Remove Fiji.
	(gcn_omp_device_kind_arch_isa): Likewise.
	(output_file_start): Likewise.
	* config/gcn/gcn.h (TARGET_CPU_CPP_BUILTINS): Likewise.
	* config/gcn/gcn.opt (gpu_type): Likewise.
	(march, mtune): Change default to PROCESSOR_VEGA10.
	* config/gcn/mkoffload.cc (EF_AMDGPU_MACH_AMDGCN_GFX803): Delete.
	(copy_early_debug_info): Remove elf_flags_actual.
	Use ELFABIVERSION_AMDGPU_HSA_V4 unconditionally.
	(get_arch): Remove Fiji.
	(main): Remove gfx803.
	* config/gcn/t-omp-device
	(omp-device-properties-gcn): Remove fiji and gfx803.
	* doc/install.texi (amdgcn*-*-*): Remove fiji and special instructions.
	* doc/invoke.texi: Remove fiji.

libgomp/ChangeLog:

	* libgomp.texi: Remove fiji and gfx803.
	* testsuite/libgomp.c/declare-variant-4.h: Remove fiji and gfx803.
	* testsuite/libgomp.c/declare-variant-4-fiji.c: Removed.
	* testsuite/libgomp.c/declare-variant-4-gfx803.c: Removed.
2024-09-02 13:08:46 +00:00
Alex Coplan e4d3e7f9ad testsuite: Rename scanltranstree.exp -> scanltrans.exp
Since r15-3254-g3f51f0dc88ec21c1ec79df694200f10ef85915f4
added scan-ltrans-rtl* variants to scanltranstree.exp, it no longer
makes sense to have "tree" in the name.  This renames the file
accordingly and updates users.

libatomic/ChangeLog:

	* testsuite/lib/libatomic.exp: Load scanltrans.exp instead of
	scanltranstree.exp.

libgomp/ChangeLog:

	* testsuite/lib/libgomp.exp: Load scanltrans.exp instead of
	scanltranstree.exp.

libitm/ChangeLog:

	* testsuite/lib/libitm.exp: Load scanltrans.exp instead of
	scanltranstree.exp.

libphobos/ChangeLog:

	* testsuite/lib/libphobos-dg.exp: Load scanltrans.exp instead of
	scanltranstree.exp.

libvtv/ChangeLog:

	* testsuite/lib/libvtv.exp: Load scanltrans.exp instead of
	scanltranstree.exp.

gcc/testsuite/ChangeLog:

	* gcc.dg-selftests/dg-final.exp: Load scanltrans.exp instead of
	scanltranstree.exp.
	* lib/gcc-dg.exp: Likewise.
	* lib/scanltranstree.exp: Rename to ...
	* lib/scanltrans.exp: ... this.
2024-09-02 10:07:09 +01:00
GCC Administrator 6cd806adac Daily bump. 2024-08-29 00:19:25 +00:00
Tobias Burnus 0beac1db38 libgomp: Add interop types and routines to OpenMP's headers and module
This commit adds OpenMP 5.1+'s interop enumeration, type and routine
declarations to the C/C++ header file and, new in OpenMP TR13, also to
the Fortran module and omp_lib.h header file.

While a stub implementation is provided, only with foreign runtime
support by the libgomp GPU plugins and with the 'interop' directive,
this becomes really useful.

libgomp/ChangeLog:

	* fortran.c (omp_get_interop_str_, omp_get_interop_name_,
	omp_get_interop_type_desc_, omp_get_interop_rc_desc_): Add.
	* libgomp.map (GOMP_5.1.3): New; add interop routines.
	* omp.h.in: Add interop typedefs, enum and prototypes.
	(__GOMP_DEFAULT_NULL): Define.
	(omp_target_memcpy_async, omp_target_memcpy_rect_async):
	Use it for the optional depend argument.
	* omp_lib.f90.in: Add paramters and interfaces for interop.
	* omp_lib.h.in: Likewise; move F90 '&' to column 81 for
	-ffree-length-80.
	* target.c (omp_get_num_interop_properties, omp_get_interop_int,
	omp_get_interop_ptr, omp_get_interop_str, omp_get_interop_name,
	omp_get_interop_type_desc, omp_get_interop_rc_desc): Add.
	* config/gcn/target.c (omp_get_num_interop_properties,
	omp_get_interop_int, omp_get_interop_ptr, omp_get_interop_str,
	omp_get_interop_name, omp_get_interop_type_desc,
	omp_get_interop_rc_desc): Add.
	* config/nvptx/target.c (omp_get_num_interop_properties,
	omp_get_interop_int, omp_get_interop_ptr, omp_get_interop_str,
	omp_get_interop_name, omp_get_interop_type_desc,
	omp_get_interop_rc_desc): Add.
	* testsuite/libgomp.c-c++-common/interop-routines-1.c: New test.
	* testsuite/libgomp.c-c++-common/interop-routines-2.c: New test.
	* testsuite/libgomp.fortran/interop-routines-1.F90: New test.
	* testsuite/libgomp.fortran/interop-routines-2.F90: New test.
	* testsuite/libgomp.fortran/interop-routines-3.F: New test.
	* testsuite/libgomp.fortran/interop-routines-4.F: New test.
	* testsuite/libgomp.fortran/interop-routines-5.F: New test.
	* testsuite/libgomp.fortran/interop-routines-6.F: New test.
	* testsuite/libgomp.fortran/interop-routines-7.F90: New test.
2024-08-28 11:50:43 +02:00
GCC Administrator 6b4b27a0f5 Daily bump. 2024-08-10 00:17:05 +00:00
Thomas Schwinge 9f5d22e3e2 OpenMP: Constructors and destructors for "declare target" static aggregates: Fix effective-target keyword in test cases
(Most of) the tests added in commit f1bfba3a9b
"OpenMP: Constructors and destructors for "declare target" static aggregates"
had a mismatch between dump file production and its scanning; the former needs
to use 'offload_target_nvptx' (like 'offload_target_amdgcn'), not
'offload_device_nvptx'.

	libgomp/
	* testsuite/libgomp.c++/static-aggr-constructor-destructor-1.C:
	Fix effective-target keyword.
	* testsuite/libgomp.c++/static-aggr-constructor-destructor-2.C:
	Likewise.
	* testsuite/libgomp.c-c++-common/target-is-initial-host-2.c:
	Likewise.
	* testsuite/libgomp.c-c++-common/target-is-initial-host.c:
	Likewise.
	* testsuite/libgomp.fortran/target-is-initial-host-2.f90:
	Likewise.
	* testsuite/libgomp.fortran/target-is-initial-host.f: Likewise.
	* testsuite/libgomp.fortran/target-is-initial-host.f90: Likewise.
2024-08-09 12:59:03 +02:00
GCC Administrator 77ccfa6ac8 Daily bump. 2024-08-09 00:18:56 +00:00
Tobias Burnus 89d2f3fefb libgomp.texi: Update implementation status table for OpenMP TR13
libgomp/ChangeLog:

	* libgomp.texi (OpenMP Technical Report 13): Renamed from
	'OpenMP Technical Report 12'; updated for TR13 changes.
2024-08-08 17:23:38 +02:00
Tobias Burnus 8b5a8b1f60 libgomp/libgomp.texi: Mention -fno-builtin-omp_is_initial_device
libgomp/ChangeLog:

	* libgomp.texi (omp_is_initial_device): Mention
	-fno-builtin-omp_is_initial_device and folding by default.
2024-08-08 14:24:59 +02:00
Tobias Burnus e3a6dec326 libgomp.c++/static-aggr-constructor-destructor-{1,2}.C: Fix scan-tree-dump
In principle, the optimized dump should be the same on the host, but as
'nohost' is not handled, is is present. However when ENABLE_OFFLOADING is
false, it is handled early enough to remove the function.

libgomp/ChangeLog:

	* testsuite/libgomp.c++/static-aggr-constructor-destructor-1.C: Split
	scan-tree-dump into with and without target offload_target_any.
	* testsuite/libgomp.c++/static-aggr-constructor-destructor-2.C:
	Likewise.
2024-08-08 10:42:25 +02:00
GCC Administrator ea973bd492 Daily bump. 2024-08-08 00:18:23 +00:00
Tobias Burnus f1bfba3a9b OpenMP: Constructors and destructors for "declare target" static aggregates
This commit also compile-time expands (__builtin_)omp_is_initial_device for
both Fortran and C/C++ (unless, -fno-builtin-omp_is_initial_device is used).
But the main change is:

This commit adds support for running constructors and destructors for
static (file-scope) aggregates for C++ objects which are marked with
"declare target" directives on OpenMP offload targets.

Before this commit, space is allocated on the target for such aggregates,
but nothing ever constructs them properly, so they end up zero-initialised.

(See the new test static-aggr-constructor-destructor-3.C for a reason
why running constructors on the target is preferable to e.g. constructing
on the host and then copying the resulting object to the target.)

2024-08-07  Julian Brown  <julian@codesourcery.com>
	    Tobias Burnus  <tobias@baylibre.com>

gcc/ChangeLog:

	* builtins.def (DEF_GOMP_BUILTIN_COMPILER): Define
	DEF_GOMP_BUILTIN_COMPILER to handle the non-prefix version.
	* gimple-fold.cc (gimple_fold_builtin_omp_is_initial_device): New.
	(gimple_fold_builtin): Call it.
	* omp-builtins.def (BUILT_IN_OMP_IS_INITIAL_DEVICE): Define.
	* tree.cc (get_file_function_name): Support names for on-target
	constructor/destructor functions.

gcc/cp/
	* decl2.cc (tree-inline.h): Include.
	(static_init_fini_fns): Bump to four entries. Update comment.
	(start_objects, start_partial_init_fini_fn): Add 'omp_target'
	parameter. Support "declare target" decls. Update forward declaration.
	(emit_partial_init_fini_fn): Add 'host_fn' parameter. Return tree for
	the created function. Support "declare target".
	(OMP_SSDF_IDENTIFIER): New macro.
	(partition_vars_for_init_fini): Support partitioning "declare target"
	variables also.
	(generate_ctor_or_dtor_function): Add 'omp_target' parameter. Support
	"declare target" decls.
	(c_parse_final_cleanups): Support constructors/destructors on OpenMP
	offload targets.

gcc/fortran/ChangeLog:

	* gfortran.h (gfc_option_t): Add disable_omp_is_initial_device.
	* lang.opt (fbuiltin-): Add.
	* options.cc (gfc_handle_option): Handle
	-fno-builtin-omp_is_initial_device.
	* f95-lang.cc (gfc_init_builtin_functions): Handle
	DEF_GOMP_BUILTIN_COMPILER.
	* trans-decl.cc (gfc_get_extern_function_decl): Add code to use
	DEF_GOMP_BUILTIN_COMPILER for 'omp_is_initial_device'.

libgomp/ChangeLog:

	* testsuite/libgomp.c++/static-aggr-constructor-destructor-1.C: New test.
	* testsuite/libgomp.c++/static-aggr-constructor-destructor-2.C: New test.
	* testsuite/libgomp.c++/static-aggr-constructor-destructor-3.C: New test.
	* testsuite/libgomp.c-c++-common/target-is-initial-host.c: New test.
	* testsuite/libgomp.c-c++-common/target-is-initial-host-2.c: New test.
	* testsuite/libgomp.fortran/target-is-initial-host.f: New test.
	* testsuite/libgomp.fortran/target-is-initial-host.f90: New test.
	* testsuite/libgomp.fortran/target-is-initial-host-2.f90: New test.

Co-authored-by: Tobias Burnus <tobias@baylibre.com>
2024-08-07 19:31:19 +02:00
Tobias Burnus aa689684d2 libgomp.c-c++-common/target-link-2.c: Fix test on multi-device systems
libgomp/ChangeLog:

	* testsuite/libgomp.c-c++-common/target-link-2.c: Reset variable
	value to handle multi-device tests.
2024-08-07 17:59:21 +02:00
GCC Administrator b120ca0c1d Daily bump. 2024-08-07 00:16:52 +00:00
Tobias Burnus 0c56fd6a1f libgomp: Device load_image - improve minor num-funcs/vars check
The run time library loads the offload functions and variable and optionally
the ICV variable and returns the number of loaded items, which has to match
the host side. The plugin returns "+1" (since GCC 12) for the ICV variable
entry, independently whether it was loaded or not, but the var's value
(start == end == 0) can be used to detect when this failed.

Thus, we can tighten the assert check - which this commit does together with
making the output less surprising - and simplify the condition further below.

libgomp/ChangeLog:

	* target.c (gomp_load_image_to_device): Extend fatal-error message;
	simplify a condition.
2024-08-06 10:34:28 +02:00
GCC Administrator 8ac4db24e4 Daily bump. 2024-08-06 00:17:19 +00:00
Tobias Burnus 1a5734135d libgomp.texi: Add OpenMP TR13 routines to @menu (commented out)
To keep track of missing routine documentation (both implemented and not),
the libgomp.texi file contains all non-OMPT routines as commented items
in @menu. This commit adds the routines added in TR13 as commented fixme
items.

libgomp/ChangeLog:

	* libgomp.texi (OpenMP Runtime Library Routines): Add TR13 routines
	to @menu (commented out).
2024-08-05 09:18:29 +02:00
GCC Administrator 02e83ff378 Daily bump. 2024-08-02 00:18:55 +00:00
Tobias Burnus c99cdcab4f omp-offload.cc: Fix value-expr handling of 'declare target link' vars [PR115637]
As the PR and included testcase shows, replacing 'arr2' by its value expression
'*arr2$13$linkptr' failed for
  MEM <uint128_t> [(c_char * {ref-all})&arr2]
which left 'arr2' in the code as unknown symbol. Now expand the value expression
already in pass_omp_target_link::execute's process_link_var_op walk_gimple_stmt
walk - and don't rely on gimple_regimplify_operands.

	PR middle-end/115637

gcc/ChangeLog:

	* gimplify.cc (gimplify_body): Fix macro name in the comment.
	* omp-offload.cc (find_link_var_op): Rename to ...
	(process_link_var_op): ... this. Replace value expr.
	(pass_omp_target_link::execute): Update walk_gimple_stmt call.

libgomp/ChangeLog:

	* testsuite/libgomp.fortran/declare-target-link.f90: Uncomment
	now working code.

Co-authored-by: Richard Biener <rguenther@suse.de
2024-08-01 09:06:32 +02:00
GCC Administrator 22c62d33ec Daily bump. 2024-08-01 00:19:03 +00:00
Sam James 9ad3d1c581
testsuite: fix dg-require-effective-target order vs dg-additional-sources
Per gccint, 'dg-require-effective-target' must come before any
'dg-additional-sources' directives. Fix a handful of deviant cases.

gcc/testsuite/ChangeLog:
	* gcc.target/aarch64/aapcs64/func-ret-3.c: Fix dg-require-effective-target directive order.
	* gcc.target/aarch64/aapcs64/func-ret-4.c: Likewise.
	* gfortran.dg/PR100914.f90: Likewise.

libgomp/ChangeLog:
	* testsuite/libgomp.c++/pr24455.C: Fix dg-require-effective-target directive order.
	* testsuite/libgomp.c/pr24455.c: Likewise.
2024-07-31 16:09:54 +01:00
Sam James 1c85b16f19
testsuite: libgomp: fix dg-do run typo
'dg-run' is not a valid dejagnu directive, 'dg-do run' is needed here
for the test to be executed.

That said, it actually seems to be executed for me anyway, presumably
a default in the directory, but let's fix it to be consistent with
other uses in the tree and in that test directory even.

libgomp/ChangeLog:
	* testsuite/libgomp.c++/declare-target-indirect-1.C: Fix 'dg-run' typo.
2024-07-31 16:09:50 +01:00
GCC Administrator 1caeabdbd8 Daily bump. 2024-07-30 00:18:10 +00:00
Tobias Burnus 8d3325708c libgomp.texi: Update 'Device Information Routines' section
Update 'OpenMP Runtime Library Routines' by adding a note that invoking
inside a target region might invoke unspecified behavior. Additionally,
update omp_{get,set}_default_device for omp_{initial,invalid}_device
named constants.

libgomp/ChangeLog:

	* libgomp.texi (OpenMP Runtime Library Routines): Add missing
	title to some commented still undocumented items.
	(Device Information Routines): Update.
2024-07-29 17:43:42 +02:00
Tobias Burnus 29b1587e7d OpenMP/Fortran: Fix handling of 'declare target' with 'link' clause [PR115559]
Contrary to a normal 'declare target', the 'declare target link' attribute
also needs to set node->offloadable and push the offload_vars in the front end.

Linked variables require that the data is mapped. For module variables, this
can happen anywhere. For variables in an external subprograms or the main
programm, this can only happen in the either that program itself or in an
internal subprogram. - Whether a variable is just normally mapped or linked then
becomes relevant if a device routine exists that can access that variable,
i.e. an internal procedure has then to be marked as declare target.

	PR fortran/115559

gcc/fortran/ChangeLog:

	* trans-common.cc (build_common_decl): Add 'omp declare target' and
	'omp declare target link' variables to offload_vars.
	* trans-decl.cc (add_attributes_to_decl): Likewise; update args and
	call decl_attributes.
	(get_proc_pointer_decl, gfc_get_extern_function_decl,
	build_function_decl): Update calls.
	(gfc_get_symbol_decl): Likewise; move after 'DECL_STATIC (t)=1'
	to avoid errors with symtab_node::get_create.

libgomp/ChangeLog:

	* testsuite/libgomp.fortran/declare-target-link.f90: New test.
2024-07-29 11:46:57 +02:00
Tobias Burnus 14c47e7eb0 libgomp: Fix declare target link with offset array-section mapping [PR116107]
Assume that 'int var[100]' is 'omp declare target link(var)'. When now
mapping an array section with offset such as 'map(to:var[20:10])',
the device-side link pointer has to store &<device-storage-data>[0] minus
the offset such that var[20] will access <device-storage-data>[0]. But
the offset calculation was missed such that the device-side 'var' pointed
to the first element of the mapped data - and var[20] points beyond at
some invalid memory.

	PR middle-end/116107

libgomp/ChangeLog:

	* target.c (gomp_map_vars_internal): Honor array mapping offsets
	with declare-target 'link' variables.
	* testsuite/libgomp.c-c++-common/target-link-2.c: New test.
2024-07-29 11:40:38 +02:00
GCC Administrator 8d6498f0d7 Daily bump. 2024-07-20 00:17:53 +00:00
Thomas Schwinge a95c1911d8 libgomp: Document 'GOMP_teams4'
For reference:

  - <https://inbox.sourceware.org/20211111190313.GV2710@tucnak> "[PATCH] openmp: Honor OpenMP 5.1 num_teams lower bound"
  - <https://inbox.sourceware.org/20211112132023.GC2710@tucnak> "[PATCH] libgomp, nvptx: Honor OpenMP 5.1 num_teams lower bound"

	libgomp/
	* config/gcn/target.c (GOMP_teams4): Document.
	* config/nvptx/target.c (GOMP_teams4): Likewise.
	* target.c (GOMP_teams4): Likewise.
2024-07-19 21:55:47 +02:00
Thomas Schwinge f9119948ce GCN: Honor OpenMP 5.1 'num_teams' lower bound
Corresponding to commit 9fa72756d9
"libgomp, nvptx: Honor OpenMP 5.1 num_teams lower bound", these are the
GCN offloading changes to fix:

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

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

..., and omptests' 't-critical' test case.  I've cross checked that those test
cases are the ones that regress for nvptx offloading, if I locally revert the
"libgomp, nvptx: Honor OpenMP 5.1 num_teams lower bound" changes.

	libgomp/
	* config/gcn/libgomp-gcn.h (GOMP_TEAM_NUM): Inject.
	* config/gcn/target.c (GOMP_teams4): Handle.
	* config/gcn/team.c (gomp_gcn_enter_kernel): Initialize.
	* config/gcn/teams.c (omp_get_team_num): Adjust.
2024-07-19 21:55:47 +02:00
Paul Thomas 8d6994f33a libgomp: Remove bogus warnings from privatized-ref-2.f90.
2024-07-19  Paul Thomas  <pault@gcc.gnu.org>

libgomp/ChangeLog

	* testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: Cut
	dg-note about 'a' and remove bogus warnings about its array
	descriptor components being used uninitialized.
2024-07-19 16:58:33 +01:00
GCC Administrator 0b4fd672bf Daily bump. 2024-07-02 00:17:36 +00:00
Andrew Stubbs 64001441ec libgomp, openmp: Add ompx_gnu_pinned_mem_alloc
This creates a new predefined allocator as a shortcut for using pinned
memory with OpenMP.  This is not in the OpenMP standard so it uses the "ompx"
namespace and an independent enum baseline of 200 (selected to not clash with
other known implementations).

The allocator is equivalent to using a custom allocator with the pinned
trait and the null fallback trait.  One motivation for having this feature is
for use by the (planned) -foffload-memory=pinned feature.

gcc/fortran/ChangeLog:

	* openmp.cc (is_predefined_allocator): Update valid ranges to
	incorporate ompx_gnu_pinned_mem_alloc.

libgomp/ChangeLog:

	* allocator.c (ompx_gnu_min_predefined_alloc): New.
	(ompx_gnu_max_predefined_alloc): New.
	(predefined_alloc_mapping): Rename to ...
	(predefined_omp_alloc_mapping): ... this.
	(predefined_ompx_gnu_alloc_mapping): New.
	(_Static_assert): Adjust for the new name, and add a new assert for the
	new table.
	(predefined_allocator_p): New.
	(predefined_alloc_mapping): New.
	(omp_aligned_alloc): Support ompx_gnu_pinned_mem_alloc.
	Use predefined_allocator_p and predefined_alloc_mapping.
	(omp_free): Likewise.
	(omp_alligned_calloc): Likewise.
	(omp_realloc): Likewise.
	* env.c (parse_allocator): Add ompx_gnu_pinned_mem_alloc.
	* libgomp.texi: Document ompx_gnu_pinned_mem_alloc.
	* omp.h.in (omp_allocator_handle_t): Add ompx_gnu_pinned_mem_alloc.
	* omp_lib.f90.in: Add ompx_gnu_pinned_mem_alloc.
	* omp_lib.h.in: Add ompx_gnu_pinned_mem_alloc.
	* testsuite/libgomp.c/alloc-pinned-5.c: New test.
	* testsuite/libgomp.c/alloc-pinned-6.c: New test.
	* testsuite/libgomp.fortran/alloc-pinned-1.f90: New test.

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/allocate-pinned-1.f90: New test.

Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com>
2024-07-01 10:59:59 +00:00
Andrew Stubbs 90efaebf95 libgomp: change alloc-pinned tests failure mode
The feature doesn't work on non-Linux hosts, at present, so skip the tests
entirely.

On Linux systems that have insufficient lockable memory configured we still
need to fail or else the feature won't be getting tested when we think it is,
but now there's a message to explain why.

libgomp/ChangeLog:

	* testsuite/libgomp.c/alloc-pinned-1.c: Change dg-xfail-run-if to
	dg-skip-if.
	Correct spelling mistake.
	Abort on insufficient lockable memory.
	Use #error on non-linux hosts.
	* testsuite/libgomp.c/alloc-pinned-2.c: Likewise.
2024-07-01 10:53:57 +00:00
GCC Administrator 6af18e8c95 Daily bump. 2024-06-07 00:16:38 +00:00
Tobias Burnus 423522aacd libgomp.texi (nvptx): Add missing preposition
libgomp/
	* libgomp.texi (nvptx): Add missing preposition.
2024-06-06 16:37:55 +02:00
Thomas Schwinge 3a4775d440 nvptx, libgfortran: Switch out of "minimal" mode
..., in order to enable (portions of) Fortran I/O, for example.

	libgfortran/
	* configure.ac: No longer set 'LIBGFOR_MINIMAL' for nvptx.
	* configure: Regenerate.
	libgomp/
	* libgomp.texi (nvptx): Update.
	* testsuite/libgomp.fortran/target-print-1-nvptx.f90: Remove.
	* testsuite/libgomp.fortran/target-print-1.f90: Adjust.
	* testsuite/libgomp.oacc-fortran/error_stop-2-nvptx.f: New.
	* testsuite/libgomp.oacc-fortran/error_stop-2.f: Adjust.
	* testsuite/libgomp.oacc-fortran/print-1-nvptx.f90: Adjust.
	* testsuite/libgomp.oacc-fortran/print-1.f90: Adjust.
	* testsuite/libgomp.oacc-fortran/stop-2-nvptx.f: New.
	* testsuite/libgomp.oacc-fortran/stop-2.f: Adjust.

Co-authored-by: Andrew Stubbs <ams@gcc.gnu.org>
2024-06-06 13:41:47 +02:00