target.c revision 1.1.1.2 1 1.1.1.2 mrg /* Copyright (C) 2013-2017 Free Software Foundation, Inc.
2 1.1.1.2 mrg Contributed by Jakub Jelinek <jakub (at) redhat.com>.
3 1.1.1.2 mrg
4 1.1.1.2 mrg This file is part of the GNU Offloading and Multi Processing Library
5 1.1.1.2 mrg (libgomp).
6 1.1.1.2 mrg
7 1.1.1.2 mrg Libgomp is free software; you can redistribute it and/or modify it
8 1.1.1.2 mrg under the terms of the GNU General Public License as published by
9 1.1.1.2 mrg the Free Software Foundation; either version 3, or (at your option)
10 1.1.1.2 mrg any later version.
11 1.1.1.2 mrg
12 1.1.1.2 mrg Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
13 1.1.1.2 mrg WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 1.1.1.2 mrg FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 1.1.1.2 mrg more details.
16 1.1.1.2 mrg
17 1.1.1.2 mrg Under Section 7 of GPL version 3, you are granted additional
18 1.1.1.2 mrg permissions described in the GCC Runtime Library Exception, version
19 1.1.1.2 mrg 3.1, as published by the Free Software Foundation.
20 1.1.1.2 mrg
21 1.1.1.2 mrg You should have received a copy of the GNU General Public License and
22 1.1.1.2 mrg a copy of the GCC Runtime Library Exception along with this program;
23 1.1.1.2 mrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 1.1.1.2 mrg <http://www.gnu.org/licenses/>. */
25 1.1.1.2 mrg
26 1.1.1.2 mrg #include "libgomp.h"
27 1.1.1.2 mrg #include <limits.h>
28 1.1.1.2 mrg
29 1.1.1.2 mrg void
30 1.1.1.2 mrg GOMP_teams (unsigned int num_teams, unsigned int thread_limit)
31 1.1.1.2 mrg {
32 1.1.1.2 mrg if (thread_limit)
33 1.1.1.2 mrg {
34 1.1.1.2 mrg struct gomp_task_icv *icv = gomp_icv (true);
35 1.1.1.2 mrg icv->thread_limit_var
36 1.1.1.2 mrg = thread_limit > INT_MAX ? UINT_MAX : thread_limit;
37 1.1.1.2 mrg }
38 1.1.1.2 mrg unsigned int num_blocks, block_id;
39 1.1.1.2 mrg asm ("mov.u32 %0, %%nctaid.x;" : "=r" (num_blocks));
40 1.1.1.2 mrg asm ("mov.u32 %0, %%ctaid.x;" : "=r" (block_id));
41 1.1.1.2 mrg if (!num_teams || num_teams >= num_blocks)
42 1.1.1.2 mrg num_teams = num_blocks;
43 1.1.1.2 mrg else if (block_id >= num_teams)
44 1.1.1.2 mrg {
45 1.1.1.2 mrg gomp_free_thread (nvptx_thrs);
46 1.1.1.2 mrg asm ("exit;");
47 1.1.1.2 mrg }
48 1.1.1.2 mrg gomp_num_teams_var = num_teams - 1;
49 1.1.1.2 mrg }
50