summaryrefslogtreecommitdiff
path: root/libgomp/omp_lib.f90.in
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-10-11 12:02:15 +0200
committerJakub Jelinek <jakub@redhat.com>2021-10-11 12:20:22 +0200
commit07dd3bcda17f97cf5476c3d6f2f2501c1e0712e6 (patch)
tree4ea465dae416e2a06d9765298bb36b7a88a49272 /libgomp/omp_lib.f90.in
parent6e3c4bfd0c0a75b805425f10fd593ee3df47fbf6 (diff)
downloadgcc-07dd3bcda17f97cf5476c3d6f2f2501c1e0712e6.tar.gz
openmp: Add omp_set_num_teams, omp_get_max_teams, omp_[gs]et_teams_thread_limit
OpenMP 5.1 adds env vars and functions to set and query new ICVs used as fallback if thread_limit or num_teams clauses aren't specified on teams construct. The following patch implements those, though further work will be needed: 1) OpenMP 5.1 also changed the num_teams clause, so that it can specify both lower and upper limit for how many teams should be created and changed the meaning when only one expression is provided, instead of num_teams(expr) in 5.0 meaning num_teams(1:expr) in 5.1, it now means num_teams(expr:expr), i.e. while previously we could create 1 to expr teams, in 5.1 we have some low limit by default equal to the single expression provided and may not create fewer teams. For host teams (which we don't currently implement efficiently for NUMA hosts) we trivially satisfy it now by always honoring what the user asked for, but for the offloading teams I think we'll need to rethink the APIs; currently teams construct is just a call that returns and possibly lowers the number of teams; and whenever possible we try to evaluate num_teams/thread_limit already on the target construct and the GOMP_teams call just sets the number of teams to the minimum of provided and requested teams; for some cases e.g. where target is not combined with teams and num_teams expression calls some functions etc., we need to call those functions in the target region and so it is late to figure number of teams, but also hw could just limit what it is willing to create; in that case I'm afraid we need to run the target body multiple times and arrange for omp_get_team_num () returning the right values 2) we need to finally implement the NUMA handling for GOMP_teams_reg 3) I now realize I haven't added some testcase coverage, will do that incrementally 4) libgomp.texi needs updates for these new APIs, but also others like the allocator 2021-10-11 Jakub Jelinek <jakub@redhat.com> gcc/ * omp-low.c (omp_runtime_api_call): Handle omp_get_max_teams, omp_[sg]et_teams_thread_limit and omp_set_num_teams. libgomp/ * omp.h.in (omp_set_num_teams, omp_get_max_teams, omp_set_teams_thread_limit, omp_get_teams_thread_limit): Declare. * omp_lib.f90.in (omp_set_num_teams, omp_get_max_teams, omp_set_teams_thread_limit, omp_get_teams_thread_limit): Declare. * omp_lib.h.in (omp_set_num_teams, omp_get_max_teams, omp_set_teams_thread_limit, omp_get_teams_thread_limit): Declare. * libgomp.h (gomp_nteams_var, gomp_teams_thread_limit_var): Declare. * libgomp.map (OMP_5.1): Export omp_get_max_teams{,_}, omp_get_teams_thread_limit{,_}, omp_set_num_teams{,_,_8_} and omp_set_teams_thread_limit{,_,_8_}. * icv.c (omp_set_num_teams, omp_get_max_teams, omp_set_teams_thread_limit, omp_get_teams_thread_limit): New functions. * env.c (gomp_nteams_var, gomp_teams_thread_limit_var): Define. (omp_display_env): Print OMP_NUM_TEAMS and OMP_TEAMS_THREAD_LIMIT. (initialize_env): Handle OMP_NUM_TEAMS and OMP_TEAMS_THREAD_LIMIT env vars. * teams.c (GOMP_teams_reg): If thread_limit is not specified, use gomp_teams_thread_limit_var as fallback if not zero. If num_teams is not specified, use gomp_nteams_var. * fortran.c (omp_set_num_teams, omp_get_max_teams, omp_set_teams_thread_limit, omp_get_teams_thread_limit): Add ialias_redirect. (omp_set_num_teams_, omp_set_num_teams_8_, omp_get_max_teams_, omp_set_teams_thread_limit_, omp_set_teams_thread_limit_8_, omp_get_teams_thread_limit_): New functions.
Diffstat (limited to 'libgomp/omp_lib.f90.in')
-rw-r--r--libgomp/omp_lib.f90.in30
1 files changed, 30 insertions, 0 deletions
diff --git a/libgomp/omp_lib.f90.in b/libgomp/omp_lib.f90.in
index 1063eee0c94..973b87be80a 100644
--- a/libgomp/omp_lib.f90.in
+++ b/libgomp/omp_lib.f90.in
@@ -564,6 +564,36 @@
end function omp_get_max_task_priority
end interface
+ interface omp_set_num_teams
+ subroutine omp_set_num_teams (num_teams)
+ integer (4), intent (in) :: num_teams
+ end subroutine omp_set_num_teams
+ subroutine omp_set_num_teams_8 (num_teams)
+ integer (8), intent (in) :: num_teams
+ end subroutine omp_set_num_teams_8
+ end interface
+
+ interface
+ function omp_get_max_teams ()
+ integer (4) :: omp_get_max_teams
+ end function omp_get_max_teams
+ end interface
+
+ interface omp_set_teams_thread_limit
+ subroutine omp_set_teams_thread_limit (thread_limit)
+ integer (4), intent (in) :: thread_limit
+ end subroutine omp_set_teams_thread_limit
+ subroutine omp_set_teams_thread_limit_8 (thread_limit)
+ integer (8), intent (in) :: thread_limit
+ end subroutine omp_set_teams_thread_limit_8
+ end interface
+
+ interface
+ function omp_get_teams_thread_limit ()
+ integer (4) :: omp_get_teams_thread_limit
+ end function omp_get_teams_thread_limit
+ end interface
+
interface
subroutine omp_fulfill_event (event)
use omp_lib_kinds