gcc/libgomp/testsuite
Marcel Vollweiler 81476bc4f4 OpenMP: omp_get_max_teams, omp_set_num_teams, and omp_{gs}et_teams_thread_limit on offload devices
This patch adds support for omp_get_max_teams, omp_set_num_teams, and
omp_{gs}et_teams_thread_limit on offload devices. That includes the usage of
device-specific ICV values (specified as environment variables or changed on a
device). In order to reuse device-specific ICV values, a copy back mechanism is
implemented that copies ICV values back from device to the host.

Additionally, a limitation of the number of teams on gcn offload devices is
implemented.  The number of teams is limited by twice the number of compute
units (one team is executed on one compute unit).  This avoids queueing
unnessecary many teams and a corresponding allocation of large amounts of
memory.  Without that limitation the memory allocation for a large number of
user-specified teams can result in an "memory access fault".
A limitation of the number of teams is already also implemented for nvptx
devices (see nvptx_adjust_launch_bounds in libgomp/plugin/plugin-nvptx.c).

gcc/ChangeLog:

	* gimplify.cc (optimize_target_teams): Set initial num_teams_upper
	to "-2" instead of "1" for non-existing num_teams clause in order to
	disambiguate from the case of an existing num_teams clause with value 1.

libgomp/ChangeLog:

	* config/gcn/icv-device.c (omp_get_teams_thread_limit): Added to
	allow processing of device-specific values.
	(omp_set_teams_thread_limit): Likewise.
	(ialias): Likewise.
	* config/nvptx/icv-device.c (omp_get_teams_thread_limit): Likewise.
	(omp_set_teams_thread_limit): Likewise.
	(ialias): Likewise.
	* icv-device.c (omp_get_teams_thread_limit): Likewise.
	(ialias): Likewise.
	(omp_set_teams_thread_limit): Likewise.
	* icv.c (omp_set_teams_thread_limit): Removed.
	(omp_get_teams_thread_limit): Likewise.
	(ialias): Likewise.
	* libgomp.texi: Updated documentation for nvptx and gcn corresponding
	to the limitation of the number of teams.
	* plugin/plugin-gcn.c (limit_teams): New helper function that limits
	the number of teams by twice the number of compute units.
	(parse_target_attributes): Limit the number of teams on gcn offload
	devices.
	* target.c (get_gomp_offload_icvs): Added teams_thread_limit_var
	handling.
	(gomp_load_image_to_device): Added a size check for the ICVs struct
	variable.
	(gomp_copy_back_icvs): New function that is used in GOMP_target_ext to
	copy back the ICV values from device to host.
	(GOMP_target_ext): Update the number of teams and threads in the kernel
	args also considering device-specific values.
	* testsuite/libgomp.c-c++-common/icv-4.c: Fixed an error in the reading
	of OMP_TEAMS_THREAD_LIMIT from the environment.
	* testsuite/libgomp.c-c++-common/icv-5.c: Extended.
	* testsuite/libgomp.c-c++-common/icv-6.c: Extended.
	* testsuite/libgomp.c-c++-common/icv-7.c: Extended.
	* testsuite/libgomp.c-c++-common/icv-9.c: New test.
	* testsuite/libgomp.fortran/icv-5.f90: New test.
	* testsuite/libgomp.fortran/icv-6.f90: New test.

gcc/testsuite/ChangeLog:

	* c-c++-common/gomp/target-teams-1.c: Adapt expected values for
	num_teams from "1" to "-2" in cases without num_teams clause.
	* g++.dg/gomp/target-teams-1.C: Likewise.
	* gfortran.dg/gomp/defaultmap-4.f90: Likewise.
	* gfortran.dg/gomp/defaultmap-5.f90: Likewise.
	* gfortran.dg/gomp/defaultmap-6.f90: Likewise.
2022-12-06 06:03:50 -08:00
..
config Update copyright years. 2022-01-03 10:42:10 +01:00
lib OpenMP: Generate SIMD clones for functions with "declare target" 2022-11-25 18:13:22 +00:00
libgomp.c amdgcn: Support AMD-specific 'isa' traits in OpenMP context selectors 2022-11-30 10:51:42 +01:00
libgomp.c-c++-common OpenMP: omp_get_max_teams, omp_set_num_teams, and omp_{gs}et_teams_thread_limit on offload devices 2022-12-06 06:03:50 -08:00
libgomp.c++ OpenMP, C++: Add template support for the has_device_addr clause. 2022-05-16 01:02:50 -07:00
libgomp.fortran OpenMP: omp_get_max_teams, omp_set_num_teams, and omp_{gs}et_teams_thread_limit on offload devices 2022-12-06 06:03:50 -08:00
libgomp.graphite Update copyright years. 2022-01-03 10:42:10 +01:00
libgomp.oacc-c [testsuite] Unset 'offload_target' after use 2020-07-24 14:00:43 +02:00
libgomp.oacc-c-c++-common Restore 'libgomp.oacc-c-c++-common/nvptx-sese-1.c' SESE regions checking [PR107195, PR107344] 2022-10-21 11:27:27 +02:00
libgomp.oacc-c++ OpenMP/OpenACC struct sibling list gimplification extension and rework 2022-09-14 13:59:55 +00:00
libgomp.oacc-fortran Support OpenACC 'declare create' with Fortran allocatable arrays, part II [PR106643, PR96668] 2022-11-02 20:51:41 +01:00
libgomp-site-extra.exp.in libgomp/test: Remove a build sysroot fix regression 2020-04-06 23:32:45 +01:00
libgomp-test-support.exp.in libgomp nvptx plugin: Remove '--with-cuda-driver=[...]' etc. configuration option 2022-06-10 17:08:57 +02:00
Makefile.am libgomp/test: Remove a build sysroot fix regression 2020-04-06 23:32:45 +01:00
Makefile.in libgomp nvptx plugin: Remove '--with-cuda-driver=[...]' etc. configuration option 2022-06-10 17:08:57 +02:00