You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dev.h 13 kB

5 years ago
5 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
3 years ago
3 years ago
3 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
3 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. /*
  2. * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
  3. * Description: dev.h
  4. * Create: 2020-01-01
  5. */
  6. #ifndef CCE_RUNTIME_DEVICE_H
  7. #define CCE_RUNTIME_DEVICE_H
  8. #include "base.h"
  9. #if defined(__cplusplus)
  10. extern "C" {
  11. #endif
  12. #define RT_CAPABILITY_SUPPORT (0x1U)
  13. #define RT_CAPABILITY_NOT_SUPPORT (0x0U)
  14. #define MEMORY_INFO_TS_4G_LIMITED (0x0U) // for compatibility
  15. typedef struct tagRTDeviceInfo {
  16. uint8_t env_type; // 0: FPGA 1: EMU 2: ESL
  17. uint32_t ctrl_cpu_ip;
  18. uint32_t ctrl_cpu_id;
  19. uint32_t ctrl_cpu_core_num;
  20. uint32_t ctrl_cpu_endian_little;
  21. uint32_t ts_cpu_core_num;
  22. uint32_t ai_cpu_core_num;
  23. uint32_t ai_core_num;
  24. uint32_t ai_core_freq;
  25. uint32_t ai_cpu_core_id;
  26. uint32_t ai_core_id;
  27. uint32_t aicpu_occupy_bitmap;
  28. uint32_t hardware_version;
  29. uint32_t ts_num;
  30. } rtDeviceInfo_t;
  31. typedef enum tagRtRunMode {
  32. RT_RUN_MODE_OFFLINE = 0,
  33. RT_RUN_MODE_ONLINE,
  34. RT_RUN_MODE_AICPU_SCHED,
  35. RT_RUN_MODE_RESERVED
  36. } rtRunMode;
  37. typedef enum tagRtAicpuDeployType {
  38. AICPU_DEPLOY_CROSS_OS = 0x0,
  39. AICPU_DEPLOY_CROSS_PROCESS,
  40. AICPU_DEPLOY_CROSS_THREAD,
  41. AICPU_DEPLOY_RESERVED
  42. } rtAicpuDeployType_t;
  43. typedef enum tagRtFeatureType {
  44. FEATURE_TYPE_MEMCPY = 0,
  45. FEATURE_TYPE_MEMORY,
  46. FEATURE_TYPE_RSV
  47. } rtFeatureType_t;
  48. typedef enum tagRtDeviceFeatureType {
  49. FEATURE_TYPE_SCHE,
  50. FEATURE_TYPE_BLOCKING_OPERATOR,
  51. FEATURE_TYPE_FFTS_MODE,
  52. FEATURE_TYPE_END,
  53. } rtDeviceFeatureType_t;
  54. typedef enum tagMemcpyInfo {
  55. MEMCPY_INFO_SUPPORT_ZEROCOPY = 0,
  56. MEMCPY_INFO_RSV
  57. } rtMemcpyInfo_t;
  58. typedef enum tagMemoryInfo {
  59. MEMORY_INFO_TS_LIMITED = 0,
  60. MEMORY_INFO_RSV
  61. } rtMemoryInfo_t;
  62. typedef enum tagRtDeviceModuleType {
  63. RT_MODULE_TYPE_SYSTEM = 0, /**< system info*/
  64. RT_MODULE_TYPE_AICPU, /** < aicpu info*/
  65. RT_MODULE_TYPE_CCPU, /**< ccpu_info*/
  66. RT_MODULE_TYPE_DCPU, /**< dcpu info*/
  67. RT_MODULE_TYPE_AICORE, /**< AI CORE info*/
  68. RT_MODULE_TYPE_TSCPU, /**< tscpu info*/
  69. RT_MODULE_TYPE_PCIE, /**< PCIE info*/
  70. RT_MODULE_TYPE_VECTOR_CORE, /**< VECTOR CORE info*/
  71. } rtDeviceModuleType_t;
  72. // used for rtGetDevMsg callback function
  73. typedef void (*rtGetMsgCallback)(const char_t *msg, uint32_t len);
  74. typedef enum tagGetDevMsgType {
  75. RT_GET_DEV_ERROR_MSG = 0,
  76. RT_GET_DEV_RUNNING_STREAM_SNAPSHOT_MSG,
  77. RT_GET_DEV_MSG_RESERVE
  78. } rtGetDevMsgType_t;
  79. /**
  80. * @ingroup dvrt_dev
  81. * @brief get total device number.
  82. * @param [in|out] cnt the device number
  83. * @return RT_ERROR_NONE for ok
  84. * @return RT_ERROR_INVALID_VALUE for error input
  85. */
  86. RTS_API rtError_t rtGetDeviceCount(int32_t *cnt);
  87. /**
  88. * @ingroup dvrt_dev
  89. * @brief get device ids
  90. * @param [in|out] get details of device ids
  91. * @return RT_ERROR_NONE for ok
  92. * @return RT_ERROR_DRV_ERR for error
  93. */
  94. RTS_API rtError_t rtGetDeviceIDs(uint32_t *devices, uint32_t len);
  95. /**
  96. * @ingroup dvrt_dev
  97. * @brief get device infomation.
  98. * @param [in] device the device id
  99. * @param [in] moduleType module type
  100. typedef enum {
  101. MODULE_TYPE_SYSTEM = 0, system info
  102. MODULE_TYPE_AICPU, aicpu info
  103. MODULE_TYPE_CCPU, ccpu_info
  104. MODULE_TYPE_DCPU, dcpu info
  105. MODULE_TYPE_AICORE, AI CORE info
  106. MODULE_TYPE_TSCPU, tscpu info
  107. MODULE_TYPE_PCIE, PCIE info
  108. } DEV_MODULE_TYPE;
  109. * @param [in] infoType info type
  110. typedef enum {
  111. INFO_TYPE_ENV = 0,
  112. INFO_TYPE_VERSION,
  113. INFO_TYPE_MASTERID,
  114. INFO_TYPE_CORE_NUM,
  115. INFO_TYPE_OS_SCHED,
  116. INFO_TYPE_IN_USED,
  117. INFO_TYPE_ERROR_MAP,
  118. INFO_TYPE_OCCUPY,
  119. INFO_TYPE_ID,
  120. INFO_TYPE_IP,
  121. INFO_TYPE_ENDIAN,
  122. } DEV_INFO_TYPE;
  123. * @param [out] val the device info
  124. * @return RT_ERROR_NONE for ok
  125. * @return RT_ERROR_DRV_ERR for error
  126. */
  127. RTS_API rtError_t rtGetDeviceInfo(uint32_t deviceId, int32_t moduleType, int32_t infoType, int64_t *val);
  128. /**
  129. * @ingroup dvrt_dev
  130. * @brief set target device for current thread
  131. * @param [int] devId the device id
  132. * @return RT_ERROR_NONE for ok
  133. * @return RT_ERROR_INVALID_VALUE for error input
  134. */
  135. RTS_API rtError_t rtSetDevice(int32_t devId);
  136. /**
  137. * @ingroup dvrt_dev
  138. * @brief set target device for current thread
  139. * @param [int] devId the device id
  140. * @param [int] deviceMode the device mode
  141. * @return RT_ERROR_NONE for ok
  142. * @return RT_ERROR_INVALID_VALUE for error input
  143. */
  144. RTS_API rtError_t rtSetDeviceV2(int32_t devId, rtDeviceMode deviceMode);
  145. /**
  146. * @ingroup dvrt_dev
  147. * @brief get deviceMode
  148. * @param [out] deviceMode the device mode
  149. * @return RT_ERROR_NONE for ok
  150. * @return RT_ERROR_INVALID_VALUE for error input
  151. */
  152. RTS_API rtError_t rtGetDeviceMode(rtDeviceMode *deviceMode);
  153. /**
  154. * @ingroup dvrt_dev
  155. * @brief set target die for current thread
  156. * @param [int] die the die id
  157. * @return RT_ERROR_NONE for ok
  158. * @return RT_ERROR_INVALID_VALUE for error input
  159. */
  160. RTS_API rtError_t rtSetDie(int32_t die);
  161. /**
  162. * @ingroup dvrt_dev
  163. * @brief get target die of current thread
  164. * @param [in|out] die the die id
  165. * @return RT_ERROR_NONE for ok
  166. * @return RT_ERROR_INVALID_VALUE for error input
  167. */
  168. RTS_API rtError_t rtGetDie(int32_t *die);
  169. /**
  170. * @ingroup dvrt_dev
  171. * @brief set target device for current thread
  172. * @param [int] devId the device id
  173. * @return RT_ERROR_NONE for ok
  174. * @return RT_ERROR_INVALID_VALUE for error input
  175. */
  176. RTS_API rtError_t rtSetDeviceEx(int32_t devId);
  177. /**
  178. * @ingroup dvrt_dev
  179. * @brief get Index by phyId.
  180. * @param [in] phyId the physical device id
  181. * @param [out] devIndex the logic device id
  182. * @return RT_ERROR_NONE for ok
  183. * @return RT_ERROR_INVALID_VALUE for error input
  184. */
  185. RTS_API rtError_t rtGetDeviceIndexByPhyId(uint32_t phyId, uint32_t *devIndex);
  186. /**
  187. * @ingroup dvrt_dev
  188. * @brief get phyId by Index.
  189. * @param [in] devIndex the logic device id
  190. * @param [out] phyId the physical device id
  191. * @return RT_ERROR_NONE for ok
  192. * @return RT_ERROR_INVALID_VALUE for error input
  193. */
  194. RTS_API rtError_t rtGetDevicePhyIdByIndex(uint32_t devIndex, uint32_t *phyId);
  195. /**
  196. * @ingroup dvrt_dev
  197. * @brief enable direction:devIdDes---->phyIdSrc.
  198. * @param [in] devIdDes the logical device id
  199. * @param [in] phyIdSrc the physical device id
  200. * @return RT_ERROR_NONE for ok
  201. * @return RT_ERROR_INVALID_VALUE for error input
  202. */
  203. RTS_API rtError_t rtEnableP2P(uint32_t devIdDes, uint32_t phyIdSrc, uint32_t flag);
  204. /**
  205. * @ingroup dvrt_dev
  206. * @brief disable direction:devIdDes---->phyIdSrc.
  207. * @param [in] devIdDes the logical device id
  208. * @param [in] phyIdSrc the physical device id
  209. * @return RT_ERROR_NONE for ok
  210. * @return RT_ERROR_INVALID_VALUE for error input
  211. */
  212. RTS_API rtError_t rtDisableP2P(uint32_t devIdDes, uint32_t phyIdSrc);
  213. /**
  214. * @ingroup dvrt_dev
  215. * @brief get cability of P2P omemry copy betwen device and peeredevic.
  216. * @param [in] devId the logical device id
  217. * @param [in] peerDevice the physical device id
  218. * @param [outv] *canAccessPeer 1:enable 0:disable
  219. * @return RT_ERROR_NONE for ok
  220. * @return RT_ERROR_INVALID_VALUE for error input
  221. */
  222. RTS_API rtError_t rtDeviceCanAccessPeer(int32_t *canAccessPeer, uint32_t devId, uint32_t peerDevice);
  223. /**
  224. * @ingroup dvrt_dev
  225. * @brief get status
  226. * @param [in] devIdDes the logical device id
  227. * @param [in] phyIdSrc the physical device id
  228. * @param [in|out] status status value
  229. * @return RT_ERROR_NONE for ok
  230. * @return RT_ERROR_INVALID_VALUE for error input
  231. */
  232. RTS_API rtError_t rtGetP2PStatus(uint32_t devIdDes, uint32_t phyIdSrc, uint32_t *status);
  233. /**
  234. * @ingroup dvrt_dev
  235. * @brief get value of current thread
  236. * @param [in|out] pid value of pid
  237. * @return RT_ERROR_NONE for ok
  238. */
  239. RTS_API rtError_t rtDeviceGetBareTgid(uint32_t *pid);
  240. /**
  241. * @ingroup dvrt_dev
  242. * @brief get target device of current thread
  243. * @param [in|out] devId the device id
  244. * @return RT_ERROR_NONE for ok
  245. * @return RT_ERROR_INVALID_VALUE for error input
  246. */
  247. RTS_API rtError_t rtGetDevice(int32_t *devId);
  248. /**
  249. * @ingroup dvrt_dev
  250. * @brief reset all opened device
  251. * @return RT_ERROR_NONE for ok
  252. * @return RT_ERROR_INVALID_VALUE for error input
  253. */
  254. RTS_API rtError_t rtDeviceReset(int32_t devId);
  255. /**
  256. * @ingroup dvrt_dev
  257. * @brief reset opened device
  258. * @return RT_ERROR_NONE for ok
  259. * @return RT_ERROR_INVALID_VALUE for error input
  260. */
  261. RTS_API rtError_t rtDeviceResetEx(int32_t devId);
  262. /**
  263. * @ingroup dvrt_dev
  264. * @brief get total device infomation.
  265. * @param [in] devId the device id
  266. * @param [in] type limit type RT_LIMIT_TYPE_LOW_POWER_TIMEOUT=0
  267. * @param [in] val limit value
  268. * @param [out] info the device info
  269. * @return RT_ERROR_NONE for ok
  270. * @return RT_ERROR_INVALID_VALUE for error input
  271. */
  272. RTS_API rtError_t rtDeviceSetLimit(int32_t devId, rtLimitType_t type, uint32_t val);
  273. /**
  274. * @ingroup dvrt_dev
  275. * @brief Wait for compute device to finish
  276. * @return RT_ERROR_NONE for ok
  277. * @return RT_ERROR_INVALID_VALUE for error input
  278. */
  279. RTS_API rtError_t rtDeviceSynchronize(void);
  280. /**
  281. * @ingroup dvrt_dev
  282. * @brief get priority range of current device
  283. * @param [in|out] leastPriority least priority
  284. * @param [in|out] greatestPriority greatest priority
  285. * @return RT_ERROR_NONE for ok
  286. * @return RT_ERROR_INVALID_VALUE for error input
  287. */
  288. RTS_API rtError_t rtDeviceGetStreamPriorityRange(int32_t *leastPriority, int32_t *greatestPriority);
  289. /**
  290. * @ingroup dvrt_dev
  291. * @brief Setting Scheduling Type of Graph
  292. * @param [in] tsId the ts id
  293. * @return RT_ERROR_NONE for ok
  294. * @return RT_ERROR_INVALID_VALUE for error input
  295. */
  296. RTS_API rtError_t rtSetTSDevice(uint32_t tsId);
  297. /**
  298. * @ingroup dvrt_dev
  299. * @brief init aicpu executor
  300. * @param [out] runtime run mode
  301. * @return RT_ERROR_NONE for ok
  302. * @return RT_ERROR_DRV_ERR for can not get run mode
  303. */
  304. RTS_API rtError_t rtGetRunMode(rtRunMode *runMode);
  305. /**
  306. * @ingroup dvrt_dev
  307. * @brief get aicpu deploy
  308. * @param [out] aicpu deploy
  309. * @return RT_ERROR_NONE for ok
  310. * @return RT_ERROR_DRV_ERR for can not get aicpu deploy
  311. */
  312. RTS_API rtError_t rtGetAicpuDeploy(rtAicpuDeployType_t *deployType);
  313. /**
  314. * @ingroup dvrt_dev
  315. * @brief set chipType
  316. * @return RT_ERROR_NONE for ok
  317. */
  318. RTS_API rtError_t rtSetSocVersion(const char_t *ver);
  319. /**
  320. * @ingroup dvrt_dev
  321. * @brief get chipType
  322. * @return RT_ERROR_NONE for ok
  323. */
  324. RTS_API rtError_t rtGetSocVersion(char_t *ver, const uint32_t maxLen);
  325. /**
  326. * @ingroup dvrt_dev
  327. * @brief get status
  328. * @param [in] devId the logical device id
  329. * @param [in] otherDevId the other logical device id
  330. * @param [in] infoType info type
  331. * @param [in|out] val pair info
  332. * @return RT_ERROR_NONE for ok
  333. */
  334. RTS_API rtError_t rtGetPairDevicesInfo(uint32_t devId, uint32_t otherDevId, int32_t infoType, int64_t *val);
  335. /**
  336. * @ingroup dvrt_dev
  337. * @brief get capability infomation.
  338. * @param [in] featureType feature type
  339. typedef enum tagRtFeatureType {
  340. FEATURE_TYPE_MEMCPY = 0,
  341. FEATURE_TYPE_RSV,
  342. } rtFeatureType_t;
  343. * @param [in] featureInfo info type
  344. typedef enum tagMemcpyInfo {
  345. MEMCPY_INFO_SUPPORT_ZEROCOPY = 0,
  346. MEMCPY_INFO _RSV,
  347. } rtMemcpyInfo_t;
  348. * @param [out] val the capability info RT_CAPABILITY_SUPPORT or RT_CAPABILITY_NOT_SUPPORT
  349. * @return RT_ERROR_NONE for ok
  350. */
  351. RTS_API rtError_t rtGetRtCapability(rtFeatureType_t featureType, int32_t featureInfo, int64_t *val);
  352. /**
  353. * @ingroup dvrt_dev
  354. * @brief set target device for current thread
  355. * @param [int] devId the device id
  356. * @return RT_ERROR_NONE for ok
  357. * @return RT_ERROR_INVALID_VALUE for error input
  358. */
  359. RTS_API rtError_t rtSetDeviceWithoutTsd(int32_t devId);
  360. /**
  361. * @ingroup dvrt_dev
  362. * @brief reset all opened device
  363. * @return RT_ERROR_NONE for ok
  364. * @return RT_ERROR_INVALID_VALUE for error input
  365. */
  366. RTS_API rtError_t rtDeviceResetWithoutTsd(int32_t devId);
  367. /**
  368. * @ingroup dvrt_dev
  369. * @brief get device message
  370. * @param [in] rtGetDevMsgType_t getMsgType:msg type
  371. * @param [in] GetMsgCallback callback:acl callback function
  372. * @return RT_ERROR_NONE for ok
  373. * @return RT_ERROR_INVALID_VALUE for error input
  374. */
  375. RTS_API rtError_t rtGetDevMsg(rtGetDevMsgType_t getMsgType, rtGetMsgCallback callback);
  376. #if defined(__cplusplus)
  377. }
  378. #endif
  379. #endif // CCE_RUNTIME_DEVICE_H

图引擎模块(GE)是MindSpore的一个子模块,其代码由C++实现,位于前端模块ME和底层硬件之间,起到承接作用。图引擎模块以ME下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示