Commit Graph

2387 Commits

Author SHA1 Message Date
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
Thomas Schwinge
0d25989d60 nvptx offloading: 'GOMP_NVPTX_NATIVE_GPU_THREAD_STACK_SIZE' environment variable [PR97384, PR105274]
... as a means to manually set the "native" GPU thread stack size.

	PR libgomp/97384
	PR libgomp/105274
	libgomp/
	* plugin/cuda-lib.def (cuCtxSetLimit): Add.
	* plugin/plugin-nvptx.c (nvptx_open_device): Handle
	'GOMP_NVPTX_NATIVE_GPU_THREAD_STACK_SIZE' environment variable.
2024-06-06 13:41:47 +02:00
Thomas Schwinge
5bbe5350a0 nvptx offloading: Global constructor, destructor support, via nvptx-tools 'ld'
This extends commit d9c90c82d9
"nvptx target: Global constructor, destructor support, via nvptx-tools 'ld'"
for offloading.

	libgcc/
	* config/nvptx/gbl-ctors.c ["mgomp"]
	(__do_global_ctors__entry__mgomp)
	(__do_global_dtors__entry__mgomp): New.
	[!"mgomp"] (__do_global_ctors__entry, __do_global_dtors__entry):
	New.
	libgomp/
	* plugin/plugin-nvptx.c (nvptx_do_global_cdtors): New.
	(nvptx_close_device, GOMP_OFFLOAD_load_image)
	(GOMP_OFFLOAD_unload_image): Call it.
2024-06-06 13:41:47 +02:00
Thomas Schwinge
395ac0417a Clean up after newlib "nvptx: In offloading execution, map '_exit' to 'abort' [GCC PR85463]"
PR target/85463
	libgfortran/
	* runtime/minimal.c [__nvptx__] (exit): Don't override.
	libgomp/
	* config/nvptx/error.c (exit): Don't override.
	* testsuite/libgomp.oacc-fortran/error_stop-1.f: Update.
	* testsuite/libgomp.oacc-fortran/error_stop-2.f: Likewise.
	* testsuite/libgomp.oacc-fortran/error_stop-3.f: Likewise.
	* testsuite/libgomp.oacc-fortran/stop-1.f: Likewise.
	* testsuite/libgomp.oacc-fortran/stop-2.f: Likewise.
	* testsuite/libgomp.oacc-fortran/stop-3.f: Likewise.
2024-06-06 13:41:46 +02:00
Jakub Jelinek
6a6bab4ba3 libgomp: Mark Loop transformation constructs as implemented in the implementation status
The implementation has been committed in r15-1037.

2024-06-06  Jakub Jelinek  <jakub@redhat.com>

	* libgomp.texi (OpenMP 5.1 status): Mark Loop transformation constructs
	as implemented.
2024-06-06 08:30:42 +02:00
GCC Administrator
10cb3336ba Daily bump. 2024-06-06 00:16:43 +00:00
Jakub Jelinek
804c0f35a6 openmp: OpenMP loop transformation support
This patch is largely rewritten version of the
https://gcc.gnu.org/pipermail/gcc-patches/2023-October/631764.html
patch set which I've promissed to adjust the way I'd like it but didn't
get to it until now.
The previous series together in diffstat was
 176 files changed, 12107 insertions(+), 298 deletions(-)
This patch is
 197 files changed, 10843 insertions(+), 212 deletions(-)
and diff between the old series and new patch is
 268 files changed, 8053 insertions(+), 9231 deletions(-)

Only the 5.1/5.2 tile/unroll constructs are supported, in various
places some preparations for the other 6.0 loop transformations
constructs (interchange/reverse/fuse) are done, but certainly
not complete and not everywhere.  The important difference is that
because tile/unroll partial map 1:1 the original loops to generated
canonical loops and add another set of generated loops without canonical
form inside of it, the tile/unroll partial constructs are terminal
for the generated loop, one can't have some loops from the tile or
unroll partial and some further loops from inside the body of that
construct.
The GENERIC representation attempts to match what the standard specifies,
so there are separate OMP_TILE and OMP_UNROLL trees.  If for a particular
loop in a loop nest of some OpenMP loop it awaits a generated loop from a
nested loop, or if in OMP_LOOPXFORM_LOWERED OMP_TILE/UNROLL construct
a generated loop has been moved to some surrounding construct, that
particular loop is represented by all NULL_TREEs in the
OMP_FOR_{INIT,COND,INCR,ORIG_DECLS} vector.
The lowering of the loop transforming constructs is done at gimplification
time, at the start of gimplify_omp_for.
I think this way it is more maintainable over magic clauses with various
loop depths on the other looping constructs or the magic OMP_LOOP_TRANS
construct.
Though, I admit I'm still undecided how to represent the OpenMP 6.0
loop transformation case of say:
  #pragma omp for collapse (4)
  for (int i = 0; i < 32; ++i)
  #pragma omp interchange permutation (2, 1)
  #pragma omp reverse
  for (int j = 0; j < 32; ++j)
  #pragma omp reverse
  for (int k = 0; k < 32; ++k)
  for (int l = 0; l < 32; ++l)
    ;
Surely the i loop would go to first vector elements of OMP_FOR_*
of the work-sharing loop, then 2 loops are expecting generated loops
from interchange which would be inside of the body.  But the innermost
l loop isn't part of the interchange, so the question is where to
put it.  One possibility is to have it in the 4th loop of the OMP_FOR,
another possibility would be to add some artificial construct inside
of the OMP_INTERCHANGE and 2 OMP_REVERSE bodies which would contain
the inner loop(s), e.g. it could be OMP_INTERCHANGE without permutation
clause or some artificial ones or whatever.

I've recently raised various unclear things in the 5.1/5.2/TRs versions
regarding loop transformations, in particular
https://github.com/OpenMP/spec/issues/3908
https://github.com/OpenMP/spec/issues/3909
(sorry, private links unless you have OpenMP membership).  Until those
are resolved, I have a sorry on trying to mix generated loops with
non-rectangular loops (way too many questions need to be answered before
that can be done) and similarly for mixing non-perfectly nested loops
with generated loops (again, it can be implemented somehow, but is way
too unclear).  The second issue is mostly about data sharing, which is
ambiguous, the patch makes the artificial iterators of the loops effectively
private in the associated constructs (more like local), but for user
iterators doesn't do anything in particular, so for now one needs to use
explicit data sharing clauses on the non-loop transformation OpenMP looping
constructs or surrounding parallel/task/target etc.

2024-06-05  Jakub Jelinek  <jakub@redhat.com>
	    Frederik Harwath  <frederik@codesourcery.com>
	    Sandra Loosemore  <sandra@codesourcery.com>

gcc/
	* tree.def (OMP_TILE, OMP_UNROLL): New tree codes.
	* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_PARTIAL,
	OMP_CLAUSE_FULL and OMP_CLAUSE_SIZES.
	* tree.h (OMP_LOOPXFORM_CHECK): Define.
	(OMP_LOOPXFORM_LOWERED): Define.
	(OMP_CLAUSE_PARTIAL_EXPR): Define.
	(OMP_CLAUSE_SIZES_LIST): Define.
	* tree.cc (omp_clause_num_ops, omp_clause_code_name): Add entries
	for OMP_CLAUSE_{PARTIAL,FULL,SIZES}.
	* tree-pretty-print.cc (dump_omp_clause): Handle
	OMP_CLAUSE_{PARTIAL,FULL,SIZES}.
	(dump_generic_node): Handle OMP_TILE and OMP_UNROLL.  Skip printing
	loops with NULL OMP_FOR_INIT (node) vector element.
	* gimplify.cc (is_gimple_stmt): Handle OMP_TILE and OMP_UNROLL.
	(gimplify_omp_taskloop_expr): For SAVE_EXPR use gimplify_save_expr.
	(gimplify_omp_loop_xform): New function.
	(gimplify_omp_for): Call omp_maybe_apply_loop_xforms and if that
	reshuffles what the passed pointer points to, retry or return GS_OK.
	Handle OMP_TILE and OMP_UNROLL.
	(gimplify_omp_loop): Call omp_maybe_apply_loop_xforms and if that
	reshuffles what the passed pointer points to, return GS_OK.
	(gimplify_expr): Handle OMP_TILE and OMP_UNROLL.
	* omp-general.h (omp_loop_number_of_iterations,
	omp_maybe_apply_loop_xforms): Declare.
	* omp-general.cc (omp_adjust_for_condition): For LE_EXPR and GE_EXPR
	with pointers, don't add/subtract one, but the size of what the
	pointer points to.
	(omp_loop_number_of_iterations, omp_apply_tile,
	find_nested_loop_xform, omp_maybe_apply_loop_xforms): New functions.
