compiler_if_host.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*
  2. Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions
  5. are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of Intel Corporation nor the names of its
  12. contributors may be used to endorse or promote products derived
  13. from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  15. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  16. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  18. HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  19. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  20. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  21. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  22. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. /*! \file
  27. \brief The interface between compiler-generated host code and runtime library
  28. */
  29. #ifndef COMPILER_IF_HOST_H_INCLUDED
  30. #define COMPILER_IF_HOST_H_INCLUDED
  31. #include "offload_host.h"
  32. #define OFFLOAD_TARGET_ACQUIRE OFFLOAD_PREFIX(target_acquire)
  33. #define OFFLOAD_TARGET_ACQUIRE1 OFFLOAD_PREFIX(target_acquire1)
  34. #define OFFLOAD_TARGET_ACQUIRE2 OFFLOAD_PREFIX(target_acquire2)
  35. #define OFFLOAD_OFFLOAD OFFLOAD_PREFIX(offload)
  36. #define OFFLOAD_OFFLOAD1 OFFLOAD_PREFIX(offload1)
  37. #define OFFLOAD_OFFLOAD2 OFFLOAD_PREFIX(offload2)
  38. #define OFFLOAD_OFFLOAD3 OFFLOAD_PREFIX(offload3)
  39. #define OFFLOAD_CALL_COUNT OFFLOAD_PREFIX(offload_call_count)
  40. /*! \fn OFFLOAD_TARGET_ACQUIRE
  41. \brief Attempt to acquire the target.
  42. \param target_type The type of target.
  43. \param target_number The device number.
  44. \param is_optional Whether CPU fall-back is allowed.
  45. \param status Address of variable to hold offload status.
  46. \param file Filename in which this offload occurred.
  47. \param line Line number in the file where this offload occurred.
  48. */
  49. extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE(
  50. TARGET_TYPE target_type,
  51. int target_number,
  52. int is_optional,
  53. _Offload_status* status,
  54. const char* file,
  55. uint64_t line
  56. );
  57. /*! \fn OFFLOAD_TARGET_ACQUIRE1
  58. \brief Acquire the target for offload (OpenMP).
  59. \param device_number Device number or null if not specified.
  60. \param file Filename in which this offload occurred
  61. \param line Line number in the file where this offload occurred.
  62. */
  63. extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE1(
  64. const int* device_number,
  65. const char* file,
  66. uint64_t line
  67. );
  68. /*! \fn OFFLOAD_TARGET_ACQUIRE2
  69. \brief Attempt to acquire the target.
  70. \param target_type The type of target.
  71. \param target_number The device number.
  72. \param is_optional Whether CPU fall-back is allowed.
  73. \param status Address of variable to hold offload status.
  74. \param file Filename in which this offload occurred.
  75. \param line Line number in the file where this offload occurred.
  76. \param stream Pointer to stream value.
  77. */
  78. extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE2(
  79. TARGET_TYPE target_type,
  80. int target_number,
  81. int is_optional,
  82. _Offload_status* status,
  83. const char* file,
  84. uint64_t line,
  85. const void** stream
  86. );
  87. /*! \fn OFFLOAD_OFFLOAD1
  88. \brief Run function on target using interface for old data persistence.
  89. \param o Offload descriptor created by OFFLOAD_TARGET_ACQUIRE.
  90. \param name Name of offload entry point.
  91. \param is_empty If no code to execute (e.g. offload_transfer)
  92. \param num_vars Number of variable descriptors.
  93. \param vars Pointer to VarDesc array.
  94. \param vars2 Pointer to VarDesc2 array.
  95. \param num_waits Number of "wait" values.
  96. \param waits Pointer to array of wait values.
  97. \param signal Pointer to signal value or NULL.
  98. */
  99. extern "C" int OFFLOAD_OFFLOAD1(
  100. OFFLOAD o,
  101. const char *name,
  102. int is_empty,
  103. int num_vars,
  104. VarDesc *vars,
  105. VarDesc2 *vars2,
  106. int num_waits,
  107. const void** waits,
  108. const void** signal
  109. );
  110. /*! \fn OFFLOAD_OFFLOAD2
  111. \brief Run function on target using interface for new data persistence.
  112. \param o Offload descriptor created by OFFLOAD_TARGET_ACQUIRE.
  113. \param name Name of offload entry point.
  114. \param is_empty If no code to execute (e.g. offload_transfer)
  115. \param num_vars Number of variable descriptors.
  116. \param vars Pointer to VarDesc array.
  117. \param vars2 Pointer to VarDesc2 array.
  118. \param num_waits Number of "wait" values.
  119. \param waits Pointer to array of wait values.
  120. \param signal Pointer to signal value or NULL.
  121. \param entry_id A signature for the function doing the offload.
  122. \param stack_addr The stack frame address of the function doing offload.
  123. */
  124. extern "C" int OFFLOAD_OFFLOAD2(
  125. OFFLOAD o,
  126. const char *name,
  127. int is_empty,
  128. int num_vars,
  129. VarDesc *vars,
  130. VarDesc2 *vars2,
  131. int num_waits,
  132. const void** waits,
  133. const void** signal,
  134. int entry_id,
  135. const void *stack_addr
  136. );
  137. /*! \fn OFFLOAD_OFFLOAD3
  138. \brief Run function on target, API introduced in 15.0 Update 1
  139. \brief when targetptr, preallocated feature was introduced.
  140. \param o Offload descriptor created by OFFLOAD_TARGET_ACQUIRE.
  141. \param name Name of offload entry point.
  142. \param is_empty If no code to execute (e.g. offload_transfer)
  143. \param num_vars Number of variable descriptors.
  144. \param vars Pointer to VarDesc array.
  145. \param vars2 Pointer to VarDesc2 array.
  146. \param num_waits Number of "wait" values.
  147. \param waits Pointer to array of wait values.
  148. \param signal Pointer to signal value or NULL.
  149. \param entry_id A signature for the function doing the offload.
  150. \param stack_addr The stack frame address of the function doing offload.
  151. \param offload_flags Flags to indicate Fortran traceback, OpenMP async.
  152. \param stream Pointer to stream value or NULL.
  153. */
  154. extern "C" int OFFLOAD_OFFLOAD3(
  155. OFFLOAD ofld,
  156. const char *name,
  157. int is_empty,
  158. int num_vars,
  159. VarDesc *vars,
  160. VarDesc2 *vars2,
  161. int num_waits,
  162. const void** waits,
  163. const void** signal,
  164. int entry_id,
  165. const void *stack_addr,
  166. OffloadFlags offload_flags,
  167. const void** stream
  168. );
  169. // Run function on target (obsolete).
  170. // @param o OFFLOAD object
  171. // @param name function name
  172. extern "C" int OFFLOAD_OFFLOAD(
  173. OFFLOAD o,
  174. const char *name,
  175. int is_empty,
  176. int num_vars,
  177. VarDesc *vars,
  178. VarDesc2 *vars2,
  179. int num_waits,
  180. const void** waits,
  181. const void* signal,
  182. int entry_id = 0,
  183. const void *stack_addr = NULL
  184. );
  185. // Global counter on host.
  186. // This variable is used if P2OPT_offload_do_data_persistence == 2.
  187. // The variable used to identify offload constructs contained in one procedure.
  188. // Call to OFFLOAD_CALL_COUNT() is inserted at HOST on entry of the routine.
  189. extern "C" int OFFLOAD_CALL_COUNT();
  190. #endif // COMPILER_IF_HOST_H_INCLUDED