00001 /**** 00002 ***** Copyright 2010 Intel Corporation All Rights Reserved. 00003 ***** 00004 ***** The source code, information and material contained herein are owned by Intel Corporation or its suppliers ***** 00005 ***** or licensors, and title to such Material remains with Intel Corporation or its suppliers or licensors. ***** 00006 ***** The Material contains proprietary information of Intel or its suppliers and licensors. The Material is ***** 00007 ***** protected by worldwide copyright laws and treaty provisions. No part of the Material may be used, copied, ***** 00008 ***** reproduced, modified, published, uploaded, posted, transmitted, distributed or disclosed in any way without ***** 00009 ***** Intel's prior express written permission. 00010 ***** 00011 ***** No license under any patent, copyright or other intellectual property rights in the material is granted to ***** 00012 ***** or conferred upon you, either expressly, by implication, inducement, estoppel or otherwise. Any license ***** 00013 ***** under such intellectual property rights must be express and approved by Intel in writing. 00014 ****/ 00015 00016 /**** Copyright Ends ****/ 00017 00018 #ifndef ARBB_VM_API_H 00019 #define ARBB_VM_API_H 00020 00021 #if defined(_WIN32) 00022 # if defined(ARBB_DLL_EXPORTS) 00023 # define ARBB_VM_EXPORT __declspec(dllexport) 00024 # else 00025 # define ARBB_VM_EXPORT __declspec(dllimport) 00026 # endif 00027 #else 00028 # if defined(ARBB_DLL_EXPORTS) 00029 # define ARBB_VM_EXPORT __attribute__((visibility("default"))) 00030 # else 00031 # define ARBB_VM_EXPORT 00032 # endif 00033 #endif 00034 00035 #if defined(_WIN32) 00036 typedef __int64 int64_t; 00037 typedef unsigned __int64 uint64_t; 00038 #else 00039 #include <stdint.h> 00040 #endif 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00048 00052 00054 typedef struct { 00055 void* ptr; 00056 } arbb_context_t; 00057 00060 typedef struct { 00061 void* ptr; 00062 } arbb_refcountable_t; 00063 00067 typedef struct { 00068 void* ptr; 00069 } arbb_error_details_t; 00070 00073 typedef struct { 00074 void* ptr; 00075 } arbb_global_variable_t; 00076 00078 typedef struct { 00079 void* ptr; 00080 } arbb_variable_t; 00081 00085 typedef struct { 00086 void* ptr; 00087 } arbb_function_t; 00088 00090 typedef struct { 00091 void* ptr; 00092 } arbb_type_t; 00093 00097 typedef struct { 00098 void* ptr; 00099 } arbb_binding_t; 00100 00102 typedef struct { 00103 void* ptr; 00104 } arbb_string_t; 00105 00107 00110 00113 ARBB_VM_EXPORT 00114 int arbb_is_refcountable_null(arbb_refcountable_t object); 00115 00117 ARBB_VM_EXPORT 00118 void arbb_set_refcountable_null(arbb_refcountable_t* object); 00119 00122 ARBB_VM_EXPORT 00123 int arbb_is_error_details_null(arbb_error_details_t object); 00124 00126 ARBB_VM_EXPORT 00127 void arbb_set_error_details_null(arbb_error_details_t* object); 00128 00131 ARBB_VM_EXPORT 00132 int arbb_is_string_null(arbb_string_t object); 00133 00135 ARBB_VM_EXPORT 00136 void arbb_set_string_null(arbb_string_t* object); 00137 00140 ARBB_VM_EXPORT 00141 int arbb_is_context_null(arbb_context_t object); 00142 00144 ARBB_VM_EXPORT 00145 void arbb_set_context_null(arbb_context_t* object); 00146 00149 ARBB_VM_EXPORT 00150 int arbb_is_function_null(arbb_function_t object); 00151 00153 ARBB_VM_EXPORT 00154 void arbb_set_function_null(arbb_function_t* object); 00155 00158 ARBB_VM_EXPORT 00159 int arbb_is_variable_null(arbb_variable_t object); 00160 00162 ARBB_VM_EXPORT 00163 void arbb_set_variable_null(arbb_variable_t* object); 00164 00167 ARBB_VM_EXPORT 00168 int arbb_is_global_variable_null(arbb_global_variable_t object); 00169 00171 ARBB_VM_EXPORT 00172 void arbb_set_global_variable_null(arbb_global_variable_t* object); 00173 00176 ARBB_VM_EXPORT 00177 int arbb_is_binding_null(arbb_binding_t object); 00178 00180 ARBB_VM_EXPORT 00181 void arbb_set_binding_null(arbb_binding_t* object); 00182 00185 ARBB_VM_EXPORT 00186 int arbb_is_type_null(arbb_type_t object); 00187 00189 ARBB_VM_EXPORT 00190 void arbb_set_type_null(arbb_type_t* object); 00191 00193 00196 00198 typedef enum { 00199 arbb_error_none, 00200 arbb_error_invalid_argument, 00201 arbb_error_scoping, 00202 arbb_error_out_of_bounds, 00203 arbb_error_arithmetic, 00204 arbb_error_bad_alloc, 00205 arbb_error_uninitialized_access, 00206 arbb_error_internal, 00207 } arbb_error_t; 00208 00214 ARBB_VM_EXPORT 00215 const char* arbb_get_error_message(arbb_error_details_t error_details); 00216 00222 ARBB_VM_EXPORT 00223 arbb_error_t arbb_get_error_code(arbb_error_details_t error_details); 00224 00227 ARBB_VM_EXPORT 00228 void arbb_free_error_details(arbb_error_details_t error_details); 00229 00231 00234 00240 ARBB_VM_EXPORT 00241 arbb_error_t arbb_get_default_context(arbb_context_t* out_context, 00242 arbb_error_details_t* details); 00243 00245 00250 00254 ARBB_VM_EXPORT 00255 arbb_refcountable_t arbb_function_to_refcountable(arbb_function_t convertible); 00256 00260 ARBB_VM_EXPORT 00261 arbb_refcountable_t arbb_global_variable_to_refcountable(arbb_global_variable_t convertible); 00262 00268 ARBB_VM_EXPORT 00269 arbb_error_t arbb_acquire_ref(arbb_refcountable_t refcountable, 00270 arbb_error_details_t* details); 00271 00278 ARBB_VM_EXPORT 00279 arbb_error_t arbb_release_ref(arbb_refcountable_t refcountable, 00280 arbb_error_details_t* details); 00281 00283 00286 00290 ARBB_VM_EXPORT 00291 const char* arbb_get_c_string(arbb_string_t string); 00292 00294 ARBB_VM_EXPORT 00295 void arbb_free_string(arbb_string_t string); 00296 00298 00304 00306 typedef enum { 00307 arbb_i8, 00308 arbb_i16, 00309 arbb_i32, 00310 arbb_i64, 00311 arbb_u8, 00312 arbb_u16, 00313 arbb_u32, 00314 arbb_u64, 00315 arbb_f32, 00316 arbb_f64, 00317 arbb_boolean, 00318 arbb_usize, 00319 arbb_isize, 00320 } arbb_scalar_type_t; 00321 00330 ARBB_VM_EXPORT 00331 arbb_error_t arbb_get_scalar_type(arbb_context_t context, 00332 arbb_type_t* out_type, 00333 arbb_scalar_type_t scalar_type, 00334 arbb_error_details_t* details); 00335 00336 // Returns the number of bytes in the representation of @p type. 00337 // 00344 ARBB_VM_EXPORT 00345 arbb_error_t arbb_sizeof_type(arbb_context_t context, 00346 uint64_t* out_size, 00347 arbb_type_t type, 00348 arbb_error_details_t* details); 00349 00360 ARBB_VM_EXPORT 00361 arbb_error_t arbb_get_dense_type(arbb_context_t context, 00362 arbb_type_t* out_type, 00363 arbb_type_t element_type, 00364 unsigned int dimensionality, 00365 arbb_error_details_t* details); 00366 00376 ARBB_VM_EXPORT 00377 arbb_error_t arbb_get_nested_type(arbb_context_t context, 00378 arbb_type_t* out_type, 00379 arbb_type_t element_type, 00380 arbb_error_details_t* details); 00381 00383 00387 00399 ARBB_VM_EXPORT 00400 arbb_error_t arbb_create_constant(arbb_context_t context, 00401 arbb_global_variable_t* out_var, 00402 arbb_type_t type, 00403 void* data, 00404 void* debug_data_ptr, 00405 arbb_error_details_t* details); 00406 00408 00413 00423 ARBB_VM_EXPORT 00424 arbb_error_t arbb_create_global(arbb_context_t context, 00425 arbb_global_variable_t* out_var, 00426 arbb_type_t type, 00427 const char *name, 00428 arbb_binding_t binding, 00429 void* debug_data_ptr, 00430 arbb_error_details_t* details); 00431 00432 00441 ARBB_VM_EXPORT 00442 arbb_error_t arbb_get_variable_from_global(arbb_context_t context, 00443 arbb_variable_t* out_var, 00444 arbb_global_variable_t global_var, 00445 arbb_error_details_t* details); 00446 00448 00451 00465 ARBB_VM_EXPORT 00466 arbb_error_t arbb_get_function_type(arbb_context_t context, 00467 arbb_type_t* out_type, 00468 unsigned int num_outputs, 00469 const arbb_type_t* output_types, 00470 unsigned int num_inputs, 00471 const arbb_type_t* input_types, 00472 arbb_error_details_t* details); 00473 00495 ARBB_VM_EXPORT 00496 arbb_error_t arbb_get_function_type_parameter_alias(arbb_context_t context, 00497 arbb_type_t* out_type, 00498 arbb_type_t function_type, 00499 const unsigned int* parameter_aliases, 00500 arbb_error_details_t* details); 00501 00511 ARBB_VM_EXPORT 00512 arbb_error_t arbb_begin_function(arbb_context_t context, 00513 arbb_function_t* out_function, 00514 arbb_type_t function_type, 00515 const char* name, 00516 int is_remote, 00517 arbb_error_details_t* details); 00518 00531 ARBB_VM_EXPORT 00532 arbb_error_t arbb_abort_function(arbb_function_t function, 00533 arbb_error_details_t* details); 00534 00541 ARBB_VM_EXPORT 00542 arbb_error_t arbb_end_function(arbb_function_t function, 00543 arbb_error_details_t* details); 00544 00558 ARBB_VM_EXPORT 00559 arbb_error_t arbb_get_parameter(arbb_function_t function, 00560 arbb_variable_t* out_var, 00561 int get_output, 00562 unsigned int index, 00563 arbb_error_details_t* details); 00564 00571 ARBB_VM_EXPORT 00572 arbb_error_t arbb_serialize_function(arbb_function_t function, 00573 arbb_string_t* out_text, 00574 arbb_error_details_t* details); 00575 00577 00580 00590 ARBB_VM_EXPORT 00591 arbb_error_t arbb_create_local(arbb_function_t function, 00592 arbb_variable_t* out_var, 00593 arbb_type_t type, 00594 const char* name, 00595 arbb_error_details_t* details); 00596 00598 00601 00604 typedef enum { 00605 // element-wise operations 00606 arbb_op_abs, 00607 arbb_op_acos, 00608 arbb_op_asin, 00609 arbb_op_atan, 00610 arbb_op_ceil, 00611 arbb_op_copy, 00612 arbb_op_cos, 00613 arbb_op_cosh, 00614 arbb_op_exp, 00615 arbb_op_exp10, 00616 arbb_op_floor, 00617 arbb_op_ln, 00618 arbb_op_log10, 00619 arbb_op_log_not, 00620 arbb_op_bit_not, 00621 arbb_op_rcp, 00622 arbb_op_round, 00623 arbb_op_rsqrt, 00624 arbb_op_sin, 00625 arbb_op_sinh, 00626 arbb_op_sqrt, 00627 arbb_op_tan, 00628 arbb_op_tanh, 00629 arbb_op_neg, 00630 arbb_op_add, 00631 arbb_op_bit_and, 00632 arbb_op_atan2, 00633 arbb_op_compare, 00634 arbb_op_div, 00635 arbb_op_div_tan, 00636 arbb_op_equal, 00637 arbb_op_geq, 00638 arbb_op_greater, 00639 arbb_op_bit_or, 00640 arbb_op_leq, 00641 arbb_op_less, 00642 arbb_op_log_and, 00643 arbb_op_log_or, 00644 arbb_op_lsh, 00645 arbb_op_max, 00646 arbb_op_min, 00647 arbb_op_mod, 00648 arbb_op_mul, 00649 arbb_op_neq, 00650 arbb_op_pow, 00651 arbb_op_rsh, 00652 arbb_op_sub, 00653 arbb_op_bit_xor, 00654 arbb_op_select, 00655 00656 // reorder operations 00657 arbb_op_gather, 00658 arbb_op_scatter, 00659 arbb_op_pack, 00660 arbb_op_unpack, 00661 arbb_op_shuffle, 00662 arbb_op_unshuffle, 00663 arbb_op_repeat, 00664 arbb_op_distribute, 00665 arbb_op_repeat_row, 00666 arbb_op_repeat_col, 00667 arbb_op_repeat_page, 00668 arbb_op_transpose, 00669 arbb_op_swap_col, 00670 arbb_op_swap_row, 00671 arbb_op_swap_page, 00672 arbb_op_shift_constant, 00673 arbb_op_shift_clamp, 00674 arbb_op_rotate, 00675 arbb_op_reverse, 00676 00677 // facility operations 00678 arbb_op_length, 00679 arbb_op_new_vector, 00680 arbb_op_apply_nesting, 00681 arbb_op_get_nesting, 00682 arbb_op_cat, 00683 arbb_op_cast, 00684 arbb_op_extract, 00685 arbb_op_split, 00686 arbb_op_unsplit, 00687 arbb_op_kill, 00688 arbb_op_index, 00689 arbb_op_mask, 00690 arbb_op_copy_nesting, 00691 arbb_op_flatten, 00692 arbb_op_const_vector, 00693 arbb_op_sort, 00694 arbb_op_sort_rank, 00695 arbb_op_replace, 00696 arbb_op_wall_clock, 00697 arbb_op_set_regular_nesting, 00698 arbb_op_replace_row, 00699 arbb_op_replace_col, 00700 arbb_op_replace_page, 00701 arbb_op_get_nrows, 00702 arbb_op_get_ncols, 00703 arbb_op_get_npages, 00704 arbb_op_replace_2d_section, 00705 arbb_op_extract_row, 00706 arbb_op_extract_col, 00707 arbb_op_extract_page, 00708 arbb_op_section, 00709 arbb_op_all_set, 00710 arbb_op_copy_length, 00711 arbb_op_segment, 00712 arbb_op_replace_segment, 00713 arbb_op_alloc, 00714 arbb_op_alloc_as, 00715 arbb_op_dump, 00716 arbb_op_create_dumper, 00717 arbb_op_kill_dumper, 00718 arbb_op_set_dumper_fmt, 00719 arbb_op_replace_element, 00720 arbb_op_get_elt_coord, 00721 arbb_op_reset_dbg, 00722 arbb_op_set_dbg, 00723 arbb_op_bitwise_cast, 00724 arbb_op_get_neighbor, 00725 arbb_op_expect_size, 00726 00727 // collective operations 00728 arbb_op_add_reduce, 00729 arbb_op_mul_reduce, 00730 arbb_op_max_reduce, 00731 arbb_op_max_reduce_loc, 00732 arbb_op_min_reduce, 00733 arbb_op_min_reduce_loc, 00734 arbb_op_and_reduce, 00735 arbb_op_ior_reduce, 00736 arbb_op_xor_reduce, 00737 00738 arbb_op_add_scan, 00739 arbb_op_mul_scan, 00740 arbb_op_max_scan, 00741 arbb_op_min_scan, 00742 arbb_op_and_scan, 00743 arbb_op_ior_scan, 00744 arbb_op_xor_scan, 00745 00746 // fused operations 00747 arbb_op_add_merge, 00748 } arbb_opcode_t; 00749 00766 ARBB_VM_EXPORT 00767 arbb_error_t arbb_op(arbb_function_t function, 00768 arbb_opcode_t opcode, 00769 const arbb_variable_t* outputs, 00770 const arbb_variable_t* inputs, 00771 void* debug_data_ptrs[], 00772 arbb_error_details_t* details); 00773 00792 ARBB_VM_EXPORT 00793 arbb_error_t arbb_op_dynamic(arbb_function_t function, 00794 arbb_opcode_t opcode, 00795 unsigned int num_outputs, 00796 const arbb_variable_t* outputs, 00797 unsigned int num_inputs, 00798 const arbb_variable_t* inputs, 00799 void* debug_data_ptrs[], 00800 arbb_error_details_t* details); 00801 00803 00806 00810 typedef enum { 00811 arbb_op_call, 00812 arbb_op_map //< Perform a map operation. 00813 } arbb_call_opcode_t; 00814 00835 ARBB_VM_EXPORT 00836 arbb_error_t arbb_call_op(arbb_function_t caller, 00837 arbb_call_opcode_t opcode, 00838 arbb_function_t callee, 00839 const arbb_variable_t* outputs, 00840 const arbb_variable_t* inputs, 00841 arbb_error_details_t* details); 00842 00844 00847 00857 ARBB_VM_EXPORT 00858 arbb_error_t arbb_if(arbb_function_t function, 00859 arbb_variable_t condition, 00860 arbb_error_details_t* details); 00861 00869 ARBB_VM_EXPORT 00870 arbb_error_t arbb_else(arbb_function_t function, 00871 arbb_error_details_t* details); 00872 00879 ARBB_VM_EXPORT 00880 arbb_error_t arbb_end_if(arbb_function_t function, 00881 arbb_error_details_t* details); 00882 00884 00887 00891 typedef enum { 00892 arbb_loop_for, 00893 arbb_loop_while, 00894 } arbb_loop_type_t; 00895 00899 typedef enum { 00900 arbb_loop_block_init, 00901 arbb_loop_block_cond, 00902 arbb_loop_block_body, 00903 arbb_loop_block_step, 00904 } arbb_loop_block_t; 00905 00915 ARBB_VM_EXPORT 00916 arbb_error_t arbb_begin_loop(arbb_function_t function, 00917 arbb_loop_type_t loop_type, 00918 arbb_error_details_t* details); 00919 00929 ARBB_VM_EXPORT 00930 arbb_error_t arbb_begin_loop_block(arbb_function_t function, 00931 arbb_loop_block_t block_type, 00932 arbb_error_details_t* details); 00933 00945 ARBB_VM_EXPORT 00946 arbb_error_t arbb_loop_condition(arbb_function_t function, 00947 arbb_variable_t condition, 00948 arbb_error_details_t* details); 00949 00957 ARBB_VM_EXPORT 00958 arbb_error_t arbb_end_loop(arbb_function_t function, 00959 arbb_error_details_t* details); 00960 00967 ARBB_VM_EXPORT 00968 arbb_error_t arbb_break(arbb_function_t function, 00969 arbb_error_details_t* details); 00970 00977 ARBB_VM_EXPORT 00978 arbb_error_t arbb_continue(arbb_function_t function, 00979 arbb_error_details_t* details); 00980 00981 00983 00986 00996 ARBB_VM_EXPORT 00997 arbb_error_t arbb_read_scalar(arbb_context_t context, 00998 arbb_variable_t variable, 00999 void* out_data, 01000 arbb_error_details_t* details); 01001 01011 ARBB_VM_EXPORT 01012 arbb_error_t arbb_write_scalar(arbb_context_t context, 01013 arbb_variable_t variable, 01014 const void* data, 01015 arbb_error_details_t* details); 01016 01018 01021 01043 ARBB_VM_EXPORT 01044 arbb_error_t arbb_create_dense_binding(arbb_context_t context, 01045 arbb_binding_t* out_binding, 01046 void* user_data, 01047 unsigned int dimensionality, 01048 const uint64_t* sizes, 01049 const uint64_t* byte_pitches, 01050 arbb_error_details_t* details); 01051 01058 ARBB_VM_EXPORT 01059 arbb_error_t arbb_free_binding(arbb_context_t context, 01060 arbb_binding_t binding, 01061 arbb_error_details_t* details); 01062 01064 01067 01071 typedef enum { 01072 arbb_read_only_range, 01073 arbb_write_only_range, 01074 arbb_read_write_range, 01075 } arbb_range_access_mode_t; 01076 01091 ARBB_VM_EXPORT 01092 arbb_error_t arbb_map_to_host(arbb_context_t context, 01093 arbb_variable_t container, 01094 void** out_data, 01095 uint64_t* out_byte_pitch, 01096 arbb_range_access_mode_t mode, 01097 arbb_error_details_t* details); 01098 01100 01103 01118 ARBB_VM_EXPORT 01119 arbb_error_t arbb_execute(arbb_function_t function, 01120 const arbb_variable_t* outputs, 01121 const arbb_variable_t* inputs, 01122 arbb_error_details_t* details); 01123 01130 ARBB_VM_EXPORT 01131 arbb_error_t arbb_compile(arbb_function_t function, 01132 arbb_error_details_t* details); 01133 01140 ARBB_VM_EXPORT 01141 arbb_error_t arbb_finish(arbb_error_details_t* details); 01142 01144 01147 01155 ARBB_VM_EXPORT 01156 arbb_error_t arbb_push_map_coord(arbb_context_t context, 01157 uint64_t x, 01158 uint64_t y, 01159 uint64_t z, 01160 arbb_error_details_t* details); 01161 01168 ARBB_VM_EXPORT 01169 arbb_error_t arbb_pop_map_coord(arbb_context_t context, 01170 arbb_error_details_t* details); 01171 01183 ARBB_VM_EXPORT 01184 arbb_error_t arbb_set_scalar_source_element(arbb_context_t context, 01185 arbb_variable_t scalar, 01186 arbb_variable_t source_container, 01187 arbb_error_details_t* details); 01188 01197 ARBB_VM_EXPORT 01198 arbb_error_t 01199 arbb_set_copy_scalar_source_element(arbb_context_t context, 01200 arbb_variable_t scalar, 01201 arbb_error_details_t* out_error_details); 01202 01204 01207 01214 ARBB_VM_EXPORT 01215 arbb_error_t arbb_push_function(arbb_context_t context, 01216 arbb_function_t function, 01217 arbb_error_details_t* details); 01218 01225 ARBB_VM_EXPORT 01226 arbb_error_t arbb_pop_function(arbb_context_t context, 01227 arbb_error_details_t* details); 01228 01237 ARBB_VM_EXPORT 01238 arbb_error_t arbb_top_function(arbb_context_t context, 01239 arbb_function_t* out_function, 01240 arbb_error_details_t* details); 01241 01243 01245 01246 #ifdef __cplusplus 01247 } /* extern "C" */ 01248 #endif 01249 01250 #endif // ARBB_VM_API_H
Copyright © 2010, Intel Corporation. All rights reserved.