gcc/c-family/
	* c-common.h (c_omp_find_generated_loop): Declare.
	* c-gimplify.cc (c_genericize_control_stmt): Handle OMP_TILE and
	OMP_UNROLL.
	* c-omp.cc (c_finish_omp_for): Handle generated loops.
	(c_omp_is_loop_iterator): Likewise.
	(c_find_nested_loop_xform_r, c_omp_find_generated_loop): New
	functions.
	(c_omp_check_loop_iv): Handle generated loops.  For now sorry
	on mixing non-rectangular loop with generated loops.
	(c_omp_check_loop_binding_exprs): For now sorry on mixing
	imperfect loops with generated loops.
	(c_omp_directives): Uncomment tile and unroll entries.
	* c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_TILE and
	PRAGMA_OMP_UNROLL, change PRAGMA_OMP__LAST_ to the latter.
	(enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_FULL and
	PRAGMA_OMP_CLAUSE_PARTIAL.
	* c-pragma.cc (omp_pragmas_simd): Add tile and unroll omp pragmas.
gcc/c/
	* c-parser.cc (c_parser_skip_std_attribute_spec_seq): New function.
	(check_omp_intervening_code): Reject imperfectly nested tile.
	(c_parser_compound_statement_nostart): If want_nested_loop, use
	c_parser_omp_next_tokens_can_be_canon_loop instead of just checking
	for RID_FOR keyword.
	(c_parser_omp_clause_name): Handle full and partial clause names.
	(c_parser_omp_clause_allocate): Remove spurious semicolon.
	(c_parser_omp_clause_full, c_parser_omp_clause_partial): New
	functions.
	(c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_FULL and
	PRAGMA_OMP_CLAUSE_PARTIAL.
	(c_parser_omp_next_tokens_can_be_canon_loop): New function.
	(c_parser_omp_loop_nest): Parse C23 attributes.  Handle tile/unroll
	constructs.  Use c_parser_omp_next_tokens_can_be_canon_loop instead
	of just checking for RID_FOR keyword.  Only add_stmt (body) if it is
	non-NULL.
	(c_parser_omp_for_loop): Rename tiling variable to oacc_tiling.  For
	OMP_CLAUSE_SIZES set collapse to list length of OMP_CLAUSE_SIZES_LIST.
	Use c_parser_omp_next_tokens_can_be_canon_loop instead of just
	checking for RID_FOR keyword.  Remove spurious semicolon.  Don't call
	c_omp_check_loop_binding_exprs if stmt is NULL.  Skip generated loops.
	(c_parser_omp_tile_sizes, c_parser_omp_tile): New functions.
	(OMP_UNROLL_CLAUSE_MASK): Define.
	(c_parser_omp_unroll): New function.
	(c_parser_omp_construct): Handle PRAGMA_OMP_TILE and
	PRAGMA_OMP_UNROLL.
	* c-typeck.cc (c_finish_omp_clauses): Adjust wording of some of the
	conflicting clause diagnostic messages to include word clause.
	Handle OMP_CLAUSE_{FULL,PARTIAL,SIZES} and diagnose full vs. partial
	conflict.
gcc/cp/
	* cp-tree.h (dependent_omp_for_p): Add another tree argument.
	* parser.cc (check_omp_intervening_code): Reject imperfectly nested
	tile.
	(cp_parser_statement_seq_opt): If want_nested_loop, use
	cp_parser_next_tokens_can_be_canon_loop instead of just checking
	for RID_FOR keyword.
	(cp_parser_omp_clause_name): Handle full and partial clause names.
	(cp_parser_omp_clause_full, cp_parser_omp_clause_partial): New
	functions.
	(cp_parser_omp_all_clauses): Formatting fix.  Handle
	PRAGMA_OMP_CLAUSE_PARTIAL and PRAGMA_OMP_CLAUSE_FULL.
	(cp_parser_next_tokens_can_be_canon_loop): New function.
	(cp_parser_omp_loop_nest): Parse C++11 attributes.  Handle tile/unroll
	constructs.  Use cp_parser_next_tokens_can_be_canon_loop instead
	of just checking for RID_FOR keyword.  Only add_stmt
	cp_parser_omp_loop_nest result if it is non-NULL.
	(cp_parser_omp_for_loop): Rename tiling variable to oacc_tiling.  For
	OMP_CLAUSE_SIZES set collapse to list length of OMP_CLAUSE_SIZES_LIST.
	Use cp_parser_next_tokens_can_be_canon_loop instead of just
	checking for RID_FOR keyword.  Remove spurious semicolon.  Don't call
	c_omp_check_loop_binding_exprs if stmt is NULL.  Skip and/or handle
	generated loops.  Remove spurious ()s around & operands.
	(cp_parser_omp_tile_sizes, cp_parser_omp_tile): New functions.
	(OMP_UNROLL_CLAUSE_MASK): Define.
	(cp_parser_omp_unroll): New function.
	(cp_parser_omp_construct): Handle PRAGMA_OMP_TILE and
	PRAGMA_OMP_UNROLL.
	(cp_parser_pragma): Likewise.
	* semantics.cc (finish_omp_clauses): Don't call
	fold_build_cleanup_point_expr for cases which obviously won't need it,
	like checked INTEGER_CSTs.  Handle OMP_CLAUSE_{FULL,PARTIAL,SIZES}
	and diagnose full vs. partial conflict.  Adjust wording of some of the
	conflicting clause diagnostic messages to include word clause.
	(finish_omp_for): Use decl equal to global_namespace as a marker for
	generated loop.  Pass also body to dependent_omp_for_p.  Skip
	generated loops.
	(finish_omp_for_block): Skip generated loops.
	* pt.cc (tsubst_omp_clauses): Handle OMP_CLAUSE_{FULL,PARTIAL,SIZES}.
	(tsubst_stmt): Handle OMP_TILE and OMP_UNROLL.  Handle or skip
	generated loops.
	(dependent_omp_for_p): Add body argument.  If declv vector element
	is NULL, find generated loop.
	* cp-gimplify.cc (cp_gimplify_expr): Handle OMP_TILE and OMP_UNROLL.
	(cp_fold_r): Likewise.
	(cp_genericize_r): Likewise.  Skip generated loops.
gcc/fortran/
	* gfortran.h (enum gfc_statement): Add ST_OMP_UNROLL,
	ST_OMP_END_UNROLL, ST_OMP_TILE and ST_OMP_END_TILE.
	(struct gfc_omp_clauses): Add sizes_list, partial, full and erroneous
	members.
	(enum gfc_exec_op): Add EXEC_OMP_UNROLL and EXEC_OMP_TILE.
	(gfc_expr_list_len): Declare.
	* match.h (gfc_match_omp_tile, gfc_match_omp_unroll): Declare.
	* openmp.cc (gfc_get_location): Declare.
	(gfc_free_omp_clauses): Free sizes_list.
	(match_oacc_expr_list): Rename to ...
	(match_omp_oacc_expr_list): ... this.  Add is_omp argument and
	change diagnostic wording if it is true.
	(enum omp_mask2): Add OMP_CLAUSE_{FULL,PARTIAL,SIZES}.
	(gfc_match_omp_clauses): Parse full, partial and sizes clauses.
	(gfc_match_oacc_wait): Use match_omp_oacc_expr_list instead of
	match_oacc_expr_list.
	(OMP_UNROLL_CLAUSES, OMP_TILE_CLAUSES): Define.
	(gfc_match_omp_tile, gfc_match_omp_unroll): New functions.
	(resolve_omp_clauses): Diagnose full vs. partial clause conflict.
	Resolve sizes clause arguments.
	(find_nested_loop_in_chain): Use switch instead of series of ifs.
	Handle EXEC_OMP_TILE and EXEC_OMP_UNROLL.
	(gfc_resolve_omp_do_blocks): Set omp_current_do_collapse to
	list length of sizes_list if present.
	(gfc_resolve_do_iterator): Return for EXEC_OMP_TILE or
	EXEC_OMP_UNROLL.
	(restructure_intervening_code): Remove spurious ()s around & operands.
	(is_outer_iteration_variable): Handle EXEC_OMP_TILE and
	EXEC_OMP_UNROLL.
	(check_nested_loop_in_chain): Likewise.
	(expr_is_invariant): Likewise.
	(resolve_omp_do): Handle EXEC_OMP_TILE and EXEC_OMP_UNROLL.  Diagnose
	tile without sizes clause.  Use sizes_list length for count if
	non-NULL.  Set code->ext.omp_clauses->erroneous on loops where we've
	reported diagnostics.  Sorry for mixing non-rectangular loops with
	generated loops.
	(omp_code_to_statement): Handle EXEC_OMP_TILE and EXEC_OMP_UNROLL.
	(gfc_resolve_omp_directive): Likewise.
	* parse.cc (decode_omp_directive): Parse end tile, end unroll, tile
	and unroll.  Move nothing entry alphabetically.
	(case_exec_markers): Add ST_OMP_TILE and ST_OMP_UNROLL.
	(gfc_ascii_statement): Handle ST_OMP_END_TILE, ST_OMP_END_UNROLL,
	ST_OMP_TILE and ST_OMP_UNROLL.
	(parse_omp_do): Add nested argument.  Handle ST_OMP_TILE and
	ST_OMP_UNROLL.
	(parse_omp_structured_block): Adjust parse_omp_do caller.
	(parse_executable): Likewise.  Handle ST_OMP_TILE and ST_OMP_UNROLL.
	* resolve.cc (gfc_resolve_blocks): Handle EXEC_OMP_TILE and
	EXEC_OMP_UNROLL.
	(gfc_resolve_code): Likewise.
	* st.cc (gfc_free_statement): Likewise.
	* trans.cc (trans_code): Likewise.
	* trans-openmp.cc (gfc_trans_omp_clauses): Handle full, partial and
	sizes clauses.  Use tree_cons + nreverse instead of
	temporary vector and build_tree_list_vec for tile_list handling.
	(gfc_expr_list_len): New function.
	(gfc_trans_omp_do): Rename tile to oacc_tile.  Handle sizes clause.
	Don't assert code->op is EXEC_DO.  Handle EXEC_OMP_TILE and
	EXEC_OMP_UNROLL.
	(gfc_trans_omp_directive): Handle EXEC_OMP_TILE and EXEC_OMP_UNROLL.
	* dump-parse-tree.cc (show_omp_clauses): Dump full, partial and
	sizes clauses.
	(show_omp_node): Handle EXEC_OMP_TILE and EXEC_OMP_UNROLL.
	(show_code_node): Likewise.
gcc/testsuite/
	* c-c++-common/gomp/attrs-tile-1.c: New test.
	* c-c++-common/gomp/attrs-tile-2.c: New test.
	* c-c++-common/gomp/attrs-tile-3.c: New test.
	* c-c++-common/gomp/attrs-tile-4.c: New test.
	* c-c++-common/gomp/attrs-tile-5.c: New test.
	* c-c++-common/gomp/attrs-tile-6.c: New test.
	* c-c++-common/gomp/attrs-unroll-1.c: New test.
	* c-c++-common/gomp/attrs-unroll-2.c: New test.
	* c-c++-common/gomp/attrs-unroll-3.c: New test.
	* c-c++-common/gomp/attrs-unroll-inner-1.c: New test.
	* c-c++-common/gomp/attrs-unroll-inner-2.c: New test.
	* c-c++-common/gomp/attrs-unroll-inner-3.c: New test.
	* c-c++-common/gomp/attrs-unroll-inner-4.c: New test.
	* c-c++-common/gomp/attrs-unroll-inner-5.c: New test.
	* c-c++-common/gomp/imperfect-attributes.c: Adjust expected
	diagnostics.
	* c-c++-common/gomp/imperfect-loop-nest.c: New test.
	* c-c++-common/gomp/ordered-5.c: New test.
	* c-c++-common/gomp/scan-7.c: New test.
	* c-c++-common/gomp/tile-1.c: New test.
	* c-c++-common/gomp/tile-2.c: New test.
	* c-c++-common/gomp/tile-3.c: New test.
	* c-c++-common/gomp/tile-4.c: New test.
	* c-c++-common/gomp/tile-5.c: New test.
	* c-c++-common/gomp/tile-6.c: New test.
	* c-c++-common/gomp/tile-7.c: New test.
	* c-c++-common/gomp/tile-8.c: New test.
	* c-c++-common/gomp/tile-9.c: New test.
	* c-c++-common/gomp/tile-10.c: New test.
	* c-c++-common/gomp/tile-11.c: New test.
	* c-c++-common/gomp/tile-12.c: New test.
	* c-c++-common/gomp/tile-13.c: New test.
	* c-c++-common/gomp/tile-14.c: New test.
	* c-c++-common/gomp/tile-15.c: New test.
	* c-c++-common/gomp/unroll-1.c: New test.
	* c-c++-common/gomp/unroll-2.c: New test.
	* c-c++-common/gomp/unroll-3.c: New test.
	* c-c++-common/gomp/unroll-4.c: New test.
	* c-c++-common/gomp/unroll-5.c: New test.
	* c-c++-common/gomp/unroll-6.c: New test.
	* c-c++-common/gomp/unroll-7.c: New test.
	* c-c++-common/gomp/unroll-8.c: New test.
	* c-c++-common/gomp/unroll-9.c: New test.
	* c-c++-common/gomp/unroll-inner-1.c: New test.
	* c-c++-common/gomp/unroll-inner-2.c: New test.
	* c-c++-common/gomp/unroll-inner-3.c: New test.
	* c-c++-common/gomp/unroll-non-rect-1.c: New test.
	* c-c++-common/gomp/unroll-non-rect-2.c: New test.
	* c-c++-common/gomp/unroll-non-rect-3.c: New test.
	* c-c++-common/gomp/unroll-simd-1.c: New test.
	* gcc.dg/gomp/attrs-4.c: Adjust expected diagnostics.
	* gcc.dg/gomp/for-1.c: Likewise.
	* gcc.dg/gomp/for-11.c: Likewise.
	* g++.dg/gomp/attrs-4.C: Likewise.
	* g++.dg/gomp/for-1.C: Likewise.
	* g++.dg/gomp/pr94512.C: Likewise.
	* g++.dg/gomp/tile-1.C: New test.
	* g++.dg/gomp/tile-2.C: New test.
	* g++.dg/gomp/unroll-1.C: New test.
	* g++.dg/gomp/unroll-2.C: New test.
	* g++.dg/gomp/unroll-3.C: New test.
	* gfortran.dg/gomp/inner-loops-1.f90: New test.
	* gfortran.dg/gomp/inner-loops-2.f90: New test.
	* gfortran.dg/gomp/pure-1.f90: Add tests for !$omp unroll
	and !$omp tile.
	* gfortran.dg/gomp/pure-2.f90: Remove those tests from here.
	* gfortran.dg/gomp/scan-9.f90: New test.
	* gfortran.dg/gomp/tile-1.f90: New test.
	* gfortran.dg/gomp/tile-2.f90: New test.
	* gfortran.dg/gomp/tile-3.f90: New test.
	* gfortran.dg/gomp/tile-4.f90: New test.
	* gfortran.dg/gomp/tile-5.f90: New test.
	* gfortran.dg/gomp/tile-6.f90: New test.
	* gfortran.dg/gomp/tile-7.f90: New test.
	* gfortran.dg/gomp/tile-8.f90: New test.
	* gfortran.dg/gomp/tile-9.f90: New test.
	* gfortran.dg/gomp/tile-10.f90: New test.
	* gfortran.dg/gomp/tile-imperfect-nest-1.f90: New test.
	* gfortran.dg/gomp/tile-imperfect-nest-2.f90: New test.
	* gfortran.dg/gomp/tile-inner-loops-1.f90: New test.
	* gfortran.dg/gomp/tile-inner-loops-2.f90: New test.
	* gfortran.dg/gomp/tile-inner-loops-3.f90: New test.
	* gfortran.dg/gomp/tile-inner-loops-4.f90: New test.
	* gfortran.dg/gomp/tile-inner-loops-5.f90: New test.
	* gfortran.dg/gomp/tile-inner-loops-6.f90: New test.
	* gfortran.dg/gomp/tile-inner-loops-7.f90: New test.
	* gfortran.dg/gomp/tile-inner-loops-8.f90: New test.
	* gfortran.dg/gomp/tile-non-rectangular-1.f90: New test.
	* gfortran.dg/gomp/tile-non-rectangular-2.f90: New test.
	* gfortran.dg/gomp/tile-non-rectangular-3.f90: New test.
	* gfortran.dg/gomp/tile-unroll-1.f90: New test.
	* gfortran.dg/gomp/tile-unroll-2.f90: New test.
	* gfortran.dg/gomp/unroll-1.f90: New test.
	* gfortran.dg/gomp/unroll-2.f90: New test.
	* gfortran.dg/gomp/unroll-3.f90: New test.
	* gfortran.dg/gomp/unroll-4.f90: New test.
	* gfortran.dg/gomp/unroll-5.f90: New test.
	* gfortran.dg/gomp/unroll-6.f90: New test.
	* gfortran.dg/gomp/unroll-7.f90: New test.
	* gfortran.dg/gomp/unroll-8.f90: New test.
	* gfortran.dg/gomp/unroll-9.f90: New test.
	* gfortran.dg/gomp/unroll-10.f90: New test.
	* gfortran.dg/gomp/unroll-11.f90: New test.
	* gfortran.dg/gomp/unroll-12.f90: New test.
	* gfortran.dg/gomp/unroll-13.f90: New test.
	* gfortran.dg/gomp/unroll-inner-loop-1.f90: New test.
	* gfortran.dg/gomp/unroll-inner-loop-2.f90: New test.
	* gfortran.dg/gomp/unroll-no-clause-1.f90: New test.
	* gfortran.dg/gomp/unroll-non-rect-1.f90: New test.
	* gfortran.dg/gomp/unroll-non-rect-2.f90: New test.
	* gfortran.dg/gomp/unroll-simd-1.f90: New test.
	* gfortran.dg/gomp/unroll-simd-2.f90: New test.
	* gfortran.dg/gomp/unroll-simd-3.f90: New test.
	* gfortran.dg/gomp/unroll-tile-1.f90: New test.
	* gfortran.dg/gomp/unroll-tile-2.f90: New test.
	* gfortran.dg/gomp/unroll-tile-inner-1.f90: New test.
libgomp/
	* testsuite/libgomp.c-c++-common/imperfect-transform-1.c: New test.
	* testsuite/libgomp.c-c++-common/imperfect-transform-2.c: New test.
	* testsuite/libgomp.c-c++-common/matrix-1.h: New test.
	* testsuite/libgomp.c-c++-common/matrix-constant-iter.h: New test.
	* testsuite/libgomp.c-c++-common/matrix-helper.h: New test.
	* testsuite/libgomp.c-c++-common/matrix-no-directive-1.c: New test.
	* testsuite/libgomp.c-c++-common/matrix-no-directive-unroll-full-1.c:
	New test.
	* testsuite/libgomp.c-c++-common/matrix-omp-distribute-parallel-for-1.c:
	New test.
	* testsuite/libgomp.c-c++-common/matrix-omp-for-1.c: New test.
	* testsuite/libgomp.c-c++-common/matrix-omp-parallel-for-1.c: New test.
	* testsuite/libgomp.c-c++-common/matrix-omp-parallel-masked-taskloop-1.c:
	New test.
	* testsuite/libgomp.c-c++-common/matrix-omp-parallel-masked-taskloop-simd-1.c:
	New test.
	* testsuite/libgomp.c-c++-common/matrix-omp-target-parallel-for-1.c:
	New test.
	* testsuite/libgomp.c-c++-common/matrix-omp-target-teams-distribute-parallel-for-1.c:
	New test.
	* testsuite/libgomp.c-c++-common/matrix-omp-taskloop-1.c: New test.
	* testsuite/libgomp.c-c++-common/matrix-omp-teams-distribute-parallel-for-1.c:
	New test.
	* testsuite/libgomp.c-c++-common/matrix-simd-1.c: New test.
	* testsuite/libgomp.c-c++-common/matrix-transform-variants-1.h:
	New test.
	* testsuite/libgomp.c-c++-common/target-imperfect-transform-1.c:
	New test.
	* testsuite/libgomp.c-c++-common/target-imperfect-transform-2.c:
	New test.
	* testsuite/libgomp.c-c++-common/unroll-1.c: New test.
	* testsuite/libgomp.c-c++-common/unroll-non-rect-1.c: New test.
	* testsuite/libgomp.c++/matrix-no-directive-unroll-full-1.C: New test.
	* testsuite/libgomp.c++/tile-2.C: New test.
	* testsuite/libgomp.c++/tile-3.C: New test.
	* testsuite/libgomp.c++/unroll-1.C: New test.
	* testsuite/libgomp.c++/unroll-2.C: New test.
	* testsuite/libgomp.c++/unroll-full-tile.C: New test.
	* testsuite/libgomp.fortran/imperfect-transform-1.f90: New test.
	* testsuite/libgomp.fortran/imperfect-transform-2.f90: New test.
	* testsuite/libgomp.fortran/inner-1.f90: New test.
	* testsuite/libgomp.fortran/nested-fn.f90: New test.
	* testsuite/libgomp.fortran/target-imperfect-transform-1.f90: New test.
	* testsuite/libgomp.fortran/target-imperfect-transform-2.f90: New test.
	* testsuite/libgomp.fortran/tile-1.f90: New test.
	* testsuite/libgomp.fortran/tile-2.f90: New test.
	* testsuite/libgomp.fortran/tile-unroll-1.f90: New test.
	* testsuite/libgomp.fortran/tile-unroll-2.f90: New test.
	* testsuite/libgomp.fortran/tile-unroll-3.f90: New test.
	* testsuite/libgomp.fortran/tile-unroll-4.f90: New test.
	* testsuite/libgomp.fortran/unroll-1.f90: New test.
	* testsuite/libgomp.fortran/unroll-2.f90: New test.
	* testsuite/libgomp.fortran/unroll-3.f90: New test.
	* testsuite/libgomp.fortran/unroll-4.f90: New test.
	* testsuite/libgomp.fortran/unroll-5.f90: New test.
	* testsuite/libgomp.fortran/unroll-6.f90: New test.
	* testsuite/libgomp.fortran/unroll-7a.f90: New test.
	* testsuite/libgomp.fortran/unroll-7b.f90: New test.
	* testsuite/libgomp.fortran/unroll-7c.f90: New test.
	* testsuite/libgomp.fortran/unroll-7.f90: New test.
	* testsuite/libgomp.fortran/unroll-8.f90: New test.
	* testsuite/libgomp.fortran/unroll-simd-1.f90: New test.
	* testsuite/libgomp.fortran/unroll-tile-1.f90: New test.
	* testsuite/libgomp.fortran/unroll-tile-2.f90: New test.
2024-06-05 19:10:26 +02:00
GCC Administrator
3c75a4c03d Daily bump. 2024-06-01 00:17:20 +00:00
Rainer Orth
7e322d576e testsuite: Adjust several dg-additional-files-options calls [PR115294]
A recent patch

commit bdc264a16e
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Thu May 30 02:06:48 2024 -0300

    [testsuite] conditionalize dg-additional-sources on target and type

added two additional args to dg-additional-files-options.
Unfortunately, this completely broke several testsuites like

ERROR: tcl error sourcing /vol/gcc/src/hg/master/local/libatomic/testsuite/../../gcc/testsuite/lib/gcc-dg.exp.
wrong # args: should be "dg-additional-files-options options source dest type"

since the patch forgot to adjust some of the callers.

This patch fixes that.

Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11, and
x86_64-pc-linux-gnu.

2024-05-31  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libatomic:
	PR testsuite/115294
	* testsuite/lib/libatomic.exp (libatomic_target_compile): Pass new
	dg-additional-files-options args.

	libgomp:
	PR testsuite/115294
	* testsuite/lib/libgomp.exp (libgomp_target_compile): Pass new
	dg-additional-files-options args.

	libitm:
	PR testsuite/115294
	* testsuite/lib/libitm.exp (libitm_target_compile): Pass new
	dg-additional-files-options args.

	libphobos:
	PR testsuite/115294
	* testsuite/lib/libphobos.exp (libphobos_target_compile): Pass new
	dg-additional-files-options args.

	libvtv:
	PR testsuite/115294
	* testsuite/lib/libvtv.exp (libvtv_target_compile): Pass new
	dg-additional-files-options args.
2024-05-31 09:29:38 +02:00
GCC Administrator
0ab643555c Daily bump. 2024-05-31 00:17:38 +00:00
Tobias Burnus
370df6ef0f libgomp.texi: Impl. update for USM and missing 5.2 item
libgomp/ChangeLog:

	* libgomp.texi (OpenMP 5.0 status): Mark 'requires' as done and
	link to 'Offload-Target Specifics'.
	(OpenMP 5.2 status): Add item about additional map-type modifiers
	in 'declare mapper'.
2024-05-30 13:21:43 +02:00
GCC Administrator
d815d9ad89 Daily bump. 2024-05-30 00:16:44 +00:00
Tobias Burnus
18f477980c libgomp: Enable USM for AMD APUs and MI200 devices
If HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT is true,
all GPUs on the system support unified shared memory. That's
the case for APUs and MI200 devices when XNACK is enabled.

XNACK can be enabled by setting HSA_XNACK=1 as env var for
supported devices; otherwise, if disable, USM code will
use host fallback.

gcc/ChangeLog:

	* config/gcn/gcn-hsa.h (gcn_local_sym_hash): Fix typo.

include/ChangeLog:

	* hsa.h (HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT): Add
	enum value.

libgomp/ChangeLog:

	* libgomp.texi (gcn): Update USM handling
	* plugin/plugin-gcn.c (GOMP_OFFLOAD_get_num_devices): Handle
	USM if HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT is true.
2024-05-29 15:29:06 +02:00
Tobias Burnus
4ccb3366ad libgomp: Enable USM for some nvptx devices
A few high-end nvptx devices support the attribute
CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS; for those, unified shared
memory is supported in hardware. This patch enables support for those -
if all installed nvptx devices have this feature (as the capabilities
are per device type).

This exposes a bug in gomp_copy_back_icvs as it did before use
omp_get_mapped_ptr to find mapped variables, but that returns
the unchanged pointer in cased of shared memory. But in this case,
we have a few actually mapped pointers - like the ICV variables.
Additionally, there was a mismatch with regards to '-1' for the
device number as gomp_copy_back_icvs and omp_get_mapped_ptr count
differently. Hence, do the lookup manually.

include/ChangeLog:

	* cuda/cuda.h (CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS): Add.

libgomp/ChangeLog:

	* libgomp.texi (nvptx): Update USM description.
	* plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_num_devices):
	Claim support when requesting USM and all devices support
	CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS.
	* target.c (gomp_copy_back_icvs): Fix device ptr lookup.
	(gomp_target_init): Set GOMP_OFFLOAD_CAP_SHARED_MEM is the
	devices supports USM.
2024-05-29 15:14:38 +02:00
GCC Administrator
d508d70836 Daily bump. 2024-05-09 10:58:01 +00:00
Rainer Orth
35b05a02de build: Derive object names in make_sunver.pl
The recent move of libgfortran object files to subdirs and the resulting
breakage of libgfortran.so symbol exports demonstrated how fragile
deriving object and archive names from their libtool counterparts in the
Makefiles is.  Therefore, this patch moves that step into
make_sunver.pl, considerably simplifying the Makefile rules to create
the version scripts.

Bootstrapped without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11, verifying that the version scripts are identical
except for the input filenames.

2024-05-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	contrib:
	* make_sunver.pl: Use File::Basename;
	Skip -lLIB args.
	Convert libtool object/archive names to underlying
	objects/archives.

	libatomic:
	* Makefile.am [LIBAT_BUILD_VERSIONED_SHLIB_SUN]
	(libatomic.map-sun): Pass $(libatomic_la_OBJECTS),
	$(libatomic_la_LIBADD) to make_sunver.pl unmodified.
	* Makefile.in: Regenerate.

	libffi:
	* Makefile.am [LIBFFI_BUILD_VERSIONED_SHLIB_SUN] (libffi.map-sun):
	Pass $(libffi_la_OBJECTS), $(libffi_la_LIBADD) to make_sunver.pl
	unmodified.
	* Makefile.in: Regenerate.

	libgfortran:
	* Makefile.am [LIBGFOR_USE_SYMVER_SUN} (gfortran.ver-sun): Pass
	$(libgfortran_la_OBJECTS), $(libgfortran_la_LIBADD) to
	make_sunver.pl unmodified.
	* Makefile.in: Regenerate.

	libgomp:
	* Makefile.am [LIBGOMP_BUILD_VERSIONED_SHLIB_SUN]
	(libgomp.ver-sun): Pass $(libgomp_la_OBJECTS),
	$(libgomp_la_LIBADD) to make_sunver.pl unmodified.
	* Makefile.in: Regenerate.

	libitm:
	* Makefile.am [LIBITM_BUILD_VERSIONED_SHLIB_SUN] (libitm.map-sun):
	Pass $(libitm_la_OBJECTS), $(libitm_la_LIBADD) to make_sunver.pl
	unmodified.
	* Makefile.in: Regenerate.

	libquadmath:
	* Makefile.am [LIBQUAD_USE_SYMVER_SUN] (quadmath.map-sun): Pass
	$(libquadmath_la_OBJECTS), $(libquadmath_la_LIBADD) to
	make_sunver.pl unmodified.
	* Makefile.in: Regenerate.

	libssp:
	* Makefile.am [LIBSSP_USE_SYMVER_SUN] (ssp.map-sun): Pass
	$(libssp_la_OBJECTS), $(libssp_la_LIBADD) to make_sunver.pl
	unmodified.
	* Makefile.in: Regenerate.

	libstdc++-v3:
	* src/Makefile.am [ENABLE_SYMVERS_SUN]
	(libstdc++-symbols.ver-sun): Pass $(libstdc___la_OBJECTS),
	$(libstdc___la_LIBADD) to make_sunver.pl unmodified.
	* src/Makefile.in: Regenerate.
2024-05-07 13:14:05 +02:00
GCC Administrator
f2d0116090 Daily bump. 2024-05-03 00:17:26 +00:00
Jakub Jelinek
5eb25d1561 libgomp: Add gfx90c, 1036 and 1103 declare variant tests
Recently -march=gfx{90c,1036,1103} support has been added, but corresponding
changes weren't done in the testsuite.

The following patch adds that.

Tested on x86_64-linux (with fiji and gfx1103 devices; had to use
OMP_DEFAULT_DEVICE=1 there, fiji doesn't really work due to LLVM dropping
support, but we still list those as offloading devices).

2024-05-02  Jakub Jelinek  <jakub@redhat.com>

	* testsuite/libgomp.c/declare-variant-4.h (gfx90c, gfx1036, gfx1103):
	New functions.
	(f): Add #pragma omp declare variant directives for those.
	* testsuite/libgomp.c/declare-variant-4-gfx90c.c: New test.
	* testsuite/libgomp.c/declare-variant-4-gfx1036.c: New test.
	* testsuite/libgomp.c/declare-variant-4-gfx1103.c: New test.
2024-05-02 11:56:16 +02:00
GCC Administrator
2781d8090e Daily bump. 2024-04-27 00:18:05 +00:00
Frederik Harwath
b8e9fd535d amdgcn: Add gfx90c target
Add support for gfx90c GCN5 APU integrated graphics devices.
The LLVM AMDGPU documentation does not list those devices as supported
by rocm-amdhsa, but it passes most libgomp offloading tests.
Although they are constrainted compared to dGPUs, they might be
interesting for learning, experimentation, and testing.

gcc/ChangeLog:

	* config.gcc: Add gfx90c.
	* config/gcn/gcn-hsa.h (NO_SRAM_ECC): Likewise.
	* config/gcn/gcn-opts.h (enum processor_type): Likewise.
	(TARGET_GFX90c): New macro.
	* config/gcn/gcn.cc (gcn_option_override): Handle gfx90c.
	(gcn_omp_device_kind_arch_isa): Likewise.
	(output_file_start): Likewise.
	* config/gcn/gcn.h: Add gfx90c.
	* config/gcn/gcn.opt: Likewise.
	* config/gcn/mkoffload.cc (EF_AMDGPU_MACH_AMDGCN_GFX90c): New macro.
	(get_arch): Handle gfx90c.
	(main): Handle EF_AMDGPU_MACH_AMDGCN_GFX90c
	* config/gcn/t-omp-device: Add gfx90c.
	* doc/install.texi: Likewise.
	* doc/invoke.texi: Likewise.

libgomp/ChangeLog:

	* plugin/plugin-gcn.c (isa_hsa_name): Handle EF_AMDGPU_MACH_AMDGCN_GFX90c.
	(isa_code): Handle gfx90c.
	(max_isa_vgprs): Handle EF_AMDGPU_MACH_AMDGCN_GFX90c.

Signed-off-by: Frederik Harwath <frederik@harwath.name>
2024-04-26 11:23:43 +02:00
GCC Administrator
9c7cf5d71f Daily bump. 2024-04-17 00:18:45 +00:00
Chung-Lin Tang
a7578a077e OpenACC 2.7: Adjust acc_map_data/acc_unmap_data interaction with reference counters
This patch adjusts the implementation of acc_map_data/acc_unmap_data API library
routines to more fit the description in the OpenACC 2.7 specification.

Instead of using REFCOUNT_INFINITY, we now define a REFCOUNT_ACC_MAP_DATA
special value to mark acc_map_data-created mappings. Adjustment around
mapping related code to respect OpenACC semantics are also added.

libgomp/ChangeLog:

	* libgomp.h (REFCOUNT_ACC_MAP_DATA): Define as (REFCOUNT_SPECIAL | 2).
	* oacc-mem.c (acc_map_data): Adjust to use REFCOUNT_ACC_MAP_DATA,
	initialize dynamic_refcount as 1.
	(acc_unmap_data): Adjust to use REFCOUNT_ACC_MAP_DATA,
	(goacc_map_var_existing): Add REFCOUNT_ACC_MAP_DATA case.
	(goacc_exit_datum_1): Add REFCOUNT_ACC_MAP_DATA case, respect
	REFCOUNT_ACC_MAP_DATA when decrementing/finalizing. Force lowest
	dynamic_refcount to be 1 for REFCOUNT_ACC_MAP_DATA.
	(goacc_enter_data_internal): Add REFCOUNT_ACC_MAP_DATA case.
	* target.c (gomp_increment_refcount): Return early for
	REFCOUNT_ACC_MAP_DATA case.
	(gomp_decrement_refcount): Likewise.
	* testsuite/libgomp.oacc-c-c++-common/lib-96.c: New testcase.
	* testsuite/libgomp.oacc-c-c++-common/unmap-infinity-1.c: Adjust
	testcase error output scan test.
2024-04-16 09:04:11 +00:00
GCC Administrator
45532e3a92 Daily bump. 2024-04-09 00:17:24 +00:00
Thomas Schwinge
a02d7f0edc GCN, nvptx: Errors during device probing are fatal
Currently, we silently disable libgomp GCN and nvptx plugins/devices in
presence of certain error conditions during device probing, thus typically
silently resorting to host-fallback execution.  Make such errors fatal, similar
as for any other device access later on, so that we early and reliably notice
when things go wrong.  (Keep just two cases non-fatal: (a) libgomp GCN or nvptx
plugins are available but 'libhsa-runtime64.so.1' or 'libcuda.so.1' are not,
and (b) those are available, but the corresponding devices are not.)

This resolves the issue that we've got execution test cases unexpectedly
PASSing, despite:

    libgomp: GCN fatal error: Run-time could not be initialized
    Runtime message: HSA_STATUS_ERROR_OUT_OF_RESOURCES: The runtime failed to allocate the necessary resources. This error may also occur when the core runtime library needs to spawn threads or create internal OS-specific events.

..., and therefore they were not offloaded to the GCN device, but ran in
host-fallback execution mode.  What happend in that scenario is that in
'init_hsa_context' during the initial 'GOMP_OFFLOAD_get_num_devices' we ran
into 'HSA_STATUS_ERROR_OUT_OF_RESOURCES', but it wasn't fatal, but just
silently disabled the libgomp plugin/device.

Especially "entertaining" were cases where such unintended host-fallback
execution happened during effective-target checks like
'offload_device_available' (host-fallback execution there meaning: no offload
device available), but actual test cases then were running with an offload
device available, and therefore mis-configured.

	include/
	* cuda/cuda.h (CUresult): Add 'CUDA_ERROR_NO_DEVICE'.
	libgomp/
	* plugin/plugin-gcn.c (init_hsa_context): Add and handle
	'bool probe' parameter.  Adjust all users; errors during device
	probing are fatal.
	* plugin/plugin-nvptx.c (nvptx_get_num_devices): Aside from
	'CUDA_ERROR_NO_DEVICE', errors during device probing are fatal.
2024-04-08 22:08:00 +02:00
GCC Administrator
1a96eb0a43 Daily bump. 2024-04-08 12:15:19 +00:00
Thomas Schwinge
679f81a32f nvptx: In mkoffload.cc, call diagnostic_color_init + gcc_init_libintl: Restore 'libgomp.c/reverse-offload-sm30.c' testing
With commit 7520a4992c
"nvptx: In mkoffload.cc, call diagnostic_color_init + gcc_init_libintl",
we regressed:

    [-PASS:-]{+FAIL:+} libgomp.c/reverse-offload-sm30.c  at line 15 (test for warnings, line )
    [-PASS:-]{+FAIL:+} libgomp.c/reverse-offload-sm30.c (test for excess errors)

	libgomp/
	* testsuite/libgomp.c/reverse-offload-sm30.c: Set 'GCC_COLORS' to the empty string.
2024-04-05 14:11:16 +02:00
Jakub Jelinek
592536eb3c c++: Fix ICE with weird copy assignment operator [PR114572]
While ctors/dtors don't return anything (undeclared void or this pointer
on arm) and copy assignment operators normally return a reference to *this,
it isn't invalid to return uselessly some class object which might need
destructing, but the OpenMP clause handling code wasn't expecting that.

