1/* OpenACC Runtime Library User-facing Declarations 2 3 Copyright (C) 2013-2020 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#ifndef _OPENACC_H 30#define _OPENACC_H 1 31 32/* The OpenACC standard is silent on whether or not including <openacc.h> 33 might or must not include other header files. We chose to include 34 some. */ 35#include <stddef.h> 36 37#ifdef __cplusplus 38extern "C" { 39#endif 40 41#if __cplusplus >= 201103 42# define __GOACC_NOTHROW noexcept 43#elif __cplusplus 44# define __GOACC_NOTHROW throw () 45#else /* Not C++ */ 46# define __GOACC_NOTHROW __attribute__ ((__nothrow__)) 47#endif 48 49/* Types */ 50typedef enum acc_device_t { 51 /* Keep in sync with include/gomp-constants.h. */ 52 acc_device_current = -1, 53 acc_device_none = 0, 54 acc_device_default = 1, 55 acc_device_host = 2, 56 /* acc_device_host_nonshm = 3 removed. */ 57 acc_device_not_host = 4, 58 acc_device_nvidia = 5, 59 acc_device_radeon = 8, 60 _ACC_device_hwm, 61 /* Ensure enumeration is layout compatible with int. */ 62 _ACC_highest = __INT_MAX__, 63 _ACC_neg = -1 64} acc_device_t; 65 66typedef enum acc_device_property_t { 67 /* Keep in sync with 'libgomp/libgomp-plugin.h:goacc_property'. */ 68 acc_property_memory = 1, 69 acc_property_free_memory = 2, 70 acc_property_name = 0x10001, 71 acc_property_vendor = 0x10002, 72 acc_property_driver = 0x10003 73} acc_device_property_t; 74 75typedef enum acc_async_t { 76 /* Keep in sync with include/gomp-constants.h. */ 77 acc_async_noval = -1, 78 acc_async_sync = -2 79} acc_async_t; 80 81int acc_get_num_devices (acc_device_t) __GOACC_NOTHROW; 82void acc_set_device_type (acc_device_t) __GOACC_NOTHROW; 83acc_device_t acc_get_device_type (void) __GOACC_NOTHROW; 84void acc_set_device_num (int, acc_device_t) __GOACC_NOTHROW; 85int acc_get_device_num (acc_device_t) __GOACC_NOTHROW; 86size_t acc_get_property 87 (int, acc_device_t, acc_device_property_t) __GOACC_NOTHROW; 88const char *acc_get_property_string 89 (int, acc_device_t, acc_device_property_t) __GOACC_NOTHROW; 90int acc_async_test (int) __GOACC_NOTHROW; 91int acc_async_test_all (void) __GOACC_NOTHROW; 92void acc_wait (int) __GOACC_NOTHROW; 93void acc_async_wait (int) __GOACC_NOTHROW; 94void acc_wait_async (int, int) __GOACC_NOTHROW; 95void acc_wait_all (void) __GOACC_NOTHROW; 96void acc_async_wait_all (void) __GOACC_NOTHROW; 97void acc_wait_all_async (int) __GOACC_NOTHROW; 98void acc_init (acc_device_t) __GOACC_NOTHROW; 99void acc_shutdown (acc_device_t) __GOACC_NOTHROW; 100#ifdef __cplusplus 101int acc_on_device (int __arg) __GOACC_NOTHROW; 102#else 103int acc_on_device (acc_device_t __arg) __GOACC_NOTHROW; 104#endif 105void *acc_malloc (size_t) __GOACC_NOTHROW; 106void acc_free (void *) __GOACC_NOTHROW; 107/* Some of these would be more correct with const qualifiers, but 108 the standard specifies otherwise. */ 109void *acc_copyin (void *, size_t) __GOACC_NOTHROW; 110void *acc_present_or_copyin (void *, size_t) __GOACC_NOTHROW; 111void *acc_pcopyin (void *, size_t) __GOACC_NOTHROW; 112void *acc_create (void *, size_t) __GOACC_NOTHROW; 113void *acc_present_or_create (void *, size_t) __GOACC_NOTHROW; 114void *acc_pcreate (void *, size_t) __GOACC_NOTHROW; 115void acc_copyout (void *, size_t) __GOACC_NOTHROW; 116void acc_delete (void *, size_t) __GOACC_NOTHROW; 117void acc_update_device (void *, size_t) __GOACC_NOTHROW; 118void acc_update_self (void *, size_t) __GOACC_NOTHROW; 119void acc_map_data (void *, void *, size_t) __GOACC_NOTHROW; 120void acc_unmap_data (void *) __GOACC_NOTHROW; 121void *acc_deviceptr (void *) __GOACC_NOTHROW; 122void *acc_hostptr (void *) __GOACC_NOTHROW; 123int acc_is_present (void *, size_t) __GOACC_NOTHROW; 124void acc_memcpy_to_device (void *, void *, size_t) __GOACC_NOTHROW; 125void acc_memcpy_from_device (void *, void *, size_t) __GOACC_NOTHROW; 126void acc_attach (void **) __GOACC_NOTHROW; 127void acc_attach_async (void **, int) __GOACC_NOTHROW; 128void acc_detach (void **) __GOACC_NOTHROW; 129void acc_detach_async (void **, int) __GOACC_NOTHROW; 130 131/* Finalize versions of copyout/delete functions, specified in OpenACC 2.5. */ 132void acc_copyout_finalize (void *, size_t) __GOACC_NOTHROW; 133void acc_copyout_finalize_async (void *, size_t, int) __GOACC_NOTHROW; 134void acc_delete_finalize (void *, size_t) __GOACC_NOTHROW; 135void acc_delete_finalize_async (void *, size_t, int) __GOACC_NOTHROW; 136void acc_detach_finalize (void **) __GOACC_NOTHROW; 137void acc_detach_finalize_async (void **, int) __GOACC_NOTHROW; 138 139/* Async functions, specified in OpenACC 2.5. */ 140void acc_copyin_async (void *, size_t, int) __GOACC_NOTHROW; 141void acc_create_async (void *, size_t, int) __GOACC_NOTHROW; 142void acc_copyout_async (void *, size_t, int) __GOACC_NOTHROW; 143void acc_delete_async (void *, size_t, int) __GOACC_NOTHROW; 144void acc_update_device_async (void *, size_t, int) __GOACC_NOTHROW; 145void acc_update_self_async (void *, size_t, int) __GOACC_NOTHROW; 146void acc_memcpy_to_device_async (void *, void *, size_t, int) __GOACC_NOTHROW; 147void acc_memcpy_from_device_async (void *, void *, size_t, int) __GOACC_NOTHROW; 148 149/* CUDA-specific routines. */ 150void *acc_get_current_cuda_device (void) __GOACC_NOTHROW; 151void *acc_get_current_cuda_context (void) __GOACC_NOTHROW; 152void *acc_get_cuda_stream (int) __GOACC_NOTHROW; 153int acc_set_cuda_stream (int, void *) __GOACC_NOTHROW; 154 155#ifdef __cplusplus 156} 157 158/* Forwarding function with correctly typed arg. */ 159 160#pragma acc routine seq 161inline int acc_on_device (acc_device_t __arg) __GOACC_NOTHROW 162{ 163 return acc_on_device ((int) __arg); 164} 165#endif 166 167#endif /* _OPENACC_H */ 168