gcc/libgomp
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 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
plugin 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
testsuite 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
.gitattributes libgomp: Fixes + cleanup for OpenACC's Fortran module + openacc_lib.h 2020-02-19 09:13:44 +01:00
acc_prof.h Update copyright years. 2022-01-03 10:42:10 +01:00
acinclude.m4 libgomp: fix typo in mold linker detection 2022-06-28 10:35:32 +02:00
aclocal.m4 libgomp: Regenerate configure files with automake 1.15.1 2020-10-02 12:08:47 +02:00
affinity-fmt.c Update copyright years. 2022-01-03 10:42:10 +01:00
affinity.c Update copyright years. 2022-01-03 10:42:10 +01:00
alloc.c libgomp: Don't define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC for _aligned_malloc [PR105745] 2022-05-28 08:30:47 +02:00
allocator.c openmp: Call dlopen with "libmemkind.so.0" rather than "libmemkind.so" 2022-06-10 21:19:51 +02:00
atomic.c Update copyright years. 2022-01-03 10:42:10 +01:00
barrier.c Update copyright years. 2022-01-03 10:42:10 +01:00
ChangeLog Daily bump. 2022-12-01 00:17:51 +00:00
ChangeLog.graphite
config.h.in Refactor '-ldl' handling for libgomp proper and plugins 2022-05-12 15:11:30 +02:00
configure Revert "sphinx: add --with-sphinx-build" 2022-11-14 09:35:05 +01:00
configure.ac Revert "sphinx: add --with-sphinx-build" 2022-11-14 09:35:05 +01:00
configure.tgt LoongArch Port: libgomp 2022-03-29 17:43:35 +08:00
critical.c Update copyright years. 2022-01-03 10:42:10 +01:00
env.c libgomp: Fix up build on mingw [PR107641] 2022-11-12 09:50:04 +01:00
error.c Update copyright years. 2022-01-03 10:42:10 +01:00
fortran.c libgomp: Add omp_in_explicit_task support 2022-10-12 18:39:20 +02:00
hashtab.h Update copyright years. 2022-01-03 10:42:10 +01:00
icv-device.c 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
icv.c 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
iter_ull.c Update copyright years. 2022-01-03 10:42:10 +01:00
iter.c Update copyright years. 2022-01-03 10:42:10 +01:00
libgomp_f.h.in Update copyright years. 2022-01-03 10:42:10 +01:00
libgomp_g.h openmp: Add taskwait nowait depend support [PR105378] 2022-05-24 09:12:44 +02:00
libgomp-plugin.c libgomp/nvptx: Prepare for reverse-offload callback handling 2022-10-24 17:04:08 +02:00
libgomp-plugin.h Remove support for Intel MIC offloading 2022-11-04 10:51:01 +01:00
libgomp.h libgomp/nvptx: Prepare for reverse-offload callback handling 2022-10-24 17:04:08 +02:00
libgomp.map libgomp/nvptx: Prepare for reverse-offload callback handling 2022-10-24 17:04:08 +02:00
libgomp.spec.in
libgomp.texi 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
lock.c Update copyright years. 2022-01-03 10:42:10 +01:00
loop_ull.c libgomp: Fix up two non-GOMP_USE_ALIGNED_WORK_SHARES related issues [PR105358] 2022-04-26 08:57:17 +02:00
loop.c libgomp: Fix up two non-GOMP_USE_ALIGNED_WORK_SHARES related issues [PR105358] 2022-04-26 08:57:17 +02:00
Makefile.am Refactor '-ldl' handling for libgomp proper and plugins 2022-05-12 15:11:30 +02:00
Makefile.in Revert "sphinx: support Sphinx in build system" 2022-11-14 09:35:06 +01:00
oacc-async.c Update copyright years. 2022-01-03 10:42:10 +01:00
oacc-cuda.c Update copyright years. 2022-01-03 10:42:10 +01:00
oacc-host.c libgomp: Prepare for reverse offload fn lookup 2022-09-09 17:37:09 +02:00
oacc-init.c OpenMP: Move omp requires checks to libgomp 2022-07-04 13:52:02 +02:00
oacc-int.h Update copyright years. 2022-01-03 10:42:10 +01:00
oacc-mem.c Support OpenACC 'declare create' with Fortran allocatable arrays, part II [PR106643, PR96668] 2022-11-02 20:51:41 +01:00
oacc-parallel.c Update copyright years. 2022-01-03 10:42:10 +01:00
oacc-plugin.c Update copyright years. 2022-01-03 10:42:10 +01:00
oacc-plugin.h Update copyright years. 2022-01-03 10:42:10 +01:00
oacc-profiling.c Update copyright years. 2022-01-03 10:42:10 +01:00
oacc-target.c GCN libgomp port 2019-11-13 12:38:04 +00:00
omp_lib.f90.in libgomp: Add omp_in_explicit_task support 2022-10-12 18:39:20 +02:00
omp_lib.h.in libgomp: Add omp_in_explicit_task support 2022-10-12 18:39:20 +02:00
omp.h.in libgomp: Add omp_in_explicit_task support 2022-10-12 18:39:20 +02:00
openacc_lib.h Update copyright years. 2022-01-03 10:42:10 +01:00
openacc.f90 Update copyright years. 2022-01-03 10:42:10 +01:00
openacc.h Update copyright years. 2022-01-03 10:42:10 +01:00
ordered.c Update copyright years. 2022-01-03 10:42:10 +01:00
parallel.c Update copyright years. 2022-01-03 10:42:10 +01:00
priority_queue.c Update copyright years. 2022-01-03 10:42:10 +01:00
priority_queue.h Update copyright years. 2022-01-03 10:42:10 +01:00
scope.c Update copyright years. 2022-01-03 10:42:10 +01:00
sections.c libgomp: Fix up two non-GOMP_USE_ALIGNED_WORK_SHARES related issues [PR105358] 2022-04-26 08:57:17 +02:00
secure_getenv.h Update copyright years. 2022-01-03 10:42:10 +01:00
single.c Update copyright years. 2022-01-03 10:42:10 +01:00
splay-tree.c Update copyright years. 2022-01-03 10:42:10 +01:00
splay-tree.h libgomp/splay-tree.h: Fix splay_tree_prefix handling 2022-08-17 15:36:41 +02:00
target.c 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
task.c libgomp: Add omp_in_explicit_task support 2022-10-12 18:39:20 +02:00
taskloop.c Update copyright years. 2022-01-03 10:42:10 +01:00
team.c Update copyright years. 2022-01-03 10:42:10 +01:00
teams.c Update copyright years. 2022-01-03 10:42:10 +01:00
work.c libgomp: Fix up two non-GOMP_USE_ALIGNED_WORK_SHARES related issues [PR105358] 2022-04-26 08:57:17 +02:00