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