PR 68115/libfortran
[official-gcc.git] / liboffloadmic / runtime / liboffload_error.c
blob29dcb6c8507c06260664a6515f1907da37174a4d
1 /*
2 Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of Intel Corporation nor the names of its
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <stdio.h>
32 #include <stdarg.h>
33 #ifndef va_copy
34 #define va_copy(dst, src) ((dst) = (src))
35 #endif
37 #include "liboffload_msg.h"
39 #include "liboffload_error_codes.h"
41 /***********************************************/
42 /* error-handling function, liboffload_error_support */
43 /***********************************************/
45 void __liboffload_error_support(error_types input_tag, ...)
47 va_list args;
48 va_start(args, input_tag);
50 switch (input_tag) {
51 case c_device_is_not_available:
52 write_message(stderr, msg_c_device_is_not_available, args);
53 break;
54 case c_invalid_device_number:
55 write_message(stderr, msg_c_invalid_device_number, args);
56 break;
57 case c_send_func_ptr:
58 write_message(stderr, msg_c_send_func_ptr, args);
59 break;
60 case c_receive_func_ptr:
61 write_message(stderr, msg_c_receive_func_ptr, args);
62 break;
63 case c_malloc:
64 write_message(stderr, msg_c_malloc, args);
65 break;
66 case c_offload_malloc:
67 write_message(stderr, msg_c_offload_malloc, args);
68 break;
69 case c_offload1:
70 write_message(stderr, msg_c_offload1, args);
71 break;
72 case c_unknown_var_type:
73 write_message(stderr, c_unknown_var_type, args);
74 break;
75 case c_invalid_env_var_value:
76 write_message(stderr, msg_c_invalid_env_var_value, args);
77 break;
78 case c_invalid_env_var_int_value:
79 write_message(stderr, msg_c_invalid_env_var_int_value, args);
80 break;
81 case c_invalid_env_report_value:
82 write_message(stderr, msg_c_invalid_env_report_value, args);
83 break;
84 case c_offload_signaled1:
85 write_message(stderr, msg_c_offload_signaled1, args);
86 break;
87 case c_offload_signaled2:
88 write_message(stderr, msg_c_offload_signaled2, args);
89 break;
90 case c_myowrapper_checkresult:
91 write_message(stderr, msg_c_myowrapper_checkresult, args);
92 break;
93 case c_myotarget_checkresult:
94 write_message(stderr, msg_c_myotarget_checkresult, args);
95 break;
96 case c_offload_descriptor_offload:
97 write_message(stderr, msg_c_offload_descriptor_offload, args);
98 break;
99 case c_merge_var_descs1:
100 write_message(stderr, msg_c_merge_var_descs1, args);
101 break;
102 case c_merge_var_descs2:
103 write_message(stderr, msg_c_merge_var_descs2, args);
104 break;
105 case c_mic_parse_env_var_list1:
106 write_message(stderr, msg_c_mic_parse_env_var_list1, args);
107 break;
108 case c_mic_parse_env_var_list2:
109 write_message(stderr, msg_c_mic_parse_env_var_list2, args);
110 break;
111 case c_mic_process_exit_ret:
112 write_message(stderr, msg_c_mic_process_exit_ret, args);
113 break;
114 case c_mic_process_exit_sig:
115 write_message(stderr, msg_c_mic_process_exit_sig, args);
116 break;
117 case c_mic_process_exit:
118 write_message(stderr, msg_c_mic_process_exit, args);
119 break;
120 case c_mic_init3:
121 write_message(stderr, msg_c_mic_init3, args);
122 break;
123 case c_mic_init4:
124 write_message(stderr, msg_c_mic_init4, args);
125 break;
126 case c_mic_init5:
127 write_message(stderr, msg_c_mic_init5, args);
128 break;
129 case c_mic_init6:
130 write_message(stderr, msg_c_mic_init6, args);
131 break;
132 case c_no_static_var_data:
133 write_message(stderr, msg_c_no_static_var_data, args);
134 break;
135 case c_no_ptr_data:
136 write_message(stderr, msg_c_no_ptr_data, args);
137 break;
138 case c_get_engine_handle:
139 write_message(stderr, msg_c_get_engine_handle, args);
140 break;
141 case c_get_engine_index:
142 write_message(stderr, msg_c_get_engine_index, args);
143 break;
144 case c_process_create:
145 write_message(stderr, msg_c_process_create, args);
146 break;
147 case c_process_set_cache_size:
148 write_message(stderr, msg_c_process_set_cache_size, args);
149 break;
150 case c_process_wait_shutdown:
151 write_message(stderr, msg_c_process_wait_shutdown, args);
152 break;
153 case c_process_proxy_flush:
154 write_message(stderr, msg_c_process_proxy_flush, args);
155 break;
156 case c_process_get_func_handles:
157 write_message(stderr, msg_c_process_get_func_handles, args);
158 break;
159 case c_load_library:
160 write_message(stderr, msg_c_load_library, args);
161 break;
162 case c_coipipe_max_number:
163 write_message(stderr, msg_c_coi_pipeline_max_number, args);
164 break;
165 case c_pipeline_create:
166 write_message(stderr, msg_c_pipeline_create, args);
167 break;
168 case c_pipeline_run_func:
169 write_message(stderr, msg_c_pipeline_run_func, args);
170 break;
171 case c_pipeline_start_run_funcs:
172 write_message(stderr, msg_c_pipeline_start_run_funcs, args);
173 break;
174 case c_buf_create:
175 write_message(stderr, msg_c_buf_create, args);
176 break;
177 case c_buf_create_out_of_mem:
178 write_message(stderr, msg_c_buf_create_out_of_mem, args);
179 break;
180 case c_buf_create_from_mem:
181 write_message(stderr, msg_c_buf_create_from_mem, args);
182 break;
183 case c_buf_destroy:
184 write_message(stderr, msg_c_buf_destroy, args);
185 break;
186 case c_buf_map:
187 write_message(stderr, msg_c_buf_map, args);
188 break;
189 case c_buf_unmap:
190 write_message(stderr, msg_c_buf_unmap, args);
191 break;
192 case c_buf_read:
193 write_message(stderr, msg_c_buf_read, args);
194 break;
195 case c_buf_write:
196 write_message(stderr, msg_c_buf_write, args);
197 break;
198 case c_buf_copy:
199 write_message(stderr, msg_c_buf_copy, args);
200 break;
201 case c_buf_get_address:
202 write_message(stderr, msg_c_buf_get_address, args);
203 break;
204 case c_buf_add_ref:
205 write_message(stderr, msg_c_buf_add_ref, args);
206 break;
207 case c_buf_release_ref:
208 write_message(stderr, msg_c_buf_release_ref, args);
209 break;
210 case c_buf_set_state:
211 write_message(stderr, msg_c_buf_set_state, args);
212 break;
213 case c_event_wait:
214 write_message(stderr, msg_c_event_wait, args);
215 break;
216 case c_zero_or_neg_ptr_len:
217 write_message(stderr, msg_c_zero_or_neg_ptr_len, args);
218 break;
219 case c_zero_or_neg_transfer_size:
220 write_message(stderr, msg_c_zero_or_neg_transfer_size, args);
221 break;
222 case c_bad_ptr_mem_alloc:
223 write_message(stderr, msg_c_bad_ptr_mem_alloc, args);
224 break;
225 case c_bad_ptr_mem_range:
226 write_message(stderr, msg_c_bad_ptr_mem_range, args);
227 break;
228 case c_different_src_and_dstn_sizes:
229 write_message(stderr, msg_c_different_src_and_dstn_sizes, args);
230 break;
231 case c_ranges_dont_match:
232 write_message(stderr, msg_c_ranges_dont_match, args);
233 break;
234 case c_destination_is_over:
235 write_message(stderr, msg_c_destination_is_over, args);
236 break;
237 case c_slice_of_noncont_array:
238 write_message(stderr, msg_c_slice_of_noncont_array, args);
239 break;
240 case c_non_contiguous_dope_vector:
241 write_message(stderr, msg_c_non_contiguous_dope_vector, args);
242 break;
243 case c_pointer_array_mismatch:
244 write_message(stderr, msg_c_pointer_array_mismatch, args);
245 break;
246 case c_omp_invalid_device_num_env:
247 write_message(stderr, msg_c_omp_invalid_device_num_env, args);
248 break;
249 case c_omp_invalid_device_num:
250 write_message(stderr, msg_c_omp_invalid_device_num, args);
251 break;
252 case c_unknown_binary_type:
253 write_message(stderr, msg_c_unknown_binary_type, args);
254 break;
255 case c_multiple_target_exes:
256 write_message(stderr, msg_c_multiple_target_exes, args);
257 break;
258 case c_no_target_exe:
259 write_message(stderr, msg_c_no_target_exe, args);
260 break;
261 case c_report_unknown_timer_node:
262 write_message(stderr, msg_c_report_unknown_timer_node, args);
263 break;
264 case c_report_unknown_trace_node:
265 write_message(stderr, msg_c_report_unknown_trace_node, args);
266 break;
267 case c_incorrect_affinity:
268 write_message(stderr, msg_c_incorrect_affinity, args);
269 break;
270 case c_cannot_set_affinity:
271 write_message(stderr, msg_c_cannot_set_affinity, args);
272 break;
273 case c_in_with_preallocated:
274 write_message(stderr, msg_c_in_with_preallocated, args);
275 break;
276 case c_report_no_host_exe:
277 write_message(stderr, msg_c_report_no_host_exe, args);
278 break;
279 case c_report_path_buff_overflow:
280 write_message(stderr, msg_c_report_path_buff_overflow, args);
281 break;
282 case c_create_pipeline_for_stream:
283 write_message(stderr, msg_c_create_pipeline_for_stream, args);
284 break;
285 case c_offload_no_stream:
286 write_message(stderr, msg_c_offload_no_stream, args);
287 break;
288 case c_get_engine_info:
289 write_message(stderr, msg_c_get_engine_info, args);
290 break;
291 case c_clear_cpu_mask:
292 write_message(stderr, msg_c_clear_cpu_mask, args);
293 break;
294 case c_set_cpu_mask:
295 write_message(stderr, msg_c_set_cpu_mask, args);
296 break;
297 case c_unload_library:
298 write_message(stderr, msg_c_unload_library, args);
299 break;
301 va_end(args);
304 char const * report_get_message_str(error_types input_tag)
306 switch (input_tag) {
307 case c_report_title:
308 return (offload_get_message_str(msg_c_report_title));
309 case c_report_from_file:
310 return (offload_get_message_str(msg_c_report_from_file));
311 case c_report_offload:
312 return (offload_get_message_str(msg_c_report_offload));
313 case c_report_mic:
314 return (offload_get_message_str(msg_c_report_mic));
315 case c_report_file:
316 return (offload_get_message_str(msg_c_report_file));
317 case c_report_line:
318 return (offload_get_message_str(msg_c_report_line));
319 case c_report_host:
320 return (offload_get_message_str(msg_c_report_host));
321 case c_report_tag:
322 return (offload_get_message_str(msg_c_report_tag));
323 case c_report_cpu_time:
324 return (offload_get_message_str(msg_c_report_cpu_time));
325 case c_report_seconds:
326 return (offload_get_message_str(msg_c_report_seconds));
327 case c_report_cpu_to_mic_data:
328 return (offload_get_message_str(msg_c_report_cpu_to_mic_data));
329 case c_report_bytes:
330 return (offload_get_message_str(msg_c_report_bytes));
331 case c_report_mic_time:
332 return (offload_get_message_str(msg_c_report_mic_time));
333 case c_report_mic_to_cpu_data:
334 return (offload_get_message_str(msg_c_report_mic_to_cpu_data));
335 case c_report_compute:
336 return (offload_get_message_str(msg_c_report_compute));
337 case c_report_copyin_data:
338 return (offload_get_message_str(msg_c_report_copyin_data));
339 case c_report_copyout_data:
340 return (offload_get_message_str(msg_c_report_copyout_data));
341 case c_report_create_buf_host:
342 return (offload_get_message_str(c_report_create_buf_host));
343 case c_report_create_buf_mic:
344 return (offload_get_message_str(msg_c_report_create_buf_mic));
345 case c_report_destroy:
346 return (offload_get_message_str(msg_c_report_destroy));
347 case c_report_gather_copyin_data:
348 return (offload_get_message_str(msg_c_report_gather_copyin_data));
349 case c_report_gather_copyout_data:
350 return (offload_get_message_str(msg_c_report_gather_copyout_data));
351 case c_report_state_signal:
352 return (offload_get_message_str(msg_c_report_state_signal));
353 case c_report_signal:
354 return (offload_get_message_str(msg_c_report_signal));
355 case c_report_wait:
356 return (offload_get_message_str(msg_c_report_wait));
357 case c_report_init:
358 return (offload_get_message_str(msg_c_report_init));
359 case c_report_init_func:
360 return (offload_get_message_str(msg_c_report_init_func));
361 case c_report_logical_card:
362 return (offload_get_message_str(msg_c_report_logical_card));
363 case c_report_mic_myo_fptr:
364 return (offload_get_message_str(msg_c_report_mic_myo_fptr));
365 case c_report_mic_myo_shared:
366 return (offload_get_message_str(msg_c_report_mic_myo_shared));
367 case c_report_myoacquire:
368 return (offload_get_message_str(msg_c_report_myoacquire));
369 case c_report_myofini:
370 return (offload_get_message_str(msg_c_report_myofini));
371 case c_report_myoinit:
372 return (offload_get_message_str(msg_c_report_myoinit));
373 case c_report_myoregister:
374 return (offload_get_message_str(msg_c_report_myoregister));
375 case c_report_myorelease:
376 return (offload_get_message_str(msg_c_report_myorelease));
377 case c_report_myosharedalignedfree:
378 return (
379 offload_get_message_str(msg_c_report_myosharedalignedfree));
380 case c_report_myosharedalignedmalloc:
381 return (
382 offload_get_message_str(msg_c_report_myosharedalignedmalloc));
383 case c_report_myosharedfree:
384 return (offload_get_message_str(msg_c_report_myosharedfree));
385 case c_report_myosharedmalloc:
386 return (offload_get_message_str(msg_c_report_myosharedmalloc));
387 case c_report_physical_card:
388 return (offload_get_message_str(msg_c_report_physical_card));
389 case c_report_receive_pointer_data:
390 return (
391 offload_get_message_str(msg_c_report_receive_pointer_data));
392 case c_report_received_pointer_data:
393 return (
394 offload_get_message_str(msg_c_report_received_pointer_data));
395 case c_report_register:
396 return (offload_get_message_str(msg_c_report_register));
397 case c_report_scatter_copyin_data:
398 return (offload_get_message_str(msg_c_report_scatter_copyin_data));
399 case c_report_scatter_copyout_data:
400 return (
401 offload_get_message_str(msg_c_report_scatter_copyout_data));
402 case c_report_send_pointer_data:
403 return (offload_get_message_str(msg_c_report_send_pointer_data));
404 case c_report_sent_pointer_data:
405 return (offload_get_message_str(msg_c_report_sent_pointer_data));
406 case c_report_start:
407 return (offload_get_message_str(msg_c_report_start));
408 case c_report_start_target_func:
409 return (offload_get_message_str(msg_c_report_start_target_func));
410 case c_report_state:
411 return (offload_get_message_str(msg_c_report_state));
412 case c_report_unregister:
413 return (offload_get_message_str(msg_c_report_unregister));
414 case c_report_var:
415 return (offload_get_message_str(msg_c_report_var));
416 case c_report_stream:
417 return (offload_get_message_str(msg_c_report_stream));
418 case c_report_state_stream:
419 return (offload_get_message_str(msg_c_report_state_stream));
421 default:
422 LIBOFFLOAD_ERROR(c_report_unknown_trace_node);
423 abort();
427 char const * report_get_host_stage_str(int i)
429 switch (i) {
430 case c_offload_host_total_offload:
431 return (
432 offload_get_message_str(msg_c_report_host_total_offload_time));
433 case c_offload_host_initialize:
434 return (offload_get_message_str(msg_c_report_host_initialize));
435 case c_offload_host_target_acquire:
436 return (
437 offload_get_message_str(msg_c_report_host_target_acquire));
438 case c_offload_host_wait_deps:
439 return (offload_get_message_str(msg_c_report_host_wait_deps));
440 case c_offload_host_setup_buffers:
441 return (offload_get_message_str(msg_c_report_host_setup_buffers));
442 case c_offload_host_alloc_buffers:
443 return (offload_get_message_str(msg_c_report_host_alloc_buffers));
444 case c_offload_host_setup_misc_data:
445 return (
446 offload_get_message_str(msg_c_report_host_setup_misc_data));
447 case c_offload_host_alloc_data_buffer:
448 return (
449 offload_get_message_str(msg_c_report_host_alloc_data_buffer));
450 case c_offload_host_send_pointers:
451 return (offload_get_message_str(msg_c_report_host_send_pointers));
452 case c_offload_host_gather_inputs:
453 return (offload_get_message_str(msg_c_report_host_gather_inputs));
454 case c_offload_host_map_in_data_buffer:
455 return (
456 offload_get_message_str(msg_c_report_host_map_in_data_buffer));
457 case c_offload_host_unmap_in_data_buffer:
458 return (offload_get_message_str(
459 msg_c_report_host_unmap_in_data_buffer));
460 case c_offload_host_start_compute:
461 return (offload_get_message_str(msg_c_report_host_start_compute));
462 case c_offload_host_wait_compute:
463 return (offload_get_message_str(msg_c_report_host_wait_compute));
464 case c_offload_host_start_buffers_reads:
465 return (offload_get_message_str(
466 msg_c_report_host_start_buffers_reads));
467 case c_offload_host_scatter_outputs:
468 return (
469 offload_get_message_str(msg_c_report_host_scatter_outputs));
470 case c_offload_host_map_out_data_buffer:
471 return (offload_get_message_str(
472 msg_c_report_host_map_out_data_buffer));
473 case c_offload_host_unmap_out_data_buffer:
474 return (offload_get_message_str(
475 msg_c_report_host_unmap_out_data_buffer));
476 case c_offload_host_wait_buffers_reads:
477 return (
478 offload_get_message_str(msg_c_report_host_wait_buffers_reads));
479 case c_offload_host_destroy_buffers:
480 return (
481 offload_get_message_str(msg_c_report_host_destroy_buffers));
482 default:
483 LIBOFFLOAD_ERROR(c_report_unknown_timer_node);
484 abort();
488 char const * report_get_target_stage_str(int i)
490 switch (i) {
491 case c_offload_target_total_time:
492 return (offload_get_message_str(msg_c_report_target_total_time));
493 case c_offload_target_descriptor_setup:
494 return (
495 offload_get_message_str(msg_c_report_target_descriptor_setup));
496 case c_offload_target_func_lookup:
497 return (offload_get_message_str(msg_c_report_target_func_lookup));
498 case c_offload_target_func_time:
499 return (offload_get_message_str(msg_c_report_target_func_time));
500 case c_offload_target_scatter_inputs:
501 return (
502 offload_get_message_str(msg_c_report_target_scatter_inputs));
503 case c_offload_target_add_buffer_refs:
504 return (
505 offload_get_message_str(msg_c_report_target_add_buffer_refs));
506 case c_offload_target_compute:
507 return (offload_get_message_str(msg_c_report_target_compute));
508 case c_offload_target_gather_outputs:
509 return (offload_get_message_str
510 (msg_c_report_target_gather_outputs));
511 case c_offload_target_release_buffer_refs:
512 return (offload_get_message_str(
513 msg_c_report_target_release_buffer_refs));
514 default:
515 LIBOFFLOAD_ERROR(c_report_unknown_timer_node);
516 abort();