The following patch fixes that.

2024-04-05  Jakub Jelinek  <jakub@redhat.com>

	PR c++/114572
	* cp-gimplify.cc (cxx_omp_clause_apply_fn): Call build_cplus_new
	on build_call_a result if it has class type.

	* testsuite/libgomp.c++/pr114572.C: New test.
2024-04-05 09:31:28 +02:00
GCC Administrator
5192e72e7e Daily bump. 2024-04-05 00:16:44 +00:00
Tobias Burnus
1c89d1b9dc libgomp.texi: Update entries in OpenMP TR12 implementation status
libgomp/ChangeLog:

	* libgomp.texi (TR12): Honor post-TR12 directive name change; add
	item about curly braces/BLOCK permitted in canonical loop nests.
2024-04-04 12:20:48 +02:00
GCC Administrator
a1e6798acf Daily bump. 2024-04-03 00:17:29 +00:00
Jakub Jelinek
94792057ad Fix up duplicated words mostly in comments, part 1
Like in r12-7519-g027e30414492d50feb2854aff38227b14300dc4b, I've done
git grep -v 'long long\|optab optab\|template template\|double double' | grep ' \([a-zA-Z]\+\) \1 '

This is just part of the changes, mostly for non-gcc directories.
I'll try to get to the rest soon.  Obviously, the above command also
finds cases which are correct as is and shouldn't be changed, so one
needs to manually inspect everything.

