liboffload_error_codes.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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. #if !defined(LIBOFFLOAD_ERROR_CODES_H)
  27. #define LIBOFFLOAD_ERROR_CODES_H
  28. #include <stdarg.h>
  29. #include <stdlib.h>
  30. #include <stdio.h>
  31. typedef enum
  32. {
  33. c_device_is_not_available = 0,
  34. c_invalid_device_number,
  35. c_offload1,
  36. c_unknown_var_type,
  37. c_send_func_ptr,
  38. c_receive_func_ptr,
  39. c_malloc,
  40. c_offload_malloc,
  41. c_invalid_env_var_value,
  42. c_invalid_env_var_int_value,
  43. c_invalid_env_report_value,
  44. c_offload_signaled1,
  45. c_offload_signaled2,
  46. c_myotarget_checkresult,
  47. c_myowrapper_checkresult,
  48. c_offload_descriptor_offload,
  49. c_merge_var_descs1,
  50. c_merge_var_descs2,
  51. c_mic_parse_env_var_list1,
  52. c_mic_parse_env_var_list2,
  53. c_mic_process_exit_ret,
  54. c_mic_process_exit_sig,
  55. c_mic_process_exit,
  56. c_mic_init3,
  57. c_mic_init4,
  58. c_mic_init5,
  59. c_mic_init6,
  60. c_no_static_var_data,
  61. c_no_ptr_data,
  62. c_get_engine_handle,
  63. c_get_engine_index,
  64. c_process_create,
  65. c_process_get_func_handles,
  66. c_process_wait_shutdown,
  67. c_process_proxy_flush,
  68. c_load_library,
  69. c_pipeline_create,
  70. c_pipeline_run_func,
  71. c_pipeline_start_run_funcs,
  72. c_buf_create,
  73. c_buf_create_out_of_mem,
  74. c_buf_create_from_mem,
  75. c_buf_destroy,
  76. c_buf_map,
  77. c_buf_unmap,
  78. c_buf_read,
  79. c_buf_write,
  80. c_buf_copy,
  81. c_buf_get_address,
  82. c_buf_add_ref,
  83. c_buf_release_ref,
  84. c_buf_set_state,
  85. c_event_wait,
  86. c_zero_or_neg_ptr_len,
  87. c_zero_or_neg_transfer_size,
  88. c_bad_ptr_mem_range,
  89. c_different_src_and_dstn_sizes,
  90. c_ranges_dont_match,
  91. c_destination_is_over,
  92. c_slice_of_noncont_array,
  93. c_non_contiguous_dope_vector,
  94. c_pointer_array_mismatch,
  95. c_omp_invalid_device_num_env,
  96. c_omp_invalid_device_num,
  97. c_unknown_binary_type,
  98. c_multiple_target_exes,
  99. c_no_target_exe,
  100. c_report_host,
  101. c_report_target,
  102. c_report_title,
  103. c_report_from_file,
  104. c_report_file,
  105. c_report_line,
  106. c_report_tag,
  107. c_report_seconds,
  108. c_report_bytes,
  109. c_report_mic,
  110. c_report_cpu_time,
  111. c_report_cpu_to_mic_data,
  112. c_report_mic_time,
  113. c_report_mic_to_cpu_data,
  114. c_report_unknown_timer_node,
  115. c_report_unknown_trace_node,
  116. c_report_offload,
  117. c_report_w_tag,
  118. c_report_state,
  119. c_report_start,
  120. c_report_init,
  121. c_report_logical_card,
  122. c_report_physical_card,
  123. c_report_register,
  124. c_report_init_func,
  125. c_report_create_buf_host,
  126. c_report_create_buf_mic,
  127. c_report_send_pointer_data,
  128. c_report_sent_pointer_data,
  129. c_report_gather_copyin_data,
  130. c_report_copyin_data,
  131. c_report_state_signal,
  132. c_report_signal,
  133. c_report_wait,
  134. c_report_compute,
  135. c_report_receive_pointer_data,
  136. c_report_received_pointer_data,
  137. c_report_start_target_func,
  138. c_report_var,
  139. c_report_scatter_copyin_data,
  140. c_report_gather_copyout_data,
  141. c_report_scatter_copyout_data,
  142. c_report_copyout_data,
  143. c_report_unregister,
  144. c_report_destroy,
  145. c_report_myoinit,
  146. c_report_myoregister,
  147. c_report_myofini,
  148. c_report_mic_myo_shared,
  149. c_report_mic_myo_fptr,
  150. c_report_myosharedmalloc,
  151. c_report_myosharedfree,
  152. c_report_myosharedalignedmalloc,
  153. c_report_myosharedalignedfree,
  154. c_report_myoacquire,
  155. c_report_myorelease,
  156. c_coipipe_max_number
  157. } error_types;
  158. enum OffloadHostPhase {
  159. // Total time on host for entire offload
  160. c_offload_host_total_offload = 0,
  161. // Time to load target binary
  162. c_offload_host_initialize,
  163. // Time to acquire lrb availability dynamically
  164. c_offload_host_target_acquire,
  165. // Time to wait for dependencies
  166. c_offload_host_wait_deps,
  167. // Time to allocate pointer buffers, initiate writes for pointers
  168. // and calculate size of copyin/copyout buffer
  169. c_offload_host_setup_buffers,
  170. // Time to allocate pointer buffers
  171. c_offload_host_alloc_buffers,
  172. // Time to initialize misc data
  173. c_offload_host_setup_misc_data,
  174. // Time to allocate copyin/copyout buffer
  175. c_offload_host_alloc_data_buffer,
  176. // Time to initiate writes from host pointers to buffers
  177. c_offload_host_send_pointers,
  178. // Time to Gather IN data of offload into buffer
  179. c_offload_host_gather_inputs,
  180. // Time to map buffer
  181. c_offload_host_map_in_data_buffer,
  182. // Time to unmap buffer
  183. c_offload_host_unmap_in_data_buffer,
  184. // Time to start remote function call that does computation on lrb
  185. c_offload_host_start_compute,
  186. // Time to wait for compute to finish
  187. c_offload_host_wait_compute,
  188. // Time to initiate reads from pointer buffers
  189. c_offload_host_start_buffers_reads,
  190. // Time to update host variabels with OUT data from buffer
  191. c_offload_host_scatter_outputs,
  192. // Time to map buffer
  193. c_offload_host_map_out_data_buffer,
  194. // Time to unmap buffer
  195. c_offload_host_unmap_out_data_buffer,
  196. // Time to wait reads from buffers to finish
  197. c_offload_host_wait_buffers_reads,
  198. // Time to destroy buffers that are no longer needed
  199. c_offload_host_destroy_buffers,
  200. // LAST TIME MONITOR
  201. c_offload_host_max_phase
  202. };
  203. enum OffloadTargetPhase {
  204. // Total time spent on the target
  205. c_offload_target_total_time = 0,
  206. // Time to initialize offload descriptor
  207. c_offload_target_descriptor_setup,
  208. // Time to find target entry point in lookup table
  209. c_offload_target_func_lookup,
  210. // Total time spend executing offload entry
  211. c_offload_target_func_time,
  212. // Time to initialize target variables with IN values from buffer
  213. c_offload_target_scatter_inputs,
  214. // Time to add buffer reference for pointer buffers
  215. c_offload_target_add_buffer_refs,
  216. // Total time on lrb for computation
  217. c_offload_target_compute,
  218. // On lrb, time to copy OUT into buffer
  219. c_offload_target_gather_outputs,
  220. // Time to release buffer references
  221. c_offload_target_release_buffer_refs,
  222. // LAST TIME MONITOR
  223. c_offload_target_max_phase
  224. };
  225. #ifdef __cplusplus
  226. extern "C" {
  227. #endif
  228. void __liboffload_error_support(error_types input_tag, ...);
  229. void __liboffload_report_support(error_types input_tag, ...);
  230. char const *offload_get_message_str(int msgCode);
  231. char const * report_get_message_str(error_types input_tag);
  232. char const * report_get_host_stage_str(int i);
  233. char const * report_get_target_stage_str(int i);
  234. #ifdef __cplusplus
  235. }
  236. #endif
  237. #define test_msg_cat(nm, msg) \
  238. fprintf(stderr, "\t TEST for %s \n \t", nm); \
  239. __liboffload_error_support(msg);
  240. #define test_msg_cat1(nm, msg, ...) \
  241. fprintf(stderr, "\t TEST for %s \n \t", nm); \
  242. __liboffload_error_support(msg, __VA_ARGS__);
  243. void write_message(FILE * file, int msgCode, va_list args_p);
  244. #define LIBOFFLOAD_ERROR __liboffload_error_support
  245. #ifdef TARGET_WINNT
  246. #define LIBOFFLOAD_ABORT \
  247. _set_abort_behavior(0, _WRITE_ABORT_MSG); \
  248. abort()
  249. #else
  250. #define LIBOFFLOAD_ABORT \
  251. abort()
  252. #endif
  253. #endif // !defined(LIBOFFLOAD_ERROR_CODES_H)