Daily bump.
[official-gcc.git] / libgomp / target.c
blob46acc588dda463942b5f43be0af3d96b45a03527
1 /* Copyright (C) 2013-2014 Free Software Foundation, Inc.
2 Contributed by Jakub Jelinek <jakub@redhat.com>.
4 This file is part of the GNU OpenMP Library (libgomp).
6 Libgomp is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
11 Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
25 /* This file handles the maintainence of threads in response to team
26 creation and termination. */
28 #include "libgomp.h"
29 #include <limits.h>
30 #include <stdbool.h>
31 #include <stdlib.h>
32 #include <string.h>
34 attribute_hidden int
35 gomp_get_num_devices (void)
37 return 0;
40 /* Called when encountering a target directive. If DEVICE
41 is -1, it means use device-var ICV. If it is -2 (or any other value
42 larger than last available hw device, use host fallback.
43 FN is address of host code, OPENMP_TARGET contains value of the
44 __OPENMP_TARGET__ symbol in the shared library or binary that invokes
45 GOMP_target. HOSTADDRS, SIZES and KINDS are arrays
46 with MAPNUM entries, with addresses of the host objects,
47 sizes of the host objects (resp. for pointer kind pointer bias
48 and assumed sizeof (void *) size) and kinds. */
50 void
51 GOMP_target (int device, void (*fn) (void *), const void *openmp_target,
52 size_t mapnum, void **hostaddrs, size_t *sizes,
53 unsigned char *kinds)
55 /* Host fallback. */
56 struct gomp_thread old_thr, *thr = gomp_thread ();
57 old_thr = *thr;
58 memset (thr, '\0', sizeof (*thr));
59 if (gomp_places_list)
61 thr->place = old_thr.place;
62 thr->ts.place_partition_len = gomp_places_list_len;
64 fn (hostaddrs);
65 gomp_free_thread (thr);
66 *thr = old_thr;
69 void
70 GOMP_target_data (int device, const void *openmp_target, size_t mapnum,
71 void **hostaddrs, size_t *sizes, unsigned char *kinds)
75 void
76 GOMP_target_end_data (void)
80 void
81 GOMP_target_update (int device, const void *openmp_target, size_t mapnum,
82 void **hostaddrs, size_t *sizes, unsigned char *kinds)
86 void
87 GOMP_teams (unsigned int num_teams, unsigned int thread_limit)
89 if (thread_limit)
91 struct gomp_task_icv *icv = gomp_icv (true);
92 icv->thread_limit_var
93 = thread_limit > INT_MAX ? UINT_MAX : thread_limit;
95 (void) num_teams;