I'd hope most of it is pretty obvious, but the config/ and libstdc++-v3/
hunks include a tweak in a license wording, though other copies of the
similar license have the wording right.

2024-04-02  Jakub Jelinek  <jakub@redhat.com>

	* Makefile.tpl: Fix duplicated words; returns returns ->
	returns.
config/
	* lcmessage.m4: Fix duplicated words; can can -> can,
	package package -> package.
libdecnumber/
	* decCommon.c (decFinalize): Fix duplicated words in
	comment; the the -> the.
libgcc/
	* unwind-dw2-fde.c (struct fde_accumulator): Fix duplicated
	words in comment; is is -> is.
libgfortran/
	* configure.host: Fix duplicated words; the the -> the.
libgm2/
	* configure.host: Fix duplicated words; the the -> the.
libgomp/
	* libgomp.texi (OpenMP 5.2): Fix duplicated words; with with ->
	with.
	(omp_target_associate_ptr): Fix duplicated words; either either ->
	either.
	(omp_init_allocator): Fix duplicated words; be be -> be.
	(omp_realloc): Fix duplicated words; is is -> is.
	(OMP_ALLOCATOR): Fix duplicated words; other other -> other.
	* priority_queue.h (priority_queue_multi_p): Fix duplicated words;
	to to -> to.
