annotate libgomp/oacc-cuda.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* OpenACC Runtime Library: CUDA support glue.
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 Copyright (C) 2014-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 Contributed by Mentor Embedded.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 This file is part of the GNU Offloading and Multi Processing Library
kono
parents:
diff changeset
8 (libgomp).
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 Libgomp is free software; you can redistribute it and/or modify it
kono
parents:
diff changeset
11 under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
12 the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
13 any later version.
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
kono
parents:
diff changeset
17 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
kono
parents:
diff changeset
18 more details.
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 Under Section 7 of GPL version 3, you are granted additional
kono
parents:
diff changeset
21 permissions described in the GCC Runtime Library Exception, version
kono
parents:
diff changeset
22 3.1, as published by the Free Software Foundation.
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 You should have received a copy of the GNU General Public License and
kono
parents:
diff changeset
25 a copy of the GCC Runtime Library Exception along with this program;
kono
parents:
diff changeset
26 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
kono
parents:
diff changeset
27 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 #include "openacc.h"
kono
parents:
diff changeset
30 #include "config.h"
kono
parents:
diff changeset
31 #include "libgomp.h"
kono
parents:
diff changeset
32 #include "oacc-int.h"
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 void *
kono
parents:
diff changeset
35 acc_get_current_cuda_device (void)
kono
parents:
diff changeset
36 {
kono
parents:
diff changeset
37 struct goacc_thread *thr = goacc_thread ();
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 if (thr && thr->dev && thr->dev->openacc.cuda.get_current_device_func)
kono
parents:
diff changeset
40 return thr->dev->openacc.cuda.get_current_device_func ();
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 return NULL;
kono
parents:
diff changeset
43 }
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 void *
kono
parents:
diff changeset
46 acc_get_current_cuda_context (void)
kono
parents:
diff changeset
47 {
kono
parents:
diff changeset
48 struct goacc_thread *thr = goacc_thread ();
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 if (thr && thr->dev && thr->dev->openacc.cuda.get_current_context_func)
kono
parents:
diff changeset
51 return thr->dev->openacc.cuda.get_current_context_func ();
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 return NULL;
kono
parents:
diff changeset
54 }
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 void *
kono
parents:
diff changeset
57 acc_get_cuda_stream (int async)
kono
parents:
diff changeset
58 {
kono
parents:
diff changeset
59 struct goacc_thread *thr = goacc_thread ();
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 if (async < 0)
kono
parents:
diff changeset
62 return NULL;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 if (thr && thr->dev && thr->dev->openacc.cuda.get_stream_func)
kono
parents:
diff changeset
65 return thr->dev->openacc.cuda.get_stream_func (async);
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 return NULL;
kono
parents:
diff changeset
68 }
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 int
kono
parents:
diff changeset
71 acc_set_cuda_stream (int async, void *stream)
kono
parents:
diff changeset
72 {
kono
parents:
diff changeset
73 struct goacc_thread *thr;
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 if (async < 0 || stream == NULL)
kono
parents:
diff changeset
76 return 0;
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 goacc_lazy_initialize ();
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 thr = goacc_thread ();
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 if (thr && thr->dev && thr->dev->openacc.cuda.set_stream_func)
kono
parents:
diff changeset
83 return thr->dev->openacc.cuda.set_stream_func (async, stream);
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 return -1;
kono
parents:
diff changeset
86 }