comgr.py 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  1. # mypy: ignore-errors
  2. # -*- coding: utf-8 -*-
  3. #
  4. # TARGET arch is: ['-D__HIP_PLATFORM_AMD__', '-I/opt/rocm/include', '-x', 'c++']
  5. # WORD_SIZE is: 8
  6. # POINTER_SIZE is: 8
  7. # LONGDOUBLE_SIZE is: 16
  8. #
  9. import ctypes, ctypes.util, os
  10. PATHS_TO_TRY = [
  11. '/opt/rocm/lib/libamd_comgr.so',
  12. os.getenv('ROCM_PATH', '')+'/lib/libamd_comgr.so',
  13. ]
  14. def _try_dlopen_amd_comgr():
  15. library = ctypes.util.find_library("amd_comgr")
  16. if library: return ctypes.CDLL(library)
  17. for candidate in PATHS_TO_TRY:
  18. try: return ctypes.CDLL(candidate)
  19. except OSError: pass
  20. raise RuntimeError("library amd_comgr not found")
  21. def string_cast(char_pointer, encoding='utf-8', errors='strict'):
  22. value = ctypes.cast(char_pointer, ctypes.c_char_p).value
  23. if value is not None and encoding is not None:
  24. value = value.decode(encoding, errors=errors)
  25. return value
  26. def char_pointer_cast(string, encoding='utf-8'):
  27. if encoding is not None:
  28. try:
  29. string = string.encode(encoding)
  30. except AttributeError:
  31. # In Python3, bytes has no encode attribute
  32. pass
  33. string = ctypes.c_char_p(string)
  34. return ctypes.cast(string, ctypes.POINTER(ctypes.c_char))
  35. _libraries = {}
  36. _libraries['libamd_comgr.so'] = _try_dlopen_amd_comgr()
  37. c_int128 = ctypes.c_ubyte*16
  38. c_uint128 = c_int128
  39. void = None
  40. if ctypes.sizeof(ctypes.c_longdouble) == 16:
  41. c_long_double_t = ctypes.c_longdouble
  42. else:
  43. c_long_double_t = ctypes.c_ubyte*16
  44. class AsDictMixin:
  45. @classmethod
  46. def as_dict(cls, self):
  47. result = {}
  48. if not isinstance(self, AsDictMixin):
  49. # not a structure, assume it's already a python object
  50. return self
  51. if not hasattr(cls, "_fields_"):
  52. return result
  53. # sys.version_info >= (3, 5)
  54. # for (field, *_) in cls._fields_: # noqa
  55. for field_tuple in cls._fields_: # noqa
  56. field = field_tuple[0]
  57. if field.startswith('PADDING_'):
  58. continue
  59. value = getattr(self, field)
  60. type_ = type(value)
  61. if hasattr(value, "_length_") and hasattr(value, "_type_"):
  62. # array
  63. if not hasattr(type_, "as_dict"):
  64. value = [v for v in value]
  65. else:
  66. type_ = type_._type_
  67. value = [type_.as_dict(v) for v in value]
  68. elif hasattr(value, "contents") and hasattr(value, "_type_"):
  69. # pointer
  70. try:
  71. if not hasattr(type_, "as_dict"):
  72. value = value.contents
  73. else:
  74. type_ = type_._type_
  75. value = type_.as_dict(value.contents)
  76. except ValueError:
  77. # nullptr
  78. value = None
  79. elif isinstance(value, AsDictMixin):
  80. # other structure
  81. value = type_.as_dict(value)
  82. result[field] = value
  83. return result
  84. class Structure(ctypes.Structure, AsDictMixin):
  85. def __init__(self, *args, **kwds):
  86. # We don't want to use positional arguments fill PADDING_* fields
  87. args = dict(zip(self.__class__._field_names_(), args))
  88. args.update(kwds)
  89. super(Structure, self).__init__(**args)
  90. @classmethod
  91. def _field_names_(cls):
  92. if hasattr(cls, '_fields_'):
  93. return (f[0] for f in cls._fields_ if not f[0].startswith('PADDING'))
  94. else:
  95. return ()
  96. @classmethod
  97. def get_type(cls, field):
  98. for f in cls._fields_:
  99. if f[0] == field:
  100. return f[1]
  101. return None
  102. @classmethod
  103. def bind(cls, bound_fields):
  104. fields = {}
  105. for name, type_ in cls._fields_:
  106. if hasattr(type_, "restype"):
  107. if name in bound_fields:
  108. if bound_fields[name] is None:
  109. fields[name] = type_()
  110. else:
  111. # use a closure to capture the callback from the loop scope
  112. fields[name] = (
  113. type_((lambda callback: lambda *args: callback(*args))(
  114. bound_fields[name]))
  115. )
  116. del bound_fields[name]
  117. else:
  118. # default callback implementation (does nothing)
  119. try:
  120. default_ = type_(0).restype().value
  121. except TypeError:
  122. default_ = None
  123. fields[name] = type_((
  124. lambda default_: lambda *args: default_)(default_))
  125. else:
  126. # not a callback function, use default initialization
  127. if name in bound_fields:
  128. fields[name] = bound_fields[name]
  129. del bound_fields[name]
  130. else:
  131. fields[name] = type_()
  132. if len(bound_fields) != 0:
  133. raise ValueError(
  134. "Cannot bind the following unknown callback(s) {}.{}".format(
  135. cls.__name__, bound_fields.keys()
  136. ))
  137. return cls(**fields)
  138. class Union(ctypes.Union, AsDictMixin):
  139. pass
  140. # values for enumeration 'amd_comgr_status_s'
  141. amd_comgr_status_s__enumvalues = {
  142. 0: 'AMD_COMGR_STATUS_SUCCESS',
  143. 1: 'AMD_COMGR_STATUS_ERROR',
  144. 2: 'AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT',
  145. 3: 'AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES',
  146. }
  147. AMD_COMGR_STATUS_SUCCESS = 0
  148. AMD_COMGR_STATUS_ERROR = 1
  149. AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT = 2
  150. AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES = 3
  151. amd_comgr_status_s = ctypes.c_uint32 # enum
  152. amd_comgr_status_t = amd_comgr_status_s
  153. amd_comgr_status_t__enumvalues = amd_comgr_status_s__enumvalues
  154. # values for enumeration 'amd_comgr_language_s'
  155. amd_comgr_language_s__enumvalues = {
  156. 0: 'AMD_COMGR_LANGUAGE_NONE',
  157. 1: 'AMD_COMGR_LANGUAGE_OPENCL_1_2',
  158. 2: 'AMD_COMGR_LANGUAGE_OPENCL_2_0',
  159. 3: 'AMD_COMGR_LANGUAGE_HC',
  160. 4: 'AMD_COMGR_LANGUAGE_HIP',
  161. 5: 'AMD_COMGR_LANGUAGE_LLVM_IR',
  162. 5: 'AMD_COMGR_LANGUAGE_LAST',
  163. }
  164. AMD_COMGR_LANGUAGE_NONE = 0
  165. AMD_COMGR_LANGUAGE_OPENCL_1_2 = 1
  166. AMD_COMGR_LANGUAGE_OPENCL_2_0 = 2
  167. AMD_COMGR_LANGUAGE_HC = 3
  168. AMD_COMGR_LANGUAGE_HIP = 4
  169. AMD_COMGR_LANGUAGE_LLVM_IR = 5
  170. AMD_COMGR_LANGUAGE_LAST = 5
  171. amd_comgr_language_s = ctypes.c_uint32 # enum
  172. amd_comgr_language_t = amd_comgr_language_s
  173. amd_comgr_language_t__enumvalues = amd_comgr_language_s__enumvalues
  174. try:
  175. amd_comgr_status_string = _libraries['libamd_comgr.so'].amd_comgr_status_string
  176. amd_comgr_status_string.restype = amd_comgr_status_t
  177. amd_comgr_status_string.argtypes = [amd_comgr_status_t, ctypes.POINTER(ctypes.POINTER(ctypes.c_char))]
  178. except AttributeError:
  179. pass
  180. try:
  181. amd_comgr_get_version = _libraries['libamd_comgr.so'].amd_comgr_get_version
  182. amd_comgr_get_version.restype = None
  183. amd_comgr_get_version.argtypes = [ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_uint64)]
  184. except AttributeError:
  185. pass
  186. # values for enumeration 'amd_comgr_data_kind_s'
  187. amd_comgr_data_kind_s__enumvalues = {
  188. 0: 'AMD_COMGR_DATA_KIND_UNDEF',
  189. 1: 'AMD_COMGR_DATA_KIND_SOURCE',
  190. 2: 'AMD_COMGR_DATA_KIND_INCLUDE',
  191. 3: 'AMD_COMGR_DATA_KIND_PRECOMPILED_HEADER',
  192. 4: 'AMD_COMGR_DATA_KIND_DIAGNOSTIC',
  193. 5: 'AMD_COMGR_DATA_KIND_LOG',
  194. 6: 'AMD_COMGR_DATA_KIND_BC',
  195. 7: 'AMD_COMGR_DATA_KIND_RELOCATABLE',
  196. 8: 'AMD_COMGR_DATA_KIND_EXECUTABLE',
  197. 9: 'AMD_COMGR_DATA_KIND_BYTES',
  198. 16: 'AMD_COMGR_DATA_KIND_FATBIN',
  199. 17: 'AMD_COMGR_DATA_KIND_AR',
  200. 18: 'AMD_COMGR_DATA_KIND_BC_BUNDLE',
  201. 19: 'AMD_COMGR_DATA_KIND_AR_BUNDLE',
  202. 19: 'AMD_COMGR_DATA_KIND_LAST',
  203. }
  204. AMD_COMGR_DATA_KIND_UNDEF = 0
  205. AMD_COMGR_DATA_KIND_SOURCE = 1
  206. AMD_COMGR_DATA_KIND_INCLUDE = 2
  207. AMD_COMGR_DATA_KIND_PRECOMPILED_HEADER = 3
  208. AMD_COMGR_DATA_KIND_DIAGNOSTIC = 4
  209. AMD_COMGR_DATA_KIND_LOG = 5
  210. AMD_COMGR_DATA_KIND_BC = 6
  211. AMD_COMGR_DATA_KIND_RELOCATABLE = 7
  212. AMD_COMGR_DATA_KIND_EXECUTABLE = 8
  213. AMD_COMGR_DATA_KIND_BYTES = 9
  214. AMD_COMGR_DATA_KIND_FATBIN = 16
  215. AMD_COMGR_DATA_KIND_AR = 17
  216. AMD_COMGR_DATA_KIND_BC_BUNDLE = 18
  217. AMD_COMGR_DATA_KIND_AR_BUNDLE = 19
  218. AMD_COMGR_DATA_KIND_LAST = 19
  219. amd_comgr_data_kind_s = ctypes.c_uint32 # enum
  220. amd_comgr_data_kind_t = amd_comgr_data_kind_s
  221. amd_comgr_data_kind_t__enumvalues = amd_comgr_data_kind_s__enumvalues
  222. class struct_amd_comgr_data_s(Structure):
  223. pass
  224. struct_amd_comgr_data_s._pack_ = 1 # source:False
  225. struct_amd_comgr_data_s._fields_ = [
  226. ('handle', ctypes.c_uint64),
  227. ]
  228. amd_comgr_data_t = struct_amd_comgr_data_s
  229. class struct_amd_comgr_data_set_s(Structure):
  230. pass
  231. struct_amd_comgr_data_set_s._pack_ = 1 # source:False
  232. struct_amd_comgr_data_set_s._fields_ = [
  233. ('handle', ctypes.c_uint64),
  234. ]
  235. amd_comgr_data_set_t = struct_amd_comgr_data_set_s
  236. class struct_amd_comgr_action_info_s(Structure):
  237. pass
  238. struct_amd_comgr_action_info_s._pack_ = 1 # source:False
  239. struct_amd_comgr_action_info_s._fields_ = [
  240. ('handle', ctypes.c_uint64),
  241. ]
  242. amd_comgr_action_info_t = struct_amd_comgr_action_info_s
  243. class struct_amd_comgr_metadata_node_s(Structure):
  244. pass
  245. struct_amd_comgr_metadata_node_s._pack_ = 1 # source:False
  246. struct_amd_comgr_metadata_node_s._fields_ = [
  247. ('handle', ctypes.c_uint64),
  248. ]
  249. amd_comgr_metadata_node_t = struct_amd_comgr_metadata_node_s
  250. class struct_amd_comgr_symbol_s(Structure):
  251. pass
  252. struct_amd_comgr_symbol_s._pack_ = 1 # source:False
  253. struct_amd_comgr_symbol_s._fields_ = [
  254. ('handle', ctypes.c_uint64),
  255. ]
  256. amd_comgr_symbol_t = struct_amd_comgr_symbol_s
  257. class struct_amd_comgr_disassembly_info_s(Structure):
  258. pass
  259. struct_amd_comgr_disassembly_info_s._pack_ = 1 # source:False
  260. struct_amd_comgr_disassembly_info_s._fields_ = [
  261. ('handle', ctypes.c_uint64),
  262. ]
  263. amd_comgr_disassembly_info_t = struct_amd_comgr_disassembly_info_s
  264. class struct_amd_comgr_symbolizer_info_s(Structure):
  265. pass
  266. struct_amd_comgr_symbolizer_info_s._pack_ = 1 # source:False
  267. struct_amd_comgr_symbolizer_info_s._fields_ = [
  268. ('handle', ctypes.c_uint64),
  269. ]
  270. amd_comgr_symbolizer_info_t = struct_amd_comgr_symbolizer_info_s
  271. try:
  272. amd_comgr_get_isa_count = _libraries['libamd_comgr.so'].amd_comgr_get_isa_count
  273. amd_comgr_get_isa_count.restype = amd_comgr_status_t
  274. amd_comgr_get_isa_count.argtypes = [ctypes.POINTER(ctypes.c_uint64)]
  275. except AttributeError:
  276. pass
  277. size_t = ctypes.c_uint64
  278. try:
  279. amd_comgr_get_isa_name = _libraries['libamd_comgr.so'].amd_comgr_get_isa_name
  280. amd_comgr_get_isa_name.restype = amd_comgr_status_t
  281. amd_comgr_get_isa_name.argtypes = [size_t, ctypes.POINTER(ctypes.POINTER(ctypes.c_char))]
  282. except AttributeError:
  283. pass
  284. try:
  285. amd_comgr_get_isa_metadata = _libraries['libamd_comgr.so'].amd_comgr_get_isa_metadata
  286. amd_comgr_get_isa_metadata.restype = amd_comgr_status_t
  287. amd_comgr_get_isa_metadata.argtypes = [ctypes.POINTER(ctypes.c_char), ctypes.POINTER(struct_amd_comgr_metadata_node_s)]
  288. except AttributeError:
  289. pass
  290. try:
  291. amd_comgr_create_data = _libraries['libamd_comgr.so'].amd_comgr_create_data
  292. amd_comgr_create_data.restype = amd_comgr_status_t
  293. amd_comgr_create_data.argtypes = [amd_comgr_data_kind_t, ctypes.POINTER(struct_amd_comgr_data_s)]
  294. except AttributeError:
  295. pass
  296. try:
  297. amd_comgr_release_data = _libraries['libamd_comgr.so'].amd_comgr_release_data
  298. amd_comgr_release_data.restype = amd_comgr_status_t
  299. amd_comgr_release_data.argtypes = [amd_comgr_data_t]
  300. except AttributeError:
  301. pass
  302. try:
  303. amd_comgr_get_data_kind = _libraries['libamd_comgr.so'].amd_comgr_get_data_kind
  304. amd_comgr_get_data_kind.restype = amd_comgr_status_t
  305. amd_comgr_get_data_kind.argtypes = [amd_comgr_data_t, ctypes.POINTER(amd_comgr_data_kind_s)]
  306. except AttributeError:
  307. pass
  308. try:
  309. amd_comgr_set_data = _libraries['libamd_comgr.so'].amd_comgr_set_data
  310. amd_comgr_set_data.restype = amd_comgr_status_t
  311. amd_comgr_set_data.argtypes = [amd_comgr_data_t, size_t, ctypes.POINTER(ctypes.c_char)]
  312. except AttributeError:
  313. pass
  314. uint64_t = ctypes.c_uint64
  315. try:
  316. amd_comgr_set_data_from_file_slice = _libraries['libamd_comgr.so'].amd_comgr_set_data_from_file_slice
  317. amd_comgr_set_data_from_file_slice.restype = amd_comgr_status_t
  318. amd_comgr_set_data_from_file_slice.argtypes = [amd_comgr_data_t, ctypes.c_int32, uint64_t, uint64_t]
  319. except AttributeError:
  320. pass
  321. try:
  322. amd_comgr_set_data_name = _libraries['libamd_comgr.so'].amd_comgr_set_data_name
  323. amd_comgr_set_data_name.restype = amd_comgr_status_t
  324. amd_comgr_set_data_name.argtypes = [amd_comgr_data_t, ctypes.POINTER(ctypes.c_char)]
  325. except AttributeError:
  326. pass
  327. try:
  328. amd_comgr_get_data = _libraries['libamd_comgr.so'].amd_comgr_get_data
  329. amd_comgr_get_data.restype = amd_comgr_status_t
  330. amd_comgr_get_data.argtypes = [amd_comgr_data_t, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_char)]
  331. except AttributeError:
  332. pass
  333. try:
  334. amd_comgr_get_data_name = _libraries['libamd_comgr.so'].amd_comgr_get_data_name
  335. amd_comgr_get_data_name.restype = amd_comgr_status_t
  336. amd_comgr_get_data_name.argtypes = [amd_comgr_data_t, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_char)]
  337. except AttributeError:
  338. pass
  339. try:
  340. amd_comgr_get_data_isa_name = _libraries['libamd_comgr.so'].amd_comgr_get_data_isa_name
  341. amd_comgr_get_data_isa_name.restype = amd_comgr_status_t
  342. amd_comgr_get_data_isa_name.argtypes = [amd_comgr_data_t, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_char)]
  343. except AttributeError:
  344. pass
  345. try:
  346. amd_comgr_create_symbolizer_info = _libraries['libamd_comgr.so'].amd_comgr_create_symbolizer_info
  347. amd_comgr_create_symbolizer_info.restype = amd_comgr_status_t
  348. amd_comgr_create_symbolizer_info.argtypes = [amd_comgr_data_t, ctypes.CFUNCTYPE(None, ctypes.POINTER(ctypes.c_char), ctypes.POINTER(None)), ctypes.POINTER(struct_amd_comgr_symbolizer_info_s)]
  349. except AttributeError:
  350. pass
  351. try:
  352. amd_comgr_destroy_symbolizer_info = _libraries['libamd_comgr.so'].amd_comgr_destroy_symbolizer_info
  353. amd_comgr_destroy_symbolizer_info.restype = amd_comgr_status_t
  354. amd_comgr_destroy_symbolizer_info.argtypes = [amd_comgr_symbolizer_info_t]
  355. except AttributeError:
  356. pass
  357. try:
  358. amd_comgr_symbolize = _libraries['libamd_comgr.so'].amd_comgr_symbolize
  359. amd_comgr_symbolize.restype = amd_comgr_status_t
  360. amd_comgr_symbolize.argtypes = [amd_comgr_symbolizer_info_t, uint64_t, ctypes.c_bool, ctypes.POINTER(None)]
  361. except AttributeError:
  362. pass
  363. try:
  364. amd_comgr_get_data_metadata = _libraries['libamd_comgr.so'].amd_comgr_get_data_metadata
  365. amd_comgr_get_data_metadata.restype = amd_comgr_status_t
  366. amd_comgr_get_data_metadata.argtypes = [amd_comgr_data_t, ctypes.POINTER(struct_amd_comgr_metadata_node_s)]
  367. except AttributeError:
  368. pass
  369. try:
  370. amd_comgr_destroy_metadata = _libraries['libamd_comgr.so'].amd_comgr_destroy_metadata
  371. amd_comgr_destroy_metadata.restype = amd_comgr_status_t
  372. amd_comgr_destroy_metadata.argtypes = [amd_comgr_metadata_node_t]
  373. except AttributeError:
  374. pass
  375. try:
  376. amd_comgr_create_data_set = _libraries['libamd_comgr.so'].amd_comgr_create_data_set
  377. amd_comgr_create_data_set.restype = amd_comgr_status_t
  378. amd_comgr_create_data_set.argtypes = [ctypes.POINTER(struct_amd_comgr_data_set_s)]
  379. except AttributeError:
  380. pass
  381. try:
  382. amd_comgr_destroy_data_set = _libraries['libamd_comgr.so'].amd_comgr_destroy_data_set
  383. amd_comgr_destroy_data_set.restype = amd_comgr_status_t
  384. amd_comgr_destroy_data_set.argtypes = [amd_comgr_data_set_t]
  385. except AttributeError:
  386. pass
  387. try:
  388. amd_comgr_data_set_add = _libraries['libamd_comgr.so'].amd_comgr_data_set_add
  389. amd_comgr_data_set_add.restype = amd_comgr_status_t
  390. amd_comgr_data_set_add.argtypes = [amd_comgr_data_set_t, amd_comgr_data_t]
  391. except AttributeError:
  392. pass
  393. try:
  394. amd_comgr_data_set_remove = _libraries['libamd_comgr.so'].amd_comgr_data_set_remove
  395. amd_comgr_data_set_remove.restype = amd_comgr_status_t
  396. amd_comgr_data_set_remove.argtypes = [amd_comgr_data_set_t, amd_comgr_data_kind_t]
  397. except AttributeError:
  398. pass
  399. try:
  400. amd_comgr_action_data_count = _libraries['libamd_comgr.so'].amd_comgr_action_data_count
  401. amd_comgr_action_data_count.restype = amd_comgr_status_t
  402. amd_comgr_action_data_count.argtypes = [amd_comgr_data_set_t, amd_comgr_data_kind_t, ctypes.POINTER(ctypes.c_uint64)]
  403. except AttributeError:
  404. pass
  405. try:
  406. amd_comgr_action_data_get_data = _libraries['libamd_comgr.so'].amd_comgr_action_data_get_data
  407. amd_comgr_action_data_get_data.restype = amd_comgr_status_t
  408. amd_comgr_action_data_get_data.argtypes = [amd_comgr_data_set_t, amd_comgr_data_kind_t, size_t, ctypes.POINTER(struct_amd_comgr_data_s)]
  409. except AttributeError:
  410. pass
  411. try:
  412. amd_comgr_create_action_info = _libraries['libamd_comgr.so'].amd_comgr_create_action_info
  413. amd_comgr_create_action_info.restype = amd_comgr_status_t
  414. amd_comgr_create_action_info.argtypes = [ctypes.POINTER(struct_amd_comgr_action_info_s)]
  415. except AttributeError:
  416. pass
  417. try:
  418. amd_comgr_destroy_action_info = _libraries['libamd_comgr.so'].amd_comgr_destroy_action_info
  419. amd_comgr_destroy_action_info.restype = amd_comgr_status_t
  420. amd_comgr_destroy_action_info.argtypes = [amd_comgr_action_info_t]
  421. except AttributeError:
  422. pass
  423. try:
  424. amd_comgr_action_info_set_isa_name = _libraries['libamd_comgr.so'].amd_comgr_action_info_set_isa_name
  425. amd_comgr_action_info_set_isa_name.restype = amd_comgr_status_t
  426. amd_comgr_action_info_set_isa_name.argtypes = [amd_comgr_action_info_t, ctypes.POINTER(ctypes.c_char)]
  427. except AttributeError:
  428. pass
  429. try:
  430. amd_comgr_action_info_get_isa_name = _libraries['libamd_comgr.so'].amd_comgr_action_info_get_isa_name
  431. amd_comgr_action_info_get_isa_name.restype = amd_comgr_status_t
  432. amd_comgr_action_info_get_isa_name.argtypes = [amd_comgr_action_info_t, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_char)]
  433. except AttributeError:
  434. pass
  435. try:
  436. amd_comgr_action_info_set_language = _libraries['libamd_comgr.so'].amd_comgr_action_info_set_language
  437. amd_comgr_action_info_set_language.restype = amd_comgr_status_t
  438. amd_comgr_action_info_set_language.argtypes = [amd_comgr_action_info_t, amd_comgr_language_t]
  439. except AttributeError:
  440. pass
  441. try:
  442. amd_comgr_action_info_get_language = _libraries['libamd_comgr.so'].amd_comgr_action_info_get_language
  443. amd_comgr_action_info_get_language.restype = amd_comgr_status_t
  444. amd_comgr_action_info_get_language.argtypes = [amd_comgr_action_info_t, ctypes.POINTER(amd_comgr_language_s)]
  445. except AttributeError:
  446. pass
  447. try:
  448. amd_comgr_action_info_set_options = _libraries['libamd_comgr.so'].amd_comgr_action_info_set_options
  449. amd_comgr_action_info_set_options.restype = amd_comgr_status_t
  450. amd_comgr_action_info_set_options.argtypes = [amd_comgr_action_info_t, ctypes.POINTER(ctypes.c_char)]
  451. except AttributeError:
  452. pass
  453. try:
  454. amd_comgr_action_info_get_options = _libraries['libamd_comgr.so'].amd_comgr_action_info_get_options
  455. amd_comgr_action_info_get_options.restype = amd_comgr_status_t
  456. amd_comgr_action_info_get_options.argtypes = [amd_comgr_action_info_t, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_char)]
  457. except AttributeError:
  458. pass
  459. try:
  460. amd_comgr_action_info_set_option_list = _libraries['libamd_comgr.so'].amd_comgr_action_info_set_option_list
  461. amd_comgr_action_info_set_option_list.restype = amd_comgr_status_t
  462. amd_comgr_action_info_set_option_list.argtypes = [amd_comgr_action_info_t, ctypes.POINTER(ctypes.c_char) * 0, size_t]
  463. except AttributeError:
  464. pass
  465. try:
  466. amd_comgr_action_info_get_option_list_count = _libraries['libamd_comgr.so'].amd_comgr_action_info_get_option_list_count
  467. amd_comgr_action_info_get_option_list_count.restype = amd_comgr_status_t
  468. amd_comgr_action_info_get_option_list_count.argtypes = [amd_comgr_action_info_t, ctypes.POINTER(ctypes.c_uint64)]
  469. except AttributeError:
  470. pass
  471. try:
  472. amd_comgr_action_info_get_option_list_item = _libraries['libamd_comgr.so'].amd_comgr_action_info_get_option_list_item
  473. amd_comgr_action_info_get_option_list_item.restype = amd_comgr_status_t
  474. amd_comgr_action_info_get_option_list_item.argtypes = [amd_comgr_action_info_t, size_t, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_char)]
  475. except AttributeError:
  476. pass
  477. try:
  478. amd_comgr_action_info_set_working_directory_path = _libraries['libamd_comgr.so'].amd_comgr_action_info_set_working_directory_path
  479. amd_comgr_action_info_set_working_directory_path.restype = amd_comgr_status_t
  480. amd_comgr_action_info_set_working_directory_path.argtypes = [amd_comgr_action_info_t, ctypes.POINTER(ctypes.c_char)]
  481. except AttributeError:
  482. pass
  483. try:
  484. amd_comgr_action_info_get_working_directory_path = _libraries['libamd_comgr.so'].amd_comgr_action_info_get_working_directory_path
  485. amd_comgr_action_info_get_working_directory_path.restype = amd_comgr_status_t
  486. amd_comgr_action_info_get_working_directory_path.argtypes = [amd_comgr_action_info_t, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_char)]
  487. except AttributeError:
  488. pass
  489. try:
  490. amd_comgr_action_info_set_logging = _libraries['libamd_comgr.so'].amd_comgr_action_info_set_logging
  491. amd_comgr_action_info_set_logging.restype = amd_comgr_status_t
  492. amd_comgr_action_info_set_logging.argtypes = [amd_comgr_action_info_t, ctypes.c_bool]
  493. except AttributeError:
  494. pass
  495. try:
  496. amd_comgr_action_info_get_logging = _libraries['libamd_comgr.so'].amd_comgr_action_info_get_logging
  497. amd_comgr_action_info_get_logging.restype = amd_comgr_status_t
  498. amd_comgr_action_info_get_logging.argtypes = [amd_comgr_action_info_t, ctypes.POINTER(ctypes.c_bool)]
  499. except AttributeError:
  500. pass
  501. # values for enumeration 'amd_comgr_action_kind_s'
  502. amd_comgr_action_kind_s__enumvalues = {
  503. 0: 'AMD_COMGR_ACTION_SOURCE_TO_PREPROCESSOR',
  504. 1: 'AMD_COMGR_ACTION_ADD_PRECOMPILED_HEADERS',
  505. 2: 'AMD_COMGR_ACTION_COMPILE_SOURCE_TO_BC',
  506. 3: 'AMD_COMGR_ACTION_ADD_DEVICE_LIBRARIES',
  507. 4: 'AMD_COMGR_ACTION_LINK_BC_TO_BC',
  508. 5: 'AMD_COMGR_ACTION_OPTIMIZE_BC_TO_BC',
  509. 6: 'AMD_COMGR_ACTION_CODEGEN_BC_TO_RELOCATABLE',
  510. 7: 'AMD_COMGR_ACTION_CODEGEN_BC_TO_ASSEMBLY',
  511. 8: 'AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_RELOCATABLE',
  512. 9: 'AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_EXECUTABLE',
  513. 10: 'AMD_COMGR_ACTION_ASSEMBLE_SOURCE_TO_RELOCATABLE',
  514. 11: 'AMD_COMGR_ACTION_DISASSEMBLE_RELOCATABLE_TO_SOURCE',
  515. 12: 'AMD_COMGR_ACTION_DISASSEMBLE_EXECUTABLE_TO_SOURCE',
  516. 13: 'AMD_COMGR_ACTION_DISASSEMBLE_BYTES_TO_SOURCE',
  517. 14: 'AMD_COMGR_ACTION_COMPILE_SOURCE_TO_FATBIN',
  518. 15: 'AMD_COMGR_ACTION_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC',
  519. 16: 'AMD_COMGR_ACTION_COMPILE_SOURCE_TO_RELOCATABLE',
  520. 17: 'AMD_COMGR_ACTION_COMPILE_SOURCE_TO_EXECUTABLE',
  521. 17: 'AMD_COMGR_ACTION_LAST',
  522. }
  523. AMD_COMGR_ACTION_SOURCE_TO_PREPROCESSOR = 0
  524. AMD_COMGR_ACTION_ADD_PRECOMPILED_HEADERS = 1
  525. AMD_COMGR_ACTION_COMPILE_SOURCE_TO_BC = 2
  526. AMD_COMGR_ACTION_ADD_DEVICE_LIBRARIES = 3
  527. AMD_COMGR_ACTION_LINK_BC_TO_BC = 4
  528. AMD_COMGR_ACTION_OPTIMIZE_BC_TO_BC = 5
  529. AMD_COMGR_ACTION_CODEGEN_BC_TO_RELOCATABLE = 6
  530. AMD_COMGR_ACTION_CODEGEN_BC_TO_ASSEMBLY = 7
  531. AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_RELOCATABLE = 8
  532. AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_EXECUTABLE = 9
  533. AMD_COMGR_ACTION_ASSEMBLE_SOURCE_TO_RELOCATABLE = 10
  534. AMD_COMGR_ACTION_DISASSEMBLE_RELOCATABLE_TO_SOURCE = 11
  535. AMD_COMGR_ACTION_DISASSEMBLE_EXECUTABLE_TO_SOURCE = 12
  536. AMD_COMGR_ACTION_DISASSEMBLE_BYTES_TO_SOURCE = 13
  537. AMD_COMGR_ACTION_COMPILE_SOURCE_TO_FATBIN = 14
  538. AMD_COMGR_ACTION_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC = 15
  539. AMD_COMGR_ACTION_COMPILE_SOURCE_TO_RELOCATABLE = 16
  540. AMD_COMGR_ACTION_COMPILE_SOURCE_TO_EXECUTABLE = 17
  541. AMD_COMGR_ACTION_LAST = 17
  542. amd_comgr_action_kind_s = ctypes.c_uint32 # enum
  543. amd_comgr_action_kind_t = amd_comgr_action_kind_s
  544. amd_comgr_action_kind_t__enumvalues = amd_comgr_action_kind_s__enumvalues
  545. try:
  546. amd_comgr_do_action = _libraries['libamd_comgr.so'].amd_comgr_do_action
  547. amd_comgr_do_action.restype = amd_comgr_status_t
  548. amd_comgr_do_action.argtypes = [amd_comgr_action_kind_t, amd_comgr_action_info_t, amd_comgr_data_set_t, amd_comgr_data_set_t]
  549. except AttributeError:
  550. pass
  551. # values for enumeration 'amd_comgr_metadata_kind_s'
  552. amd_comgr_metadata_kind_s__enumvalues = {
  553. 0: 'AMD_COMGR_METADATA_KIND_NULL',
  554. 1: 'AMD_COMGR_METADATA_KIND_STRING',
  555. 2: 'AMD_COMGR_METADATA_KIND_MAP',
  556. 3: 'AMD_COMGR_METADATA_KIND_LIST',
  557. 3: 'AMD_COMGR_METADATA_KIND_LAST',
  558. }
  559. AMD_COMGR_METADATA_KIND_NULL = 0
  560. AMD_COMGR_METADATA_KIND_STRING = 1
  561. AMD_COMGR_METADATA_KIND_MAP = 2
  562. AMD_COMGR_METADATA_KIND_LIST = 3
  563. AMD_COMGR_METADATA_KIND_LAST = 3
  564. amd_comgr_metadata_kind_s = ctypes.c_uint32 # enum
  565. amd_comgr_metadata_kind_t = amd_comgr_metadata_kind_s
  566. amd_comgr_metadata_kind_t__enumvalues = amd_comgr_metadata_kind_s__enumvalues
  567. try:
  568. amd_comgr_get_metadata_kind = _libraries['libamd_comgr.so'].amd_comgr_get_metadata_kind
  569. amd_comgr_get_metadata_kind.restype = amd_comgr_status_t
  570. amd_comgr_get_metadata_kind.argtypes = [amd_comgr_metadata_node_t, ctypes.POINTER(amd_comgr_metadata_kind_s)]
  571. except AttributeError:
  572. pass
  573. try:
  574. amd_comgr_get_metadata_string = _libraries['libamd_comgr.so'].amd_comgr_get_metadata_string
  575. amd_comgr_get_metadata_string.restype = amd_comgr_status_t
  576. amd_comgr_get_metadata_string.argtypes = [amd_comgr_metadata_node_t, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_char)]
  577. except AttributeError:
  578. pass
  579. try:
  580. amd_comgr_get_metadata_map_size = _libraries['libamd_comgr.so'].amd_comgr_get_metadata_map_size
  581. amd_comgr_get_metadata_map_size.restype = amd_comgr_status_t
  582. amd_comgr_get_metadata_map_size.argtypes = [amd_comgr_metadata_node_t, ctypes.POINTER(ctypes.c_uint64)]
  583. except AttributeError:
  584. pass
  585. try:
  586. amd_comgr_iterate_map_metadata = _libraries['libamd_comgr.so'].amd_comgr_iterate_map_metadata
  587. amd_comgr_iterate_map_metadata.restype = amd_comgr_status_t
  588. amd_comgr_iterate_map_metadata.argtypes = [amd_comgr_metadata_node_t, ctypes.CFUNCTYPE(amd_comgr_status_s, struct_amd_comgr_metadata_node_s, struct_amd_comgr_metadata_node_s, ctypes.POINTER(None)), ctypes.POINTER(None)]
  589. except AttributeError:
  590. pass
  591. try:
  592. amd_comgr_metadata_lookup = _libraries['libamd_comgr.so'].amd_comgr_metadata_lookup
  593. amd_comgr_metadata_lookup.restype = amd_comgr_status_t
  594. amd_comgr_metadata_lookup.argtypes = [amd_comgr_metadata_node_t, ctypes.POINTER(ctypes.c_char), ctypes.POINTER(struct_amd_comgr_metadata_node_s)]
  595. except AttributeError:
  596. pass
  597. try:
  598. amd_comgr_get_metadata_list_size = _libraries['libamd_comgr.so'].amd_comgr_get_metadata_list_size
  599. amd_comgr_get_metadata_list_size.restype = amd_comgr_status_t
  600. amd_comgr_get_metadata_list_size.argtypes = [amd_comgr_metadata_node_t, ctypes.POINTER(ctypes.c_uint64)]
  601. except AttributeError:
  602. pass
  603. try:
  604. amd_comgr_index_list_metadata = _libraries['libamd_comgr.so'].amd_comgr_index_list_metadata
  605. amd_comgr_index_list_metadata.restype = amd_comgr_status_t
  606. amd_comgr_index_list_metadata.argtypes = [amd_comgr_metadata_node_t, size_t, ctypes.POINTER(struct_amd_comgr_metadata_node_s)]
  607. except AttributeError:
  608. pass
  609. try:
  610. amd_comgr_iterate_symbols = _libraries['libamd_comgr.so'].amd_comgr_iterate_symbols
  611. amd_comgr_iterate_symbols.restype = amd_comgr_status_t
  612. amd_comgr_iterate_symbols.argtypes = [amd_comgr_data_t, ctypes.CFUNCTYPE(amd_comgr_status_s, struct_amd_comgr_symbol_s, ctypes.POINTER(None)), ctypes.POINTER(None)]
  613. except AttributeError:
  614. pass
  615. try:
  616. amd_comgr_symbol_lookup = _libraries['libamd_comgr.so'].amd_comgr_symbol_lookup
  617. amd_comgr_symbol_lookup.restype = amd_comgr_status_t
  618. amd_comgr_symbol_lookup.argtypes = [amd_comgr_data_t, ctypes.POINTER(ctypes.c_char), ctypes.POINTER(struct_amd_comgr_symbol_s)]
  619. except AttributeError:
  620. pass
  621. # values for enumeration 'amd_comgr_symbol_type_s'
  622. amd_comgr_symbol_type_s__enumvalues = {
  623. -1: 'AMD_COMGR_SYMBOL_TYPE_UNKNOWN',
  624. 0: 'AMD_COMGR_SYMBOL_TYPE_NOTYPE',
  625. 1: 'AMD_COMGR_SYMBOL_TYPE_OBJECT',
  626. 2: 'AMD_COMGR_SYMBOL_TYPE_FUNC',
  627. 3: 'AMD_COMGR_SYMBOL_TYPE_SECTION',
  628. 4: 'AMD_COMGR_SYMBOL_TYPE_FILE',
  629. 5: 'AMD_COMGR_SYMBOL_TYPE_COMMON',
  630. 10: 'AMD_COMGR_SYMBOL_TYPE_AMDGPU_HSA_KERNEL',
  631. }
  632. AMD_COMGR_SYMBOL_TYPE_UNKNOWN = -1
  633. AMD_COMGR_SYMBOL_TYPE_NOTYPE = 0
  634. AMD_COMGR_SYMBOL_TYPE_OBJECT = 1
  635. AMD_COMGR_SYMBOL_TYPE_FUNC = 2
  636. AMD_COMGR_SYMBOL_TYPE_SECTION = 3
  637. AMD_COMGR_SYMBOL_TYPE_FILE = 4
  638. AMD_COMGR_SYMBOL_TYPE_COMMON = 5
  639. AMD_COMGR_SYMBOL_TYPE_AMDGPU_HSA_KERNEL = 10
  640. amd_comgr_symbol_type_s = ctypes.c_int32 # enum
  641. amd_comgr_symbol_type_t = amd_comgr_symbol_type_s
  642. amd_comgr_symbol_type_t__enumvalues = amd_comgr_symbol_type_s__enumvalues
  643. # values for enumeration 'amd_comgr_symbol_info_s'
  644. amd_comgr_symbol_info_s__enumvalues = {
  645. 0: 'AMD_COMGR_SYMBOL_INFO_NAME_LENGTH',
  646. 1: 'AMD_COMGR_SYMBOL_INFO_NAME',
  647. 2: 'AMD_COMGR_SYMBOL_INFO_TYPE',
  648. 3: 'AMD_COMGR_SYMBOL_INFO_SIZE',
  649. 4: 'AMD_COMGR_SYMBOL_INFO_IS_UNDEFINED',
  650. 5: 'AMD_COMGR_SYMBOL_INFO_VALUE',
  651. 5: 'AMD_COMGR_SYMBOL_INFO_LAST',
  652. }
  653. AMD_COMGR_SYMBOL_INFO_NAME_LENGTH = 0
  654. AMD_COMGR_SYMBOL_INFO_NAME = 1
  655. AMD_COMGR_SYMBOL_INFO_TYPE = 2
  656. AMD_COMGR_SYMBOL_INFO_SIZE = 3
  657. AMD_COMGR_SYMBOL_INFO_IS_UNDEFINED = 4
  658. AMD_COMGR_SYMBOL_INFO_VALUE = 5
  659. AMD_COMGR_SYMBOL_INFO_LAST = 5
  660. amd_comgr_symbol_info_s = ctypes.c_uint32 # enum
  661. amd_comgr_symbol_info_t = amd_comgr_symbol_info_s
  662. amd_comgr_symbol_info_t__enumvalues = amd_comgr_symbol_info_s__enumvalues
  663. try:
  664. amd_comgr_symbol_get_info = _libraries['libamd_comgr.so'].amd_comgr_symbol_get_info
  665. amd_comgr_symbol_get_info.restype = amd_comgr_status_t
  666. amd_comgr_symbol_get_info.argtypes = [amd_comgr_symbol_t, amd_comgr_symbol_info_t, ctypes.POINTER(None)]
  667. except AttributeError:
  668. pass
  669. try:
  670. amd_comgr_create_disassembly_info = _libraries['libamd_comgr.so'].amd_comgr_create_disassembly_info
  671. amd_comgr_create_disassembly_info.restype = amd_comgr_status_t
  672. amd_comgr_create_disassembly_info.argtypes = [ctypes.POINTER(ctypes.c_char), ctypes.CFUNCTYPE(ctypes.c_uint64, ctypes.c_uint64, ctypes.POINTER(ctypes.c_char), ctypes.c_uint64, ctypes.POINTER(None)), ctypes.CFUNCTYPE(None, ctypes.POINTER(ctypes.c_char), ctypes.POINTER(None)), ctypes.CFUNCTYPE(None, ctypes.c_uint64, ctypes.POINTER(None)), ctypes.POINTER(struct_amd_comgr_disassembly_info_s)]
  673. except AttributeError:
  674. pass
  675. try:
  676. amd_comgr_destroy_disassembly_info = _libraries['libamd_comgr.so'].amd_comgr_destroy_disassembly_info
  677. amd_comgr_destroy_disassembly_info.restype = amd_comgr_status_t
  678. amd_comgr_destroy_disassembly_info.argtypes = [amd_comgr_disassembly_info_t]
  679. except AttributeError:
  680. pass
  681. try:
  682. amd_comgr_disassemble_instruction = _libraries['libamd_comgr.so'].amd_comgr_disassemble_instruction
  683. amd_comgr_disassemble_instruction.restype = amd_comgr_status_t
  684. amd_comgr_disassemble_instruction.argtypes = [amd_comgr_disassembly_info_t, uint64_t, ctypes.POINTER(None), ctypes.POINTER(ctypes.c_uint64)]
  685. except AttributeError:
  686. pass
  687. try:
  688. amd_comgr_demangle_symbol_name = _libraries['libamd_comgr.so'].amd_comgr_demangle_symbol_name
  689. amd_comgr_demangle_symbol_name.restype = amd_comgr_status_t
  690. amd_comgr_demangle_symbol_name.argtypes = [amd_comgr_data_t, ctypes.POINTER(struct_amd_comgr_data_s)]
  691. except AttributeError:
  692. pass
  693. try:
  694. amd_comgr_populate_mangled_names = _libraries['libamd_comgr.so'].amd_comgr_populate_mangled_names
  695. amd_comgr_populate_mangled_names.restype = amd_comgr_status_t
  696. amd_comgr_populate_mangled_names.argtypes = [amd_comgr_data_t, ctypes.POINTER(ctypes.c_uint64)]
  697. except AttributeError:
  698. pass
  699. try:
  700. amd_comgr_get_mangled_name = _libraries['libamd_comgr.so'].amd_comgr_get_mangled_name
  701. amd_comgr_get_mangled_name.restype = amd_comgr_status_t
  702. amd_comgr_get_mangled_name.argtypes = [amd_comgr_data_t, size_t, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_char)]
  703. except AttributeError:
  704. pass
  705. try:
  706. amd_comgr_populate_name_expression_map = _libraries['libamd_comgr.so'].amd_comgr_populate_name_expression_map
  707. amd_comgr_populate_name_expression_map.restype = amd_comgr_status_t
  708. amd_comgr_populate_name_expression_map.argtypes = [amd_comgr_data_t, ctypes.POINTER(ctypes.c_uint64)]
  709. except AttributeError:
  710. pass
  711. try:
  712. amd_comgr_map_name_expression_to_symbol_name = _libraries['libamd_comgr.so'].amd_comgr_map_name_expression_to_symbol_name
  713. amd_comgr_map_name_expression_to_symbol_name.restype = amd_comgr_status_t
  714. amd_comgr_map_name_expression_to_symbol_name.argtypes = [amd_comgr_data_t, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_char), ctypes.POINTER(ctypes.c_char)]
  715. except AttributeError:
  716. pass
  717. class struct_code_object_info_s(Structure):
  718. pass
  719. struct_code_object_info_s._pack_ = 1 # source:False
  720. struct_code_object_info_s._fields_ = [
  721. ('isa', ctypes.POINTER(ctypes.c_char)),
  722. ('size', ctypes.c_uint64),
  723. ('offset', ctypes.c_uint64),
  724. ]
  725. amd_comgr_code_object_info_t = struct_code_object_info_s
  726. try:
  727. amd_comgr_lookup_code_object = _libraries['libamd_comgr.so'].amd_comgr_lookup_code_object
  728. amd_comgr_lookup_code_object.restype = amd_comgr_status_t
  729. amd_comgr_lookup_code_object.argtypes = [amd_comgr_data_t, ctypes.POINTER(struct_code_object_info_s), size_t]
  730. except AttributeError:
  731. pass
  732. try:
  733. amd_comgr_map_elf_virtual_address_to_code_object_offset = _libraries['libamd_comgr.so'].amd_comgr_map_elf_virtual_address_to_code_object_offset
  734. amd_comgr_map_elf_virtual_address_to_code_object_offset.restype = amd_comgr_status_t
  735. amd_comgr_map_elf_virtual_address_to_code_object_offset.argtypes = [amd_comgr_data_t, uint64_t, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_bool)]
  736. except AttributeError:
  737. pass
  738. __all__ = \
  739. ['AMD_COMGR_ACTION_ADD_DEVICE_LIBRARIES',
  740. 'AMD_COMGR_ACTION_ADD_PRECOMPILED_HEADERS',
  741. 'AMD_COMGR_ACTION_ASSEMBLE_SOURCE_TO_RELOCATABLE',
  742. 'AMD_COMGR_ACTION_CODEGEN_BC_TO_ASSEMBLY',
  743. 'AMD_COMGR_ACTION_CODEGEN_BC_TO_RELOCATABLE',
  744. 'AMD_COMGR_ACTION_COMPILE_SOURCE_TO_BC',
  745. 'AMD_COMGR_ACTION_COMPILE_SOURCE_TO_EXECUTABLE',
  746. 'AMD_COMGR_ACTION_COMPILE_SOURCE_TO_FATBIN',
  747. 'AMD_COMGR_ACTION_COMPILE_SOURCE_TO_RELOCATABLE',
  748. 'AMD_COMGR_ACTION_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC',
  749. 'AMD_COMGR_ACTION_DISASSEMBLE_BYTES_TO_SOURCE',
  750. 'AMD_COMGR_ACTION_DISASSEMBLE_EXECUTABLE_TO_SOURCE',
  751. 'AMD_COMGR_ACTION_DISASSEMBLE_RELOCATABLE_TO_SOURCE',
  752. 'AMD_COMGR_ACTION_LAST', 'AMD_COMGR_ACTION_LINK_BC_TO_BC',
  753. 'AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_EXECUTABLE',
  754. 'AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_RELOCATABLE',
  755. 'AMD_COMGR_ACTION_OPTIMIZE_BC_TO_BC',
  756. 'AMD_COMGR_ACTION_SOURCE_TO_PREPROCESSOR',
  757. 'AMD_COMGR_DATA_KIND_AR', 'AMD_COMGR_DATA_KIND_AR_BUNDLE',
  758. 'AMD_COMGR_DATA_KIND_BC', 'AMD_COMGR_DATA_KIND_BC_BUNDLE',
  759. 'AMD_COMGR_DATA_KIND_BYTES', 'AMD_COMGR_DATA_KIND_DIAGNOSTIC',
  760. 'AMD_COMGR_DATA_KIND_EXECUTABLE', 'AMD_COMGR_DATA_KIND_FATBIN',
  761. 'AMD_COMGR_DATA_KIND_INCLUDE', 'AMD_COMGR_DATA_KIND_LAST',
  762. 'AMD_COMGR_DATA_KIND_LOG',
  763. 'AMD_COMGR_DATA_KIND_PRECOMPILED_HEADER',
  764. 'AMD_COMGR_DATA_KIND_RELOCATABLE', 'AMD_COMGR_DATA_KIND_SOURCE',
  765. 'AMD_COMGR_DATA_KIND_UNDEF', 'AMD_COMGR_LANGUAGE_HC',
  766. 'AMD_COMGR_LANGUAGE_HIP', 'AMD_COMGR_LANGUAGE_LAST',
  767. 'AMD_COMGR_LANGUAGE_LLVM_IR', 'AMD_COMGR_LANGUAGE_NONE',
  768. 'AMD_COMGR_LANGUAGE_OPENCL_1_2', 'AMD_COMGR_LANGUAGE_OPENCL_2_0',
  769. 'AMD_COMGR_METADATA_KIND_LAST', 'AMD_COMGR_METADATA_KIND_LIST',
  770. 'AMD_COMGR_METADATA_KIND_MAP', 'AMD_COMGR_METADATA_KIND_NULL',
  771. 'AMD_COMGR_METADATA_KIND_STRING', 'AMD_COMGR_STATUS_ERROR',
  772. 'AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT',
  773. 'AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES',
  774. 'AMD_COMGR_STATUS_SUCCESS', 'AMD_COMGR_SYMBOL_INFO_IS_UNDEFINED',
  775. 'AMD_COMGR_SYMBOL_INFO_LAST', 'AMD_COMGR_SYMBOL_INFO_NAME',
  776. 'AMD_COMGR_SYMBOL_INFO_NAME_LENGTH', 'AMD_COMGR_SYMBOL_INFO_SIZE',
  777. 'AMD_COMGR_SYMBOL_INFO_TYPE', 'AMD_COMGR_SYMBOL_INFO_VALUE',
  778. 'AMD_COMGR_SYMBOL_TYPE_AMDGPU_HSA_KERNEL',
  779. 'AMD_COMGR_SYMBOL_TYPE_COMMON', 'AMD_COMGR_SYMBOL_TYPE_FILE',
  780. 'AMD_COMGR_SYMBOL_TYPE_FUNC', 'AMD_COMGR_SYMBOL_TYPE_NOTYPE',
  781. 'AMD_COMGR_SYMBOL_TYPE_OBJECT', 'AMD_COMGR_SYMBOL_TYPE_SECTION',
  782. 'AMD_COMGR_SYMBOL_TYPE_UNKNOWN', 'amd_comgr_action_data_count',
  783. 'amd_comgr_action_data_get_data',
  784. 'amd_comgr_action_info_get_isa_name',
  785. 'amd_comgr_action_info_get_language',
  786. 'amd_comgr_action_info_get_logging',
  787. 'amd_comgr_action_info_get_option_list_count',
  788. 'amd_comgr_action_info_get_option_list_item',
  789. 'amd_comgr_action_info_get_options',
  790. 'amd_comgr_action_info_get_working_directory_path',
  791. 'amd_comgr_action_info_set_isa_name',
  792. 'amd_comgr_action_info_set_language',
  793. 'amd_comgr_action_info_set_logging',
  794. 'amd_comgr_action_info_set_option_list',
  795. 'amd_comgr_action_info_set_options',
  796. 'amd_comgr_action_info_set_working_directory_path',
  797. 'amd_comgr_action_info_t', 'amd_comgr_action_kind_s',
  798. 'amd_comgr_action_kind_t', 'amd_comgr_action_kind_t__enumvalues',
  799. 'amd_comgr_code_object_info_t', 'amd_comgr_create_action_info',
  800. 'amd_comgr_create_data', 'amd_comgr_create_data_set',
  801. 'amd_comgr_create_disassembly_info',
  802. 'amd_comgr_create_symbolizer_info', 'amd_comgr_data_kind_s',
  803. 'amd_comgr_data_kind_t', 'amd_comgr_data_kind_t__enumvalues',
  804. 'amd_comgr_data_set_add', 'amd_comgr_data_set_remove',
  805. 'amd_comgr_data_set_t', 'amd_comgr_data_t',
  806. 'amd_comgr_demangle_symbol_name', 'amd_comgr_destroy_action_info',
  807. 'amd_comgr_destroy_data_set',
  808. 'amd_comgr_destroy_disassembly_info',
  809. 'amd_comgr_destroy_metadata', 'amd_comgr_destroy_symbolizer_info',
  810. 'amd_comgr_disassemble_instruction',
  811. 'amd_comgr_disassembly_info_t', 'amd_comgr_do_action',
  812. 'amd_comgr_get_data', 'amd_comgr_get_data_isa_name',
  813. 'amd_comgr_get_data_kind', 'amd_comgr_get_data_metadata',
  814. 'amd_comgr_get_data_name', 'amd_comgr_get_isa_count',
  815. 'amd_comgr_get_isa_metadata', 'amd_comgr_get_isa_name',
  816. 'amd_comgr_get_mangled_name', 'amd_comgr_get_metadata_kind',
  817. 'amd_comgr_get_metadata_list_size',
  818. 'amd_comgr_get_metadata_map_size',
  819. 'amd_comgr_get_metadata_string', 'amd_comgr_get_version',
  820. 'amd_comgr_index_list_metadata', 'amd_comgr_iterate_map_metadata',
  821. 'amd_comgr_iterate_symbols', 'amd_comgr_language_s',
  822. 'amd_comgr_language_t', 'amd_comgr_language_t__enumvalues',
  823. 'amd_comgr_lookup_code_object',
  824. 'amd_comgr_map_elf_virtual_address_to_code_object_offset',
  825. 'amd_comgr_map_name_expression_to_symbol_name',
  826. 'amd_comgr_metadata_kind_s', 'amd_comgr_metadata_kind_t',
  827. 'amd_comgr_metadata_kind_t__enumvalues',
  828. 'amd_comgr_metadata_lookup', 'amd_comgr_metadata_node_t',
  829. 'amd_comgr_populate_mangled_names',
  830. 'amd_comgr_populate_name_expression_map',
  831. 'amd_comgr_release_data', 'amd_comgr_set_data',
  832. 'amd_comgr_set_data_from_file_slice', 'amd_comgr_set_data_name',
  833. 'amd_comgr_status_s', 'amd_comgr_status_string',
  834. 'amd_comgr_status_t', 'amd_comgr_status_t__enumvalues',
  835. 'amd_comgr_symbol_get_info', 'amd_comgr_symbol_info_s',
  836. 'amd_comgr_symbol_info_t', 'amd_comgr_symbol_info_t__enumvalues',
  837. 'amd_comgr_symbol_lookup', 'amd_comgr_symbol_t',
  838. 'amd_comgr_symbol_type_s', 'amd_comgr_symbol_type_t',
  839. 'amd_comgr_symbol_type_t__enumvalues', 'amd_comgr_symbolize',
  840. 'amd_comgr_symbolizer_info_t', 'size_t',
  841. 'struct_amd_comgr_action_info_s', 'struct_amd_comgr_data_s',
  842. 'struct_amd_comgr_data_set_s',
  843. 'struct_amd_comgr_disassembly_info_s',
  844. 'struct_amd_comgr_metadata_node_s', 'struct_amd_comgr_symbol_s',
  845. 'struct_amd_comgr_symbolizer_info_s', 'struct_code_object_info_s',
  846. 'uint64_t']