libiberty/
	* regex.c (byte_re_match_2_internal): Fix duplicated words in comment;
	next next -> next.
	* dyn-string.c (dyn_string_init): Fix duplicated words in comment;
	of of -> of.
libitm/
	* beginend.cc (GTM::gtm_thread::begin_transaction): Fix duplicated
	words in comment; not not -> not to.
libobjc/
	* init.c (duplicate_classes): Fix duplicated words in comment; in in
	-> in.
	* sendmsg.c (__objc_prepare_dtable_for_class): Fix duplicated words
	in comment; the the -> the.
	* encoding.c (objc_layout_structure): Likewise.
libstdc++-v3/
	* acinclude.m4: Fix duplicated words; file file -> file can.
	* configure.host: Fix duplicated words; the the -> the.
libvtv/
	* vtv_rts.cc (vtv_fail): Fix duplicated words; to to -> to.
	* vtv_fail.cc (vtv_fail): Likewise.
2024-04-02 13:39:11 +02:00
GCC Administrator
7e6cdec4d3 Daily bump. 2024-03-26 00:17:13 +00:00
Richard Biener
78b56a12dd amdgcn: Add gfx1036 target
Add support for the gfx1036 RDNA2 APU integrated graphics devices.  The ROCm
documentation warns that these may not be supported, but it seems to work
at least partially.

