10Sstevel@tonic-gate/* Copyright (C) 2018-2020 Free Software Foundation, Inc.
20Sstevel@tonic-gate   Contributed by Jakub Jelinek <jakub@redhat.com>.
30Sstevel@tonic-gate
40Sstevel@tonic-gate   This file is part of the GNU Offloading and Multi Processing Library
50Sstevel@tonic-gate   (libgomp).
60Sstevel@tonic-gate
70Sstevel@tonic-gate   Libgomp is free software; you can redistribute it and/or modify it
80Sstevel@tonic-gate   under the terms of the GNU General Public License as published by
90Sstevel@tonic-gate   the Free Software Foundation; either version 3, or (at your option)
100Sstevel@tonic-gate   any later version.
110Sstevel@tonic-gate
120Sstevel@tonic-gate   Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
130Sstevel@tonic-gate   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
140Sstevel@tonic-gate   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
150Sstevel@tonic-gate   more details.
160Sstevel@tonic-gate
170Sstevel@tonic-gate   Under Section 7 of GPL version 3, you are granted additional
180Sstevel@tonic-gate   permissions described in the GCC Runtime Library Exception, version
190Sstevel@tonic-gate   3.1, as published by the Free Software Foundation.
200Sstevel@tonic-gate
210Sstevel@tonic-gate   You should have received a copy of the GNU General Public License and
220Sstevel@tonic-gate   a copy of the GCC Runtime Library Exception along with this program;
230Sstevel@tonic-gate   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
240Sstevel@tonic-gate   <http://www.gnu.org/licenses/>.  */
250Sstevel@tonic-gate
260Sstevel@tonic-gate/* This file handles the host TEAMS construct.  */
270Sstevel@tonic-gate
280Sstevel@tonic-gate#include "libgomp.h"
290Sstevel@tonic-gate#include <limits.h>
300Sstevel@tonic-gate
310Sstevel@tonic-gatestatic unsigned gomp_num_teams = 1, gomp_team_num = 0;
320Sstevel@tonic-gate
330Sstevel@tonic-gatevoid
340Sstevel@tonic-gateGOMP_teams_reg (void (*fn) (void *), void *data, unsigned int num_teams,
350Sstevel@tonic-gate		unsigned int thread_limit, unsigned int flags)
360Sstevel@tonic-gate{
370Sstevel@tonic-gate  (void) flags;
380Sstevel@tonic-gate  (void) num_teams;
390Sstevel@tonic-gate  unsigned old_thread_limit_var = 0;
400Sstevel@tonic-gate  if (thread_limit)
410Sstevel@tonic-gate    {
420Sstevel@tonic-gate      struct gomp_task_icv *icv = gomp_icv (true);
430Sstevel@tonic-gate      old_thread_limit_var = icv->thread_limit_var;
440Sstevel@tonic-gate      icv->thread_limit_var
450Sstevel@tonic-gate	= thread_limit > INT_MAX ? UINT_MAX : thread_limit;
460Sstevel@tonic-gate    }
470Sstevel@tonic-gate  if (num_teams == 0)
480Sstevel@tonic-gate    num_teams = 3;
490Sstevel@tonic-gate  gomp_num_teams = num_teams;
500Sstevel@tonic-gate  for (gomp_team_num = 0; gomp_team_num < num_teams; gomp_team_num++)
510Sstevel@tonic-gate    fn (data);
520Sstevel@tonic-gate  gomp_num_teams = 1;
530Sstevel@tonic-gate  gomp_team_num = 0;
540Sstevel@tonic-gate  if (thread_limit)
550Sstevel@tonic-gate    {
560Sstevel@tonic-gate      struct gomp_task_icv *icv = gomp_icv (true);
570Sstevel@tonic-gate      icv->thread_limit_var = old_thread_limit_var;
580Sstevel@tonic-gate    }
590Sstevel@tonic-gate}
600Sstevel@tonic-gate
610Sstevel@tonic-gateint
620Sstevel@tonic-gateomp_get_num_teams (void)
630Sstevel@tonic-gate{
640Sstevel@tonic-gate  return gomp_num_teams;
650Sstevel@tonic-gate}
660Sstevel@tonic-gate
670Sstevel@tonic-gateint
680Sstevel@tonic-gateomp_get_team_num (void)
690Sstevel@tonic-gate{
700Sstevel@tonic-gate  return gomp_team_num;
710Sstevel@tonic-gate}
720Sstevel@tonic-gate
730Sstevel@tonic-gateialias (omp_get_num_teams)
740Sstevel@tonic-gateialias (omp_get_team_num)
750Sstevel@tonic-gate