Testing of C/C++ OpenACC cache directive.
[official-gcc.git] / libgomp / oacc-cuda.c
blob3daf5b14f67d387b1833bb81a8c3f3e2056ab392
1 /* OpenACC Runtime Library: CUDA support glue.
3 Copyright (C) 2014 Free Software Foundation, Inc.
5 Contributed by Mentor Embedded.
7 This file is part of the GNU OpenMP Library (libgomp).
9 Libgomp is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
14 Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 more details.
19 Under Section 7 of GPL version 3, you are granted additional
20 permissions described in the GCC Runtime Library Exception, version
21 3.1, as published by the Free Software Foundation.
23 You should have received a copy of the GNU General Public License and
24 a copy of the GCC Runtime Library Exception along with this program;
25 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
26 <http://www.gnu.org/licenses/>. */
28 #include "openacc.h"
29 #include "config.h"
30 #include "libgomp.h"
31 #include "target.h"
32 #include "oacc-int.h"
34 void *
35 acc_get_current_cuda_device (void)
37 void *p = NULL;
39 if (base_dev && base_dev->openacc.cuda.get_current_device_func)
40 p = base_dev->openacc.cuda.get_current_device_func ();
42 return p;
45 void *
46 acc_get_current_cuda_context (void)
48 void *p = NULL;
50 if (base_dev && base_dev->openacc.cuda.get_current_context_func)
51 p = base_dev->openacc.cuda.get_current_context_func ();
53 return p;
56 void *
57 acc_get_cuda_stream (int async)
59 void *p = NULL;
61 if (async < 0)
62 return p;
64 if (base_dev && base_dev->openacc.cuda.get_stream_func)
65 p = base_dev->openacc.cuda.get_stream_func (async);
67 return p;
70 int
71 acc_set_cuda_stream (int async, void *stream)
73 int s = -1;
75 if (async < 0 || stream == NULL)
76 return 0;
78 ACC_lazy_initialize ();
80 if (base_dev && base_dev->openacc.cuda.set_stream_func)
81 s = base_dev->openacc.cuda.set_stream_func (async, stream);
83 return s;