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