libgomp updates.
[official-gcc.git] / libgomp / openacc.h
blob4ac13651c9b6c8224a2eaee778ed107d9ba05554
1 /* OpenACC Runtime Library User-facing Declarations
3 Copyright (C) 2013-2014 Free Software Foundation, Inc.
5 Contributed by Mentor Embedded.
7 This file is part of the GNU Offloading and Multi Processing Library
8 (libgomp).
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.
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.
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.
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/>. */
29 #ifndef _OPENACC_H
30 #define _OPENACC_H 1
32 #include "gomp-constants.h"
34 /* The OpenACC std is silent on whether or not including openacc.h
35 might or must not include other header files. We chose to include
36 some. */
37 #include <stddef.h>
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
43 #if __cplusplus >= 201103
44 # define __GOACC_NOTHROW noexcept ()
45 #elif __cplusplus
46 # define __GOACC_NOTHROW throw ()
47 #else /* Not C++ */
48 # define __GOACC_NOTHROW __attribute__ ((__nothrow__))
49 #endif
51 /* Types */
52 typedef enum acc_device_t
54 acc_device_none = 0,
55 acc_device_default, /* This has to be a distinct value, as no
56 return value can match it. */
57 acc_device_host = GOMP_TARGET_HOST,
58 acc_device_host_nonshm = GOMP_TARGET_HOST_NONSHM,
59 acc_device_not_host,
60 acc_device_nvidia = GOMP_TARGET_NVIDIA_PTX,
61 _ACC_device_hwm
62 } acc_device_t;
64 typedef enum acc_async_t
66 acc_async_noval = -1,
67 acc_async_sync = -2
68 } acc_async_t;
70 int acc_get_num_devices (acc_device_t __dev) __GOACC_NOTHROW;
71 void acc_set_device_type (acc_device_t __dev) __GOACC_NOTHROW;
72 acc_device_t acc_get_device_type (void) __GOACC_NOTHROW;
73 void acc_set_device_num (int __num, acc_device_t __dev) __GOACC_NOTHROW;
74 int acc_get_device_num (acc_device_t __dev) __GOACC_NOTHROW;
75 int acc_async_test (int __async) __GOACC_NOTHROW;
76 int acc_async_test_all (void) __GOACC_NOTHROW;
77 void acc_wait (int __async) __GOACC_NOTHROW;
78 void acc_wait_async (int __async1, int __async2) __GOACC_NOTHROW;
79 void acc_wait_all (void) __GOACC_NOTHROW;
80 void acc_wait_all_async (int __async) __GOACC_NOTHROW;
81 void acc_init (acc_device_t __dev) __GOACC_NOTHROW;
82 void acc_shutdown (acc_device_t __dev) __GOACC_NOTHROW;
83 int acc_on_device (acc_device_t __dev) __GOACC_NOTHROW;
84 void *acc_malloc (size_t) __GOACC_NOTHROW;
85 void acc_free (void *) __GOACC_NOTHROW;
86 /* Some of these would be more correct with const qualifiers, but
87 the standard specifies otherwise. */
88 void *acc_copyin (void *, size_t) __GOACC_NOTHROW;
89 void *acc_present_or_copyin (void *, size_t) __GOACC_NOTHROW;
90 void *acc_create (void *, size_t) __GOACC_NOTHROW;
91 void *acc_present_or_create (void *, size_t) __GOACC_NOTHROW;
92 void acc_copyout (void *, size_t) __GOACC_NOTHROW;
93 void acc_delete (void *, size_t) __GOACC_NOTHROW;
94 void acc_update_device (void *, size_t) __GOACC_NOTHROW;
95 void acc_update_self (void *, size_t) __GOACC_NOTHROW;
96 void acc_map_data (void *, void *, size_t) __GOACC_NOTHROW;
97 void acc_unmap_data (void *) __GOACC_NOTHROW;
98 void *acc_deviceptr (void *) __GOACC_NOTHROW;
99 void *acc_hostptr (void *) __GOACC_NOTHROW;
100 int acc_is_present (void *, size_t) __GOACC_NOTHROW;
101 void acc_memcpy_to_device (void *, void *, size_t) __GOACC_NOTHROW;
102 void acc_memcpy_from_device (void *, void *, size_t) __GOACC_NOTHROW;
104 void ACC_target (int, void (*) (void *), const void *,
105 size_t, void **, size_t *, unsigned char *, int *) __GOACC_NOTHROW;
106 void ACC_parallel (int, void (*) (void *), const void *,
107 size_t, void **, size_t *, unsigned char *) __GOACC_NOTHROW;
108 void ACC_add_device_code (void const *, char const *) __GOACC_NOTHROW;
110 void ACC_async_copy (int) __GOACC_NOTHROW;
111 void ACC_async_kern (int) __GOACC_NOTHROW;
113 /* Old names. OpenACC does not specify whether these can or must
114 not be macros, inlines or aliases for the new names. */
115 #define acc_pcreate acc_present_or_create
116 #define acc_pcopyin acc_present_or_copyin
118 /* CUDA-specific routines. */
119 void *acc_get_current_cuda_device (void) __GOACC_NOTHROW;
120 void *acc_get_current_cuda_context (void) __GOACC_NOTHROW;
121 void *acc_get_cuda_stream (int __async) __GOACC_NOTHROW;
122 int acc_set_cuda_stream (int __async, void *__stream) __GOACC_NOTHROW;
124 #ifdef __cplusplus
126 #endif
128 #endif /* _OPENACC_H */