1 #ifndef INFO_RET_H 2 #define INFO_RET_H 3 4 #include "ext.h" 5 #include "strbuf.h" 6 7 /* The cl_device_topology_amd structure is missing domain infromation, but the NV queries expose them, 8 * so we define our own structure that supersets both, and convert to this before printing */ 9 10 struct clinfo_device_topology_pci { 11 cl_uint domain; 12 cl_uchar bus; 13 cl_uchar device; 14 cl_uchar function; 15 }; 16 17 /* Return type of the functions that gather platform info */ 18 struct platform_info_ret 19 { 20 cl_int err; 21 /* string representation of the value (if any) */ 22 struct _strbuf str; 23 /* error representation of the value (if any) */ 24 struct _strbuf err_str; 25 /* actual value, when not a string */ 26 union { 27 size_t s; 28 cl_uint u32; 29 cl_ulong u64; 30 } value; 31 /* Does this ret need escaping as JSON? */ 32 cl_bool needs_escaping; 33 }; 34 35 /* Return type of the functions that print device info */ 36 struct device_info_ret { 37 cl_int err; 38 /* string representation of the value (if any) */ 39 struct _strbuf str; 40 /* error representation of the value (if any) */ 41 struct _strbuf err_str; 42 /* actual value, when not a string */ 43 union { 44 size_t s; 45 cl_long i64; 46 cl_ulong u64; 47 cl_ulong2 u64v2; 48 cl_ulong4 u64v; 49 cl_int i32; 50 cl_uint u32; 51 cl_uint4 u32v; 52 cl_bitfield bits; 53 cl_bool b; 54 cl_device_type devtype; 55 cl_device_mem_cache_type cachetype; 56 cl_device_local_mem_type lmemtype; 57 cl_device_topology_amd devtopo_amd; 58 cl_device_affinity_domain affinity_domain; 59 cl_device_fp_config fpconfig; 60 cl_command_queue_properties qprop; 61 cl_device_exec_capabilities execap; 62 cl_device_svm_capabilities svmcap; 63 cl_device_terminate_capability_khr termcap; 64 struct clinfo_device_topology_pci devtopo_pci; 65 } value; 66 /* pointer base for array data or other auxiliary information */ 67 union { 68 void *ptr; // TODO 69 cl_context ctx; // associated context 70 } base; 71 /* Does this ret need escaping as JSON? */ 72 cl_bool needs_escaping; 73 }; 74 75 /* Return type of the functions that gather ICD loader info */ 76 struct icdl_info_ret 77 { 78 cl_int err; 79 /* string representation of the value (if any) */ 80 struct _strbuf str; 81 /* error representation of the value (if any) */ 82 struct _strbuf err_str; 83 }; 84 85 #define RET_BUF(ret) (ret.err ? &ret.err_str : &ret.str) 86 #define RET_BUF_PTR(ret) (ret->err ? &ret->err_str : &ret->str) 87 #define INIT_RET(ret, msg) do { \ 88 init_strbuf(&ret.str, msg " info string values"); \ 89 init_strbuf(&ret.err_str, msg " info error values"); \ 90 } while (0) 91 92 #define UNINIT_RET(ret) do { \ 93 free_strbuf(&ret.str); \ 94 free_strbuf(&ret.err_str); \ 95 } while (0) 96 97 98 #endif 99