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