gcc/ChangeLog:

	* config.gcc (amdgcn): Add gfx1036 entries.
	* config/gcn/gcn-hsa.h (NO_XNACK): Likewise.
	(gcn_local_sym_hash): Likewise.
	* config/gcn/gcn-opts.h (enum processor_type): Likewise.
	(TARGET_GFX1036): New macro.
	* config/gcn/gcn.cc (gcn_option_override): Handle gfx1036.
	(gcn_omp_device_kind_arch_isa): Likewise.
	(output_file_start): Likewise.
	* config/gcn/gcn.h (TARGET_CPU_CPP_BUILTINS): Add __gfx1036__.
	(TARGET_CPU_CPP_BUILTINS): Rename __gfx1030 to __gfx1030__.
	* config/gcn/gcn.opt: Add gfx1036.
	* config/gcn/mkoffload.cc (EF_AMDGPU_MACH_AMDGCN_GFX1036): New.
	(main): Handle gfx1036.
	* config/gcn/t-omp-device: Add gfx1036 isa.
	* doc/install.texi (amdgcn): Add gfx1036.
	* doc/invoke.texi (-march): Likewise.

libgomp/ChangeLog:

	* plugin/plugin-gcn.c (EF_AMDGPU_MACH): GFX1036.
	(gcn_gfx1103_s): New.
	(isa_hsa_name): Handle gfx1036.
	(isa_code): Likewise.
	(max_isa_vgprs): Likewise.
2024-03-25 15:54:37 +01:00
GCC Administrator
e8985864a3 Daily bump. 2024-03-23 00:17:26 +00:00
Kwok Cheung Yeung
637e76b90e openmp: Change to using a hashtab to lookup offload target addresses for indirect function calls
A splay-tree was previously used to lookup equivalent target addresses
for a given host address on offload targets. However, as splay-trees can
modify their structure on lookup, they are not suitable for concurrent
access from separate teams/threads without some form of locking.  This
patch changes the lookup data structure to a hashtab instead, which does
not have these issues.

The call to build_indirect_map to initialize the data structure is now
called from just the first thread of the first team to avoid redundant
calls to this function.

2024-03-22  Kwok Cheung Yeung  <kcyeung@baylibre.com>

	libgomp/
	* config/accel/target-indirect.c: Include string.h and hashtab.h.
	Remove include of splay-tree.h.  Update comments.
	(splay_tree_prefix, splay_tree_c): Delete.
	(struct indirect_map_t): New.
	(hash_entry_type, htab_alloc, htab_free, htab_hash, htab_eq): New.
	(GOMP_INDIRECT_ADD_MAP): Remove volatile qualifier.
	(USE_SPLAY_TREE_LOOKUP): Rename to...
	(USE_HASHTAB_LOOKUP): ..this.
	(indirect_map, indirect_array): Delete.
	(indirect_htab): New.
	(build_indirect_map): Remove locking.  Build indirect map using
	hashtab.
	(GOMP_target_map_indirect_ptr): Use indirect_htab to lookup target
	address.
	(GOMP_target_map_indirect_ptr): Remove volatile qualifier.
	* config/gcn/team.c (gomp_gcn_enter_kernel): Call build_indirect_map
	from first thread of first team only.
	* config/nvptx/team.c (gomp_nvptx_main): Likewise.
	* testsuite/libgomp.c-c++-common/declare-target-indirect-2.c (main):
	Add missing break statements.
	* testsuite/libgomp.fortran/declare-target-indirect-2.f90: Remove
	xfail.
2024-03-22 18:09:40 +00:00
Andrew Stubbs
1bf18629c5 amdgcn: Add gfx1103 target
Add support for the gfx1103 RDNA3 APU integrated graphics devices.  The ROCm
documentation warns that these may not be supported, but it seems to work
at least partially.

