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