openacc.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* OpenACC Runtime Library User-facing Declarations
  2. Copyright (C) 2013-2019 Free Software Foundation, Inc.
  3. Contributed by Mentor Embedded.
  4. This file is part of the GNU Offloading and Multi Processing Library
  5. (libgomp).
  6. Libgomp is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3, or (at your option)
  9. any later version.
  10. Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. more details.
  14. Under Section 7 of GPL version 3, you are granted additional
  15. permissions described in the GCC Runtime Library Exception, version
  16. 3.1, as published by the Free Software Foundation.
  17. You should have received a copy of the GNU General Public License and
  18. a copy of the GCC Runtime Library Exception along with this program;
  19. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  20. <http://www.gnu.org/licenses/>. */
  21. #ifndef _OPENACC_H
  22. #define _OPENACC_H 1
  23. /* The OpenACC standard is silent on whether or not including <openacc.h>
  24. might or must not include other header files. We chose to include
  25. some. */
  26. #include <stddef.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #if __cplusplus >= 201103
  31. # define __GOACC_NOTHROW noexcept
  32. #elif __cplusplus
  33. # define __GOACC_NOTHROW throw ()
  34. #else /* Not C++ */
  35. # define __GOACC_NOTHROW __attribute__ ((__nothrow__))
  36. #endif
  37. /* Types */
  38. typedef enum acc_device_t {
  39. /* Keep in sync with include/gomp-constants.h. */
  40. acc_device_none = 0,
  41. acc_device_default = 1,
  42. acc_device_host = 2,
  43. /* acc_device_host_nonshm = 3 removed. */
  44. acc_device_not_host = 4,
  45. acc_device_nvidia = 5,
  46. _ACC_device_hwm,
  47. /* Ensure enumeration is layout compatible with int. */
  48. _ACC_highest = __INT_MAX__,
  49. _ACC_neg = -1
  50. } acc_device_t;
  51. typedef enum acc_async_t {
  52. /* Keep in sync with include/gomp-constants.h. */
  53. acc_async_noval = -1,
  54. acc_async_sync = -2
  55. } acc_async_t;
  56. int acc_get_num_devices (acc_device_t) __GOACC_NOTHROW;
  57. void acc_set_device_type (acc_device_t) __GOACC_NOTHROW;
  58. acc_device_t acc_get_device_type (void) __GOACC_NOTHROW;
  59. void acc_set_device_num (int, acc_device_t) __GOACC_NOTHROW;
  60. int acc_get_device_num (acc_device_t) __GOACC_NOTHROW;
  61. int acc_async_test (int) __GOACC_NOTHROW;
  62. int acc_async_test_all (void) __GOACC_NOTHROW;
  63. void acc_wait (int) __GOACC_NOTHROW;
  64. void acc_async_wait (int) __GOACC_NOTHROW;
  65. void acc_wait_async (int, int) __GOACC_NOTHROW;
  66. void acc_wait_all (void) __GOACC_NOTHROW;
  67. void acc_async_wait_all (void) __GOACC_NOTHROW;
  68. void acc_wait_all_async (int) __GOACC_NOTHROW;
  69. void acc_init (acc_device_t) __GOACC_NOTHROW;
  70. void acc_shutdown (acc_device_t) __GOACC_NOTHROW;
  71. #ifdef __cplusplus
  72. int acc_on_device (int __arg) __GOACC_NOTHROW;
  73. #else
  74. int acc_on_device (acc_device_t __arg) __GOACC_NOTHROW;
  75. #endif
  76. void *acc_malloc (size_t) __GOACC_NOTHROW;
  77. void acc_free (void *) __GOACC_NOTHROW;
  78. /* Some of these would be more correct with const qualifiers, but
  79. the standard specifies otherwise. */
  80. void *acc_copyin (void *, size_t) __GOACC_NOTHROW;
  81. void *acc_present_or_copyin (void *, size_t) __GOACC_NOTHROW;
  82. void *acc_pcopyin (void *, size_t) __GOACC_NOTHROW;
  83. void *acc_create (void *, size_t) __GOACC_NOTHROW;
  84. void *acc_present_or_create (void *, size_t) __GOACC_NOTHROW;
  85. void *acc_pcreate (void *, size_t) __GOACC_NOTHROW;
  86. void acc_copyout (void *, size_t) __GOACC_NOTHROW;
  87. void acc_delete (void *, size_t) __GOACC_NOTHROW;
  88. void acc_update_device (void *, size_t) __GOACC_NOTHROW;
  89. void acc_update_self (void *, size_t) __GOACC_NOTHROW;
  90. void acc_map_data (void *, void *, size_t) __GOACC_NOTHROW;
  91. void acc_unmap_data (void *) __GOACC_NOTHROW;
  92. void *acc_deviceptr (void *) __GOACC_NOTHROW;
  93. void *acc_hostptr (void *) __GOACC_NOTHROW;
  94. int acc_is_present (void *, size_t) __GOACC_NOTHROW;
  95. void acc_memcpy_to_device (void *, void *, size_t) __GOACC_NOTHROW;
  96. void acc_memcpy_from_device (void *, void *, size_t) __GOACC_NOTHROW;
  97. /* Finalize versions of copyout/delete functions, specified in OpenACC 2.5. */
  98. void acc_copyout_finalize (void *, size_t) __GOACC_NOTHROW;
  99. void acc_copyout_finalize_async (void *, size_t, int) __GOACC_NOTHROW;
  100. void acc_delete_finalize (void *, size_t) __GOACC_NOTHROW;
  101. void acc_delete_finalize_async (void *, size_t, int) __GOACC_NOTHROW;
  102. /* Async functions, specified in OpenACC 2.5. */
  103. void acc_copyin_async (void *, size_t, int) __GOACC_NOTHROW;
  104. void acc_create_async (void *, size_t, int) __GOACC_NOTHROW;
  105. void acc_copyout_async (void *, size_t, int) __GOACC_NOTHROW;
  106. void acc_delete_async (void *, size_t, int) __GOACC_NOTHROW;
  107. void acc_update_device_async (void *, size_t, int) __GOACC_NOTHROW;
  108. void acc_update_self_async (void *, size_t, int) __GOACC_NOTHROW;
  109. void acc_memcpy_to_device_async (void *, void *, size_t, int) __GOACC_NOTHROW;
  110. void acc_memcpy_from_device_async (void *, void *, size_t, int) __GOACC_NOTHROW;
  111. /* CUDA-specific routines. */
  112. void *acc_get_current_cuda_device (void) __GOACC_NOTHROW;
  113. void *acc_get_current_cuda_context (void) __GOACC_NOTHROW;
  114. void *acc_get_cuda_stream (int) __GOACC_NOTHROW;
  115. int acc_set_cuda_stream (int, void *) __GOACC_NOTHROW;
  116. #ifdef __cplusplus
  117. }
  118. /* Forwarding function with correctly typed arg. */
  119. #pragma acc routine seq
  120. inline int acc_on_device (acc_device_t __arg) __GOACC_NOTHROW
  121. {
  122. return acc_on_device ((int) __arg);
  123. }
  124. #endif
  125. #endif /* _OPENACC_H */