summaryrefslogtreecommitdiff
path: root/liboffloadmic/runtime/liboffload_error_codes.h
blob: c33bef562365dec812cb5ccb973adbd74367a8a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
/*
    Copyright (c) 2014 Intel Corporation.  All Rights Reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:

      * Redistributions of source code must retain the above copyright
        notice, this list of conditions and the following disclaimer.
      * Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.
      * Neither the name of Intel Corporation nor the names of its
        contributors may be used to endorse or promote products derived
        from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/


#if !defined(LIBOFFLOAD_ERROR_CODES_H)
#define LIBOFFLOAD_ERROR_CODES_H
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>

typedef enum
{
    c_device_is_not_available = 0,
    c_invalid_device_number,
    c_offload1,
    c_unknown_var_type,
    c_send_func_ptr,
    c_receive_func_ptr,
    c_malloc,
    c_offload_malloc,
    c_invalid_env_var_value,
    c_invalid_env_var_int_value,
    c_invalid_env_report_value,
    c_offload_signaled1,
    c_offload_signaled2,
    c_myotarget_checkresult,
    c_myowrapper_checkresult,
    c_offload_descriptor_offload,
    c_merge_var_descs1,
    c_merge_var_descs2,
    c_mic_parse_env_var_list1,
    c_mic_parse_env_var_list2,
    c_mic_process_exit_ret,
    c_mic_process_exit_sig,
    c_mic_process_exit,
    c_mic_init3,
    c_mic_init4,
    c_mic_init5,
    c_mic_init6,
    c_no_static_var_data,
    c_no_ptr_data,
    c_get_engine_handle,
    c_get_engine_index,
    c_process_create,
    c_process_get_func_handles,
    c_process_wait_shutdown,
    c_process_proxy_flush,
    c_load_library,
    c_pipeline_create,
    c_pipeline_run_func,
    c_pipeline_start_run_funcs,
    c_buf_create,
    c_buf_create_out_of_mem,
    c_buf_create_from_mem,
    c_buf_destroy,
    c_buf_map,
    c_buf_unmap,
    c_buf_read,
    c_buf_write,
    c_buf_copy,
    c_buf_get_address,
    c_buf_add_ref,
    c_buf_release_ref,
    c_buf_set_state,
    c_event_wait,
    c_zero_or_neg_ptr_len,
    c_zero_or_neg_transfer_size,
    c_bad_ptr_mem_range,
    c_different_src_and_dstn_sizes,
    c_ranges_dont_match,
    c_destination_is_over,
    c_slice_of_noncont_array,
    c_non_contiguous_dope_vector,
    c_pointer_array_mismatch,
    c_omp_invalid_device_num_env,
    c_omp_invalid_device_num,
    c_unknown_binary_type,
    c_multiple_target_exes,
    c_no_target_exe,
    c_report_host,
    c_report_target,
    c_report_title,
    c_report_from_file,
    c_report_file,
    c_report_line,
    c_report_tag,
    c_report_seconds,
    c_report_bytes,
    c_report_mic,
    c_report_cpu_time,
    c_report_cpu_to_mic_data,
    c_report_mic_time,
    c_report_mic_to_cpu_data,
    c_report_unknown_timer_node,
    c_report_unknown_trace_node,
    c_report_offload,
    c_report_w_tag,
    c_report_state,
    c_report_start,
    c_report_init,
    c_report_logical_card,
    c_report_physical_card,
    c_report_register,
    c_report_init_func,
    c_report_create_buf_host,
    c_report_create_buf_mic,
    c_report_send_pointer_data,
    c_report_sent_pointer_data,
    c_report_gather_copyin_data,
    c_report_copyin_data,
    c_report_state_signal,
    c_report_signal,
    c_report_wait,
    c_report_compute,
    c_report_receive_pointer_data,
    c_report_received_pointer_data,
    c_report_start_target_func,
    c_report_var,
    c_report_scatter_copyin_data,
    c_report_gather_copyout_data,
    c_report_scatter_copyout_data,
    c_report_copyout_data,
    c_report_unregister,
    c_report_destroy,
    c_report_myoinit,
    c_report_myoregister,
    c_report_myofini,
    c_report_mic_myo_shared,
    c_report_mic_myo_fptr,
    c_report_myosharedmalloc,
    c_report_myosharedfree,
    c_report_myosharedalignedmalloc,
    c_report_myosharedalignedfree,
    c_report_myoacquire,
    c_report_myorelease,
    c_coipipe_max_number
} error_types;

enum OffloadHostPhase {
    // Total time on host for entire offload
    c_offload_host_total_offload = 0,

    // Time to load target binary
    c_offload_host_initialize,

    // Time to acquire lrb availability dynamically
    c_offload_host_target_acquire,

    // Time to wait for dependencies
    c_offload_host_wait_deps,

    // Time to allocate pointer buffers, initiate writes for pointers
    // and calculate size of copyin/copyout buffer
    c_offload_host_setup_buffers,

    // Time to allocate pointer buffers
    c_offload_host_alloc_buffers,

    // Time to initialize misc data
    c_offload_host_setup_misc_data,

    // Time to allocate copyin/copyout buffer
    c_offload_host_alloc_data_buffer,

    // Time to initiate writes from host pointers to buffers
    c_offload_host_send_pointers,

    // Time to Gather IN data of offload into buffer
    c_offload_host_gather_inputs,

    // Time to map buffer
    c_offload_host_map_in_data_buffer,

    // Time to unmap buffer
    c_offload_host_unmap_in_data_buffer,

    // Time to start remote function call that does computation on lrb
    c_offload_host_start_compute,

    // Time to wait for compute to finish
    c_offload_host_wait_compute,

    // Time to initiate reads from pointer buffers
    c_offload_host_start_buffers_reads,

    // Time to update host variabels with OUT data from buffer
    c_offload_host_scatter_outputs,

    // Time to map buffer
    c_offload_host_map_out_data_buffer,

    // Time to unmap buffer
    c_offload_host_unmap_out_data_buffer,

    // Time to wait reads from buffers to finish
    c_offload_host_wait_buffers_reads,

    // Time to destroy buffers that are no longer needed
    c_offload_host_destroy_buffers,

    // LAST TIME MONITOR
    c_offload_host_max_phase
};

enum OffloadTargetPhase {
    // Total time spent on the target
    c_offload_target_total_time = 0,

    // Time to initialize offload descriptor
    c_offload_target_descriptor_setup,

    // Time to find target entry point in lookup table
    c_offload_target_func_lookup,

    // Total time spend executing offload entry
    c_offload_target_func_time,

    // Time to initialize target variables with IN values from buffer
    c_offload_target_scatter_inputs,

    // Time to add buffer reference for pointer buffers
    c_offload_target_add_buffer_refs,

    // Total time on lrb for computation
    c_offload_target_compute,

    // On lrb, time to copy OUT into buffer
    c_offload_target_gather_outputs,

    // Time to release buffer references
    c_offload_target_release_buffer_refs,

    // LAST TIME MONITOR
    c_offload_target_max_phase
};

#ifdef __cplusplus
extern "C" {
#endif
void __liboffload_error_support(error_types input_tag, ...);
void __liboffload_report_support(error_types input_tag, ...);
char const *offload_get_message_str(int msgCode);
char const * report_get_message_str(error_types input_tag);
char const * report_get_host_stage_str(int i);
char const * report_get_target_stage_str(int i);
#ifdef __cplusplus
}
#endif

#define test_msg_cat(nm, msg) \
    fprintf(stderr, "\t TEST for %s \n \t", nm); \
    __liboffload_error_support(msg);

#define test_msg_cat1(nm, msg, ...) \
    fprintf(stderr, "\t TEST for %s \n \t", nm); \
    __liboffload_error_support(msg, __VA_ARGS__);

void write_message(FILE * file, int msgCode, va_list args_p);

#define LIBOFFLOAD_ERROR __liboffload_error_support

#ifdef TARGET_WINNT
#define LIBOFFLOAD_ABORT \
         _set_abort_behavior(0, _WRITE_ABORT_MSG); \
         abort()
#else
#define LIBOFFLOAD_ABORT \
         abort()
#endif

#endif // !defined(LIBOFFLOAD_ERROR_CODES_H)