gcc/ChangeLog:

	* config.gcc (amdgcn): Add gfx1103 entries.
	* config/gcn/gcn-hsa.h (NO_XNACK): Likewise.
	(gcn_local_sym_hash): Likewise.
	* config/gcn/gcn-opts.h (enum processor_type): Likewise.
	(TARGET_GFX1103): New macro.
	* config/gcn/gcn.cc (gcn_option_override): Handle gfx1103.
	(gcn_omp_device_kind_arch_isa): Likewise.
	(output_file_start): Likewise.
	(gcn_hsa_declare_function_name): Use TARGET_RDNA3, not just gfx1100.
	* config/gcn/gcn.h (TARGET_CPU_CPP_BUILTINS): Add __gfx1103__.
	* config/gcn/gcn.opt: Add gfx1103.
	* config/gcn/mkoffload.cc (EF_AMDGPU_MACH_AMDGCN_GFX1103): New.
	(main): Handle gfx1103.
	* config/gcn/t-omp-device: Add gfx1103 isa.
	* doc/install.texi (amdgcn): Add gfx1103.
	* doc/invoke.texi (-march): Likewise.

libgomp/ChangeLog:

	* plugin/plugin-gcn.c (EF_AMDGPU_MACH): GFX1103.
	(gcn_gfx1103_s): New.
	(isa_hsa_name): Handle gfx1103.
	(isa_code): Likewise.
	(max_isa_vgprs): Likewise.
2024-03-22 14:45:15 +00:00
GCC Administrator
c1f6690b82 Daily bump. 2024-03-15 00:17:52 +00:00
Thomas Schwinge
25242ed8eb Fix 'char' initialization, copy, check in 'libgomp.oacc-fortran/acc-memcpy.f90'
Our dear friend '-Wuninitialized' reported:

    [...]/libgomp.oacc-fortran/acc-memcpy.f90:18:27:

       18 |     char(j) = int (j, int8)
          |                           ^
    Warning: ‘j’ may be used uninitialized [-Wmaybe-uninitialized]
    [...]/libgomp.oacc-fortran/acc-memcpy.f90:14:20:

       14 |   integer(int8) :: j
          |                    ^
    note: ‘j’ was declared here

..., but actually there were other issues.

	libgomp/
	* testsuite/libgomp.oacc-fortran/acc-memcpy.f90: Fix 'char'
	initialization, copy, check.
2024-03-14 15:41:33 +01:00
GCC Administrator
746b71e26b Daily bump. 2024-03-14 00:18:12 +00:00
Tobias Burnus
c5037fcee2 OpenMP/Fortran: Fix defaultmap(none) issue with dummy procedures [PR114283]
Dummy procedures look similar to variables but aren't - neither in Fortran
nor in OpenMP. As the middle end sees PARM_DECLs, mark them as predetermined
firstprivate for mapping (as already done in gfc_omp_predetermined_sharing).

This does not address the isses related to procedure pointers, which are
still discussed on spec level [see PR].

	PR fortran/114283

gcc/fortran/ChangeLog:

	* trans-openmp.cc (gfc_omp_predetermined_mapping): Map dummy
	procedures as firstprivate.

libgomp/ChangeLog:

	* testsuite/libgomp.fortran/declare-target-indirect-4.f90: New test.
2024-03-13 09:35:28 +01:00
GCC Administrator
f6d9426b5b Daily bump. 2024-03-13 00:17:12 +00:00
Tobias Burnus
ef79c64cb5 libgomp/libgomp.texi: Fix @node order in @menu
While texinfo 7.0.3 does not warn, an older texinfo did complain about:
libgomp.texi:1964: warning: node next `omp_target_memcpy' in menu
`omp_target_memcpy_rect' and in sectioning `omp_target_memcpy_async' differ

libgomp/

	* libgomp.texi (Device Memory Routines): Swap item order to match
	the order of the '@node's of the '@subsection's.
2024-03-12 15:42:50 +01:00
GCC Administrator
c775a030af Daily bump. 2024-03-09 00:17:14 +00:00
Thomas Schwinge
84fc8f4f32 GCN: The original meaning of 'GCN_SUPPRESS_HOST_FALLBACK' isn't applicable (non-shared memory system)
'GCN_SUPPRESS_HOST_FALLBACK' originated as 'HSA_SUPPRESS_HOST_FALLBACK' in the
libgomp HSA plugin, where the idea was -- in my understanding -- that you
wouldn't have device code available for all functions that may be called, and
in that case transparently (shared memory system!) do host-fallback execution.
Or, with 'HSA_SUPPRESS_HOST_FALLBACK' set, you'd get those diagnosed.

This has then been copied into the libgomp GCN plugin as
'GCN_SUPPRESS_HOST_FALLBACK'.  However, the original meaning isn't applicable
for the libgomp GCN plugin anymore: we assume that we're generating device code
for all relevant functions, and we're implementing a non-shared memory system,
where we cannot transparently do host-fallback execution for individual
functions.

However, 'GCN_SUPPRESS_HOST_FALLBACK' has gained an additional meaning, to
enforce a fatal error in case that 'libhsa-runtime64.so.1' can't be dynamically
loaded; keep that meaning.

	libgomp/
	* plugin/plugin-gcn.c (GOMP_OFFLOAD_can_run): Don't consider
	'GCN_SUPPRESS_HOST_FALLBACK' anymore (assume always-'true').
	(init_hsa_context): Adjust 'GCN_SUPPRESS_HOST_FALLBACK' error
	message.
2024-03-08 16:35:28 +01:00
Thomas Schwinge
37078f241a nvptx: 'cuDeviceGetCount' failure is fatal
Per commit 683f118439
"OpenMP: Move omp requires checks to libgomp", we're now using 'return -1'
from 'GOMP_OFFLOAD_get_num_devices' for 'omp_requires_mask' purposes.  This
missed that via 'nvptx_get_num_devices', we could also 'return -1' for
'cuDeviceGetCount' failure.  Before, this meant (in 'gomp_target_init') to
silently ignore the plugin/device -- which also has been doubtful behavior.
Let's instead turn 'cuDeviceGetCount' failure into a fatal error, similar to
other errors during device initialization.

	libgomp/
	* plugin/plugin-nvptx.c (nvptx_get_num_devices):
	'cuDeviceGetCount' failure is fatal.
2024-03-08 16:35:28 +01:00
Thomas Schwinge
ab70addf56 GCN, nvptx: Fatal error for missing symbols in 'libhsa-runtime64.so.1', 'libcuda.so.1'
If 'libhsa-runtime64.so.1', 'libcuda.so.1' are not available, the corresponding
libgomp plugin/device gets disabled, as before.  But if they are available,
report any inconsistencies such as missing symbols, similar to how we fail in
presence of other issues during device initialization.

	libgomp/
	* plugin/plugin-gcn.c (init_hsa_runtime_functions): Fatal error
	for missing symbols.
	* plugin/plugin-nvptx.c (init_cuda_lib): Likewise.
2024-03-08 16:35:28 +01:00
GCC Administrator
8b483cd552 Daily bump. 2024-03-07 00:17:38 +00:00
John David Anglin
49c3f24552 Revert "Set num_threads to 50 on 32-bit hppa in two libgomp loop tests"
This reverts commit b14209715e.
2024-03-06 17:01:59 +00:00
GCC Administrator
264e3ad419 Daily bump. 2024-03-05 00:18:04 +00:00
Jakub Jelinek
dea9ac2a00 libgomp: Use void (*) (void *) rather than void (*)() for host_fn type [PR114216]
For the type of the target callbacks we use elsehwere void (*) (void *) and
IMHO should use that for the reverse offload fallback as well (where the actual
callback is emitted using the same code as for host fallback or device kernel
entry routines), even when it is also ok to use void (*) () before C23 and
we aren't building libgomp with C23 yet.  On some arches perhaps void (*) ()
could result in worse code generation because calls in that case like casts
to unprototyped functions need to sometimes pass argument in two different spots
etc. so that it deals with both passing it through ... and as a named argument.

2024-03-04  Jakub Jelinek  <jakub@redhat.com>

	PR libgomp/114216
	* target.c (gomp_target_rev): Change host_fn type and corresponding
	cast from void (*)() to void (*) (void *).
2024-03-04 11:48:40 +01:00
GCC Administrator
306a4c3223 Daily bump. 2024-03-02 00:17:11 +00:00
Jakub Jelinek
4f82d5a95a OpenMP/C++: Fix (first)private clause with member variables [PR110347]
OpenMP permits '(first)private' for C++ member variables, which GCC handles
by tagging those by DECL_OMP_PRIVATIZED_MEMBER, adding a temporary VAR_DECL
and DECL_VALUE_EXPR pointing to the 'this->member_var' in the C++ front end.

The idea is that in omp-low.cc, the DECL_VALUE_EXPR is used before the
region (for 'firstprivate'; ignored for 'private') while in the region,
the DECL itself is used.

In gimplify, the value expansion is suppressed and deferred if the
  lang_hooks.decls.omp_disregard_value_expr (decl, shared)
returns true - which is never the case if 'shared' is true. In OpenMP 4.5,
only 'map' and 'use_device_ptr' was permitted for the 'target' directive.
And when OpenMP 5.0's 'private'/'firstprivate' clauses was added, the
the update that now 'shared' argument could be false was missed. The
respective check has now been added.

2024-03-01  Jakub Jelinek  <jakub@redhat.com>
	    Tobias Burnus  <tburnus@baylibre.com>

	PR c++/110347

gcc/ChangeLog:

	* gimplify.cc (omp_notice_variable): Fix 'shared' arg to
	lang_hooks.decls.omp_disregard_value_expr for
	(first)private in target regions.

libgomp/ChangeLog:

	* testsuite/libgomp.c++/target-lambda-3.C: Moved from
	gcc/testsuite/g++.dg/gomp/ and fixed is-mapped handling.
	* testsuite/libgomp.c++/target-lambda-1.C: Modify to also
	also work without offloading.
	* testsuite/libgomp.c++/firstprivate-1.C: New test.
	* testsuite/libgomp.c++/firstprivate-2.C: New test.
	* testsuite/libgomp.c++/private-1.C: New test.
	* testsuite/libgomp.c++/private-2.C: New test.
	* testsuite/libgomp.c++/target-lambda-4.C: New test.
	* testsuite/libgomp.c++/use_device_ptr-1.C: New test.

gcc/testsuite/ChangeLog:

	* g++.dg/gomp/target-lambda-1.C: Moved to become a
	run-time test under testsuite/libgomp.c++.

Co-authored-by: Tobias Burnus <tburnus@baylibre.com>
2024-03-01 17:26:42 +01:00
GCC Administrator
6309ad25c6 Daily bump. 2024-02-28 00:16:42 +00:00
Tobias Burnus
8b3f1edf9b OpenACC: Add Fortran routines acc_{alloc,free,hostptr,deviceptr,memcpy_{to,from}_device*}
These routines map simply to the C counterpart and are meanwhile
defined in OpenACC 3.3. (There are additional routine changes,
including the Fortran addition of acc_attach/acc_detach, that
require more work than a simple addition of an interface and
are therefore excluded.)

libgomp/ChangeLog:

	* libgomp.texi (OpenACC Runtime Library Routines): Document new 3.3
	routines that simply map to their C counterpart.
	* openacc.f90 (openacc): Add them.
	* openacc_lib.h: Likewise.
	* testsuite/libgomp.oacc-fortran/acc_host_device_ptr.f90: New test.
	* testsuite/libgomp.oacc-fortran/acc-memcpy.f90: New test.
	* testsuite/libgomp.oacc-fortran/acc-memcpy-2.f90: New test.
	* testsuite/libgomp.oacc-c-c++-common/lib-59.c: Crossref to f90 test.
	* testsuite/libgomp.oacc-c-c++-common/lib-60.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/lib-95.c: Likewise.
2024-02-27 17:30:38 +01:00
GCC Administrator
98004ca00e Daily bump. 2024-02-22 00:18:58 +00:00
Tobias Burnus
703d14132e OpenMP/nvptx: support 'arch(nvptx64)' as context selector
The main 'arch' context selector for nvptx is, well, 'nvptx';
however, as 'nvptx64' is used as by LLVM, it makes sense
to support it as well.

Note that LLVM has: "The triple architecture can be one of
``nvptx`` (32-bit PTX) or ``nvptx64`` (64-bit PTX)."
GCC effectively only supports the 64bit variant (at least for
offloading). Thus, GCC's 'nvptx' is not quite the same as LLVM's.

The device-compiler part (nvptx_omp_device_kind_arch_isa) uses
TARGET_ABI64 such that nvptx64 is only defined with -m64.

gcc/ChangeLog:

	* config/nvptx/gen-omp-device-properties.sh: Add 'nvptx64' to arch.
	* config/nvptx/nvptx.cc (nvptx_omp_device_kind_arch_isa): Likewise.

libgomp/ChangeLog:

	* libgomp.texi (OpenMP Context Selectors): Add 'nvptx64' as additional
	'arch' value for nvptx.
2024-02-21 11:31:43 +01:00
GCC Administrator
5c30ecfa81 Daily bump. 2024-02-16 00:17:22 +00:00
Kwok Cheung Yeung
b3b3bd250f libgomp: Update documentation for indirect calls in target regions
Support for indirect calls to procedures/functions in offloaded target
regions is now available for C, C++ and Fortran.

2024-02-15  Kwok Cheung Yeung  <kcyeung@baylibre.com>

	libgomp/
	* libgomp.texi (OpenMP 5.1): Mark indirect call support as fully
	implemented.
2024-02-15 21:30:00 +00:00
Kwok Cheung Yeung
451bb58660 openmp, fortran: Add Fortran support for indirect clause on the declare target directive
2024-02-15  Kwok Cheung Yeung  <kcyeung@baylibre.com>

	gcc/fortran/
	* dump-parse-tree.cc (show_attr): Handle omp_declare_target_indirect
	attribute.
	* f95-lang.cc (gfc_gnu_attributes): Add entry for 'omp declare
	target indirect'.
	* gfortran.h (symbol_attribute): Add omp_declare_target_indirect
	field.
	(struct gfc_omp_clauses): Add indirect field.
	* openmp.cc (omp_mask2): Add OMP_CLAUSE_INDIRECT.
	(gfc_match_omp_clauses): Match indirect clause.
	(OMP_DECLARE_TARGET_CLAUSES): Add OMP_CLAUSE_INDIRECT.
	(gfc_match_omp_declare_target): Check omp_device_type and apply
	omp_declare_target_indirect attribute to symbol if indirect clause
	active.  Show warning if there are only device_type and/or indirect
	clauses on the directive.
	* trans-decl.cc (add_attributes_to_decl): Add 'omp declare target
	indirect' attribute if symbol has indirect attribute set.

	gcc/testsuite/
	* gfortran.dg/gomp/declare-target-4.f90 (f1): Update expected warning.
	* gfortran.dg/gomp/declare-target-indirect-1.f90: New.
	* gfortran.dg/gomp/declare-target-indirect-2.f90: New.

	libgomp/
	* testsuite/libgomp.fortran/declare-target-indirect-1.f90: New.
	* testsuite/libgomp.fortran/declare-target-indirect-2.f90: New.
	* testsuite/libgomp.fortran/declare-target-indirect-3.f90: New.
2024-02-15 21:04:53 +00:00
GCC Administrator
bf074ee40a Daily bump. 2024-02-13 00:17:51 +00:00
Rainer Orth
1e94648ab7 libgomp: testsuite: Don't XPASS libgomp.c/alloc-pinned-1.c etc. on non-Linux targets [PR113448]
Two libgomp tests XPASS on Solaris (any non-Linux target actually) since
their introduction:

XPASS: libgomp.c/alloc-pinned-1.c execution test
XPASS: libgomp.c/alloc-pinned-2.c execution test

The problem is that the test just prints

OS unsupported

and exits successfully, while the test is XFAILed:

/* { dg-xfail-run-if "Pinning not implemented on this host" { ! *-*-linux-gnu } } */

Fixed by aborting immediately after the message above in the non-Linux
case.

Tested on i386-pc-solaris2.11 and i686-pc-linux-gnu.

2024-02-02  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libgomp:
	PR testsuite/113448
	* testsuite/libgomp.c/alloc-pinned-1.c [!__linux__] (CHECK_SIZE):
	Call abort.
	* testsuite/libgomp.c/alloc-pinned-2.c [!__linux__] (CHECK_SIZE):
	Likewise.
2024-02-12 14:44:17 +01:00
GCC Administrator
cc136a0bdc Daily bump. 2024-02-12 00:17:01 +00:00
John David Anglin
167798a4d2 libgomp: Define config_path for hppa*-*-linux*
2024-02-11  John David Anglin  <danglin@gcc.gnu.org>

libgomp/ChangeLog:

	PR libgomp/113843
	* configure.tgt (hppa*-*-linux*): Define config_path.
2024-02-11 20:23:14 +00:00
GCC Administrator
e255454046 Daily bump. 2024-02-02 00:18:18 +00:00
John David Anglin
b14209715e Set num_threads to 50 on 32-bit hppa in two libgomp loop tests
We support a maximum of 50 threads on 32-bit hppa.

2024-02-01  John David Anglin  <danglin@gcc.gnu.org>

libgomp/ChangeLog:

	* testsuite/libgomp.c++/loop-3.C: Set num_threads to 50
	on 32-bit hppa.
	* testsuite/libgomp.c/omp-loop03.c: Likewise.
2024-02-01 19:09:53 +00:00
GCC Administrator
f07068197d Daily bump. 2024-01-30 00:18:41 +00:00
Tobias Burnus
cb366731e7 libgomp.c/declare-variant-4.h: Fix used variant function for gfx1030/gfx1100
libgomp/ChangeLog:

	* testsuite/libgomp.c/declare-variant-4.h: Use gfx1100/gfx1030
	function not gfx90a for gfx1100/gfx1030 context selector.

Signed-off-by: Tobias Burnus <tburnus@baylibre.com>
2024-01-29 11:06:15 +01:00