compiler_if_host.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. Copyright (c) 2014 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_OFFLOAD OFFLOAD_PREFIX(offload)
  35. #define OFFLOAD_OFFLOAD1 OFFLOAD_PREFIX(offload1)
  36. #define OFFLOAD_OFFLOAD2 OFFLOAD_PREFIX(offload2)
  37. #define OFFLOAD_CALL_COUNT OFFLOAD_PREFIX(offload_call_count)
  38. /*! \fn OFFLOAD_TARGET_ACQUIRE
  39. \brief Attempt to acquire the target.
  40. \param target_type The type of target.
  41. \param target_number The device number.
  42. \param is_optional Whether CPU fall-back is allowed.
  43. \param status Address of variable to hold offload status.
  44. \param file Filename in which this offload occurred.
  45. \param line Line number in the file where this offload occurred.
  46. */
  47. extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE(
  48. TARGET_TYPE target_type,
  49. int target_number,
  50. int is_optional,
  51. _Offload_status* status,
  52. const char* file,
  53. uint64_t line
  54. );
  55. /*! \fn OFFLOAD_TARGET_ACQUIRE1
  56. \brief Acquire the target for offload (OpenMP).
  57. \param device_number Device number or null if not specified.
  58. \param file Filename in which this offload occurred
  59. \param line Line number in the file where this offload occurred.
  60. */
  61. extern "C" OFFLOAD OFFLOAD_TARGET_ACQUIRE1(
  62. const int* device_number,
  63. const char* file,
  64. uint64_t line
  65. );
  66. /*! \fn OFFLOAD_OFFLOAD1
  67. \brief Run function on target using interface for old data persistence.
  68. \param o Offload descriptor created by OFFLOAD_TARGET_ACQUIRE.
  69. \param name Name of offload entry point.
  70. \param is_empty If no code to execute (e.g. offload_transfer)
  71. \param num_vars Number of variable descriptors.
  72. \param vars Pointer to VarDesc array.
  73. \param vars2 Pointer to VarDesc2 array.
  74. \param num_waits Number of "wait" values.
  75. \param waits Pointer to array of wait values.
  76. \param signal Pointer to signal value or NULL.
  77. */
  78. extern "C" int OFFLOAD_OFFLOAD1(
  79. OFFLOAD o,
  80. const char *name,
  81. int is_empty,
  82. int num_vars,
  83. VarDesc *vars,
  84. VarDesc2 *vars2,
  85. int num_waits,
  86. const void** waits,
  87. const void** signal
  88. );
  89. /*! \fn OFFLOAD_OFFLOAD2
  90. \brief Run function on target using interface for new data persistence.
  91. \param o Offload descriptor created by OFFLOAD_TARGET_ACQUIRE.
  92. \param name Name of offload entry point.
  93. \param is_empty If no code to execute (e.g. offload_transfer)
  94. \param num_vars Number of variable descriptors.
  95. \param vars Pointer to VarDesc array.
  96. \param vars2 Pointer to VarDesc2 array.
  97. \param num_waits Number of "wait" values.
  98. \param waits Pointer to array of wait values.
  99. \param signal Pointer to signal value or NULL.
  100. \param entry_id A signature for the function doing the offload.
  101. \param stack_addr The stack frame address of the function doing offload.
  102. */
  103. extern "C" int OFFLOAD_OFFLOAD2(
  104. OFFLOAD o,
  105. const char *name,
  106. int is_empty,
  107. int num_vars,
  108. VarDesc *vars,
  109. VarDesc2 *vars2,
  110. int num_waits,
  111. const void** waits,
  112. const void** signal,
  113. int entry_id,
  114. const void *stack_addr
  115. );
  116. // Run function on target (obsolete).
  117. // @param o OFFLOAD object
  118. // @param name function name
  119. extern "C" int OFFLOAD_OFFLOAD(
  120. OFFLOAD o,
  121. const char *name,
  122. int is_empty,
  123. int num_vars,
  124. VarDesc *vars,
  125. VarDesc2 *vars2,
  126. int num_waits,
  127. const void** waits,
  128. const void* signal,
  129. int entry_id = 0,
  130. const void *stack_addr = NULL
  131. );
  132. // Global counter on host.
  133. // This variable is used if P2OPT_offload_do_data_persistence == 2.
  134. // The variable used to identify offload constructs contained in one procedure.
  135. // Call to OFFLOAD_CALL_COUNT() is inserted at HOST on entry of the routine.
  136. extern "C" int OFFLOAD_CALL_COUNT();
  137. #endif // COMPILER_IF_HOST_H_INCLUDED