oacc-int.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* OpenACC Runtime - internal declarations
  2. Copyright (C) 2013-2015 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. /* This file contains data types and function declarations that are not
  22. part of the official OpenACC user interface. There are declarations
  23. in here that are part of the GNU OpenACC ABI, in that the compiler is
  24. required to know about them and use them.
  25. The convention is that the all caps prefix "GOACC" is used group items
  26. that are part of the external ABI, and the lower case prefix "goacc"
  27. is used group items that are completely private to the library. */
  28. #ifndef OACC_INT_H
  29. #define OACC_INT_H 1
  30. #include "openacc.h"
  31. #include "config.h"
  32. #include <stddef.h>
  33. #include <stdbool.h>
  34. #include <stdarg.h>
  35. #ifdef HAVE_ATTRIBUTE_VISIBILITY
  36. # pragma GCC visibility push(hidden)
  37. #endif
  38. static inline enum acc_device_t
  39. acc_device_type (enum offload_target_type type)
  40. {
  41. return (enum acc_device_t) type;
  42. }
  43. struct goacc_thread
  44. {
  45. /* The base device for the current thread. */
  46. struct gomp_device_descr *base_dev;
  47. /* The device for the current thread. */
  48. struct gomp_device_descr *dev;
  49. struct gomp_device_descr *saved_bound_dev;
  50. /* This is a linked list of data mapped by the "acc data" pragma, following
  51. strictly push/pop semantics according to lexical scope. */
  52. struct target_mem_desc *mapped_data;
  53. /* These structures form a list: this is the next thread in that list. */
  54. struct goacc_thread *next;
  55. /* Target-specific data (used by plugin). */
  56. void *target_tls;
  57. };
  58. #if defined HAVE_TLS || defined USE_EMUTLS
  59. extern __thread struct goacc_thread *goacc_tls_data;
  60. static inline struct goacc_thread *
  61. goacc_thread (void)
  62. {
  63. return goacc_tls_data;
  64. }
  65. #else
  66. extern pthread_key_t goacc_tls_key;
  67. static inline struct goacc_thread *
  68. goacc_thread (void)
  69. {
  70. return pthread_getspecific (goacc_tls_key);
  71. }
  72. #endif
  73. void goacc_register (struct gomp_device_descr *) __GOACC_NOTHROW;
  74. void goacc_attach_host_thread_to_device (int);
  75. void goacc_runtime_initialize (void);
  76. void goacc_save_and_set_bind (acc_device_t);
  77. void goacc_restore_bind (void);
  78. void goacc_lazy_initialize (void);
  79. #ifdef HAVE_ATTRIBUTE_VISIBILITY
  80. # pragma GCC visibility pop
  81. #endif
  82. #endif