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