1*4c3eb207Smrg /* Copyright (C) 2018-2020 Free Software Foundation, Inc.
2627f7eb2Smrg Contributed by Jakub Jelinek <jakub@redhat.com>.
3627f7eb2Smrg
4627f7eb2Smrg This file is part of the GNU Offloading and Multi Processing Library
5627f7eb2Smrg (libgomp).
6627f7eb2Smrg
7627f7eb2Smrg Libgomp is free software; you can redistribute it and/or modify it
8627f7eb2Smrg under the terms of the GNU General Public License as published by
9627f7eb2Smrg the Free Software Foundation; either version 3, or (at your option)
10627f7eb2Smrg any later version.
11627f7eb2Smrg
12627f7eb2Smrg Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
13627f7eb2Smrg WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14627f7eb2Smrg FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15627f7eb2Smrg more details.
16627f7eb2Smrg
17627f7eb2Smrg Under Section 7 of GPL version 3, you are granted additional
18627f7eb2Smrg permissions described in the GCC Runtime Library Exception, version
19627f7eb2Smrg 3.1, as published by the Free Software Foundation.
20627f7eb2Smrg
21627f7eb2Smrg You should have received a copy of the GNU General Public License and
22627f7eb2Smrg a copy of the GCC Runtime Library Exception along with this program;
23627f7eb2Smrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24627f7eb2Smrg <http://www.gnu.org/licenses/>. */
25627f7eb2Smrg
26627f7eb2Smrg /* This file handles the host TEAMS construct. */
27627f7eb2Smrg
28627f7eb2Smrg #include "libgomp.h"
29627f7eb2Smrg #include <limits.h>
30627f7eb2Smrg
31627f7eb2Smrg static unsigned gomp_num_teams = 1, gomp_team_num = 0;
32627f7eb2Smrg
33627f7eb2Smrg void
GOMP_teams_reg(void (* fn)(void *),void * data,unsigned int num_teams,unsigned int thread_limit,unsigned int flags)34627f7eb2Smrg GOMP_teams_reg (void (*fn) (void *), void *data, unsigned int num_teams,
35627f7eb2Smrg unsigned int thread_limit, unsigned int flags)
36627f7eb2Smrg {
37627f7eb2Smrg (void) flags;
38627f7eb2Smrg (void) num_teams;
39627f7eb2Smrg unsigned old_thread_limit_var = 0;
40627f7eb2Smrg if (thread_limit)
41627f7eb2Smrg {
42627f7eb2Smrg struct gomp_task_icv *icv = gomp_icv (true);
43627f7eb2Smrg old_thread_limit_var = icv->thread_limit_var;
44627f7eb2Smrg icv->thread_limit_var
45627f7eb2Smrg = thread_limit > INT_MAX ? UINT_MAX : thread_limit;
46627f7eb2Smrg }
47627f7eb2Smrg if (num_teams == 0)
48627f7eb2Smrg num_teams = 3;
49627f7eb2Smrg gomp_num_teams = num_teams;
50627f7eb2Smrg for (gomp_team_num = 0; gomp_team_num < num_teams; gomp_team_num++)
51627f7eb2Smrg fn (data);
52627f7eb2Smrg gomp_num_teams = 1;
53627f7eb2Smrg gomp_team_num = 0;
54627f7eb2Smrg if (thread_limit)
55627f7eb2Smrg {
56627f7eb2Smrg struct gomp_task_icv *icv = gomp_icv (true);
57627f7eb2Smrg icv->thread_limit_var = old_thread_limit_var;
58627f7eb2Smrg }
59627f7eb2Smrg }
60627f7eb2Smrg
61627f7eb2Smrg int
omp_get_num_teams(void)62627f7eb2Smrg omp_get_num_teams (void)
63627f7eb2Smrg {
64627f7eb2Smrg return gomp_num_teams;
65627f7eb2Smrg }
66627f7eb2Smrg
67627f7eb2Smrg int
omp_get_team_num(void)68627f7eb2Smrg omp_get_team_num (void)
69627f7eb2Smrg {
70627f7eb2Smrg return gomp_team_num;
71627f7eb2Smrg }
72627f7eb2Smrg
73627f7eb2Smrg ialias (omp_get_num_teams)
74627f7eb2Smrg ialias (omp_get_team_num)
75