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 14 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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. typedef enum tagRtMemRequestFeature {
  73. MEM_REQUEST_FEATURE_DEFAULT = 0,
  74. MEM_REQUEST_FEATURE_OPP,
  75. MEM_REQUEST_FEATURE_RESERVED
  76. } rtMemRequestFeature_t;
  77. // used for rtGetDevMsg callback function
  78. typedef void (*rtGetMsgCallback)(const char_t *msg, uint32_t len);
  79. typedef enum tagGetDevMsgType {
  80. RT_GET_DEV_ERROR_MSG = 0,
  81. RT_GET_DEV_RUNNING_STREAM_SNAPSHOT_MSG,
  82. RT_GET_DEV_MSG_RESERVE
  83. } rtGetDevMsgType_t;
  84. /**
  85. * @ingroup dvrt_dev
  86. * @brief get total device number.
  87. * @param [in|out] cnt the device number
  88. * @return RT_ERROR_NONE for ok
  89. * @return RT_ERROR_INVALID_VALUE for error input
  90. */
  91. RTS_API rtError_t rtGetDeviceCount(int32_t *cnt);
  92. /**
  93. * @ingroup dvrt_dev
  94. * @brief get device ids
  95. * @param [in|out] get details of device ids
  96. * @return RT_ERROR_NONE for ok
  97. * @return RT_ERROR_DRV_ERR for error
  98. */
  99. RTS_API rtError_t rtGetDeviceIDs(uint32_t *devices, uint32_t len);
  100. /**
  101. * @ingroup dvrt_dev
  102. * @brief get device infomation.
  103. * @param [in] device the device id
  104. * @param [in] moduleType module type
  105. typedef enum {
  106. MODULE_TYPE_SYSTEM = 0, system info
  107. MODULE_TYPE_AICPU, aicpu info
  108. MODULE_TYPE_CCPU, ccpu_info
  109. MODULE_TYPE_DCPU, dcpu info
  110. MODULE_TYPE_AICORE, AI CORE info
  111. MODULE_TYPE_TSCPU, tscpu info
  112. MODULE_TYPE_PCIE, PCIE info
  113. } DEV_MODULE_TYPE;
  114. * @param [in] infoType info type
  115. typedef enum {
  116. INFO_TYPE_ENV = 0,
  117. INFO_TYPE_VERSION,
  118. INFO_TYPE_MASTERID,
  119. INFO_TYPE_CORE_NUM,
  120. INFO_TYPE_OS_SCHED,
  121. INFO_TYPE_IN_USED,
  122. INFO_TYPE_ERROR_MAP,
  123. INFO_TYPE_OCCUPY,
  124. INFO_TYPE_ID,
  125. INFO_TYPE_IP,
  126. INFO_TYPE_ENDIAN,
  127. } DEV_INFO_TYPE;
  128. * @param [out] val the device info
  129. * @return RT_ERROR_NONE for ok
  130. * @return RT_ERROR_DRV_ERR for error
  131. */
  132. RTS_API rtError_t rtGetDeviceInfo(uint32_t deviceId, int32_t moduleType, int32_t infoType, int64_t *val);
  133. /**
  134. * @ingroup dvrt_dev
  135. * @brief set target device for current thread
  136. * @param [int] devId the device id
  137. * @return RT_ERROR_NONE for ok
  138. * @return RT_ERROR_INVALID_VALUE for error input
  139. */
  140. RTS_API rtError_t rtSetDevice(int32_t devId);
  141. /**
  142. * @ingroup dvrt_dev
  143. * @brief set target device for current thread
  144. * @param [int] devId the device id
  145. * @param [int] deviceMode the device mode
  146. * @return RT_ERROR_NONE for ok
  147. * @return RT_ERROR_INVALID_VALUE for error input
  148. */
  149. RTS_API rtError_t rtSetDeviceV2(int32_t devId, rtDeviceMode deviceMode);
  150. /**
  151. * @ingroup dvrt_dev
  152. * @brief get deviceMode
  153. * @param [out] deviceMode the device mode
  154. * @return RT_ERROR_NONE for ok
  155. * @return RT_ERROR_INVALID_VALUE for error input
  156. */
  157. RTS_API rtError_t rtGetDeviceMode(rtDeviceMode *deviceMode);
  158. /**
  159. * @ingroup dvrt_dev
  160. * @brief set target die for current thread
  161. * @param [int] die the die id
  162. * @return RT_ERROR_NONE for ok
  163. * @return RT_ERROR_INVALID_VALUE for error input
  164. */
  165. RTS_API rtError_t rtSetDie(int32_t die);
  166. /**
  167. * @ingroup dvrt_dev
  168. * @brief get target die of current thread
  169. * @param [in|out] die the die id
  170. * @return RT_ERROR_NONE for ok
  171. * @return RT_ERROR_INVALID_VALUE for error input
  172. */
  173. RTS_API rtError_t rtGetDie(int32_t *die);
  174. /**
  175. * @ingroup dvrt_dev
  176. * @brief set target device for current thread
  177. * @param [int] devId the device id
  178. * @return RT_ERROR_NONE for ok
  179. * @return RT_ERROR_INVALID_VALUE for error input
  180. */
  181. RTS_API rtError_t rtSetDeviceEx(int32_t devId);
  182. /**
  183. * @ingroup dvrt_dev
  184. * @brief get Index by phyId.
  185. * @param [in] phyId the physical device id
  186. * @param [out] devIndex the logic device id
  187. * @return RT_ERROR_NONE for ok
  188. * @return RT_ERROR_INVALID_VALUE for error input
  189. */
  190. RTS_API rtError_t rtGetDeviceIndexByPhyId(uint32_t phyId, uint32_t *devIndex);
  191. /**
  192. * @ingroup dvrt_dev
  193. * @brief get phyId by Index.
  194. * @param [in] devIndex the logic device id
  195. * @param [out] phyId the physical device id
  196. * @return RT_ERROR_NONE for ok
  197. * @return RT_ERROR_INVALID_VALUE for error input
  198. */
  199. RTS_API rtError_t rtGetDevicePhyIdByIndex(uint32_t devIndex, uint32_t *phyId);
  200. /**
  201. * @ingroup dvrt_dev
  202. * @brief enable direction:devIdDes---->phyIdSrc.
  203. * @param [in] devIdDes the logical device id
  204. * @param [in] phyIdSrc the physical device id
  205. * @return RT_ERROR_NONE for ok
  206. * @return RT_ERROR_INVALID_VALUE for error input
  207. */
  208. RTS_API rtError_t rtEnableP2P(uint32_t devIdDes, uint32_t phyIdSrc, uint32_t flag);
  209. /**
  210. * @ingroup dvrt_dev
  211. * @brief disable direction:devIdDes---->phyIdSrc.
  212. * @param [in] devIdDes the logical device id
  213. * @param [in] phyIdSrc the physical device id
  214. * @return RT_ERROR_NONE for ok
  215. * @return RT_ERROR_INVALID_VALUE for error input
  216. */
  217. RTS_API rtError_t rtDisableP2P(uint32_t devIdDes, uint32_t phyIdSrc);
  218. /**
  219. * @ingroup dvrt_dev
  220. * @brief get cability of P2P omemry copy betwen device and peeredevic.
  221. * @param [in] devId the logical device id
  222. * @param [in] peerDevice the physical device id
  223. * @param [outv] *canAccessPeer 1:enable 0:disable
  224. * @return RT_ERROR_NONE for ok
  225. * @return RT_ERROR_INVALID_VALUE for error input
  226. */
  227. RTS_API rtError_t rtDeviceCanAccessPeer(int32_t *canAccessPeer, uint32_t devId, uint32_t peerDevice);
  228. /**
  229. * @ingroup dvrt_dev
  230. * @brief get status
  231. * @param [in] devIdDes the logical device id
  232. * @param [in] phyIdSrc the physical device id
  233. * @param [in|out] status status value
  234. * @return RT_ERROR_NONE for ok
  235. * @return RT_ERROR_INVALID_VALUE for error input
  236. */
  237. RTS_API rtError_t rtGetP2PStatus(uint32_t devIdDes, uint32_t phyIdSrc, uint32_t *status);
  238. /**
  239. * @ingroup dvrt_dev
  240. * @brief get value of current thread
  241. * @param [in|out] pid value of pid
  242. * @return RT_ERROR_NONE for ok
  243. */
  244. RTS_API rtError_t rtDeviceGetBareTgid(uint32_t *pid);
  245. /**
  246. * @ingroup dvrt_dev
  247. * @brief get target device of current thread
  248. * @param [in|out] devId the device id
  249. * @return RT_ERROR_NONE for ok
  250. * @return RT_ERROR_INVALID_VALUE for error input
  251. */
  252. RTS_API rtError_t rtGetDevice(int32_t *devId);
  253. /**
  254. * @ingroup dvrt_dev
  255. * @brief reset all opened device
  256. * @return RT_ERROR_NONE for ok
  257. * @return RT_ERROR_INVALID_VALUE for error input
  258. */
  259. RTS_API rtError_t rtDeviceReset(int32_t devId);
  260. /**
  261. * @ingroup dvrt_dev
  262. * @brief reset opened device
  263. * @return RT_ERROR_NONE for ok
  264. * @return RT_ERROR_INVALID_VALUE for error input
  265. */
  266. RTS_API rtError_t rtDeviceResetEx(int32_t devId);
  267. /**
  268. * @ingroup dvrt_dev
  269. * @brief get total device infomation.
  270. * @param [in] devId the device id
  271. * @param [in] type limit type RT_LIMIT_TYPE_LOW_POWER_TIMEOUT=0
  272. * @param [in] val limit value
  273. * @param [out] info the device info
  274. * @return RT_ERROR_NONE for ok
  275. * @return RT_ERROR_INVALID_VALUE for error input
  276. */
  277. RTS_API rtError_t rtDeviceSetLimit(int32_t devId, rtLimitType_t type, uint32_t val);
  278. /**
  279. * @ingroup dvrt_dev
  280. * @brief Wait for compute device to finish
  281. * @return RT_ERROR_NONE for ok
  282. * @return RT_ERROR_INVALID_VALUE for error input
  283. */
  284. RTS_API rtError_t rtDeviceSynchronize(void);
  285. /**
  286. * @ingroup dvrt_dev
  287. * @brief get priority range of current device
  288. * @param [in|out] leastPriority least priority
  289. * @param [in|out] greatestPriority greatest priority
  290. * @return RT_ERROR_NONE for ok
  291. * @return RT_ERROR_INVALID_VALUE for error input
  292. */
  293. RTS_API rtError_t rtDeviceGetStreamPriorityRange(int32_t *leastPriority, int32_t *greatestPriority);
  294. /**
  295. * @ingroup dvrt_dev
  296. * @brief Setting Scheduling Type of Graph
  297. * @param [in] tsId the ts id
  298. * @return RT_ERROR_NONE for ok
  299. * @return RT_ERROR_INVALID_VALUE for error input
  300. */
  301. RTS_API rtError_t rtSetTSDevice(uint32_t tsId);
  302. /**
  303. * @ingroup dvrt_dev
  304. * @brief init aicpu executor
  305. * @param [out] runtime run mode
  306. * @return RT_ERROR_NONE for ok
  307. * @return RT_ERROR_DRV_ERR for can not get run mode
  308. */
  309. RTS_API rtError_t rtGetRunMode(rtRunMode *runMode);
  310. /**
  311. * @ingroup dvrt_dev
  312. * @brief get aicpu deploy
  313. * @param [out] aicpu deploy
  314. * @return RT_ERROR_NONE for ok
  315. * @return RT_ERROR_DRV_ERR for can not get aicpu deploy
  316. */
  317. RTS_API rtError_t rtGetAicpuDeploy(rtAicpuDeployType_t *deployType);
  318. /**
  319. * @ingroup dvrt_dev
  320. * @brief set chipType
  321. * @return RT_ERROR_NONE for ok
  322. */
  323. RTS_API rtError_t rtSetSocVersion(const char_t *ver);
  324. /**
  325. * @ingroup dvrt_dev
  326. * @brief get chipType
  327. * @return RT_ERROR_NONE for ok
  328. */
  329. RTS_API rtError_t rtGetSocVersion(char_t *ver, const uint32_t maxLen);
  330. /**
  331. * @ingroup dvrt_dev
  332. * @brief get status
  333. * @param [in] devId the logical device id
  334. * @param [in] otherDevId the other logical device id
  335. * @param [in] infoType info type
  336. * @param [in|out] val pair info
  337. * @return RT_ERROR_NONE for ok
  338. */
  339. RTS_API rtError_t rtGetPairDevicesInfo(uint32_t devId, uint32_t otherDevId, int32_t infoType, int64_t *val);
  340. /**
  341. * @ingroup dvrt_dev
  342. * @brief get capability infomation.
  343. * @param [in] featureType feature type
  344. typedef enum tagRtFeatureType {
  345. FEATURE_TYPE_MEMCPY = 0,
  346. FEATURE_TYPE_RSV,
  347. } rtFeatureType_t;
  348. * @param [in] featureInfo info type
  349. typedef enum tagMemcpyInfo {
  350. MEMCPY_INFO_SUPPORT_ZEROCOPY = 0,
  351. MEMCPY_INFO _RSV,
  352. } rtMemcpyInfo_t;
  353. * @param [out] val the capability info RT_CAPABILITY_SUPPORT or RT_CAPABILITY_NOT_SUPPORT
  354. * @return RT_ERROR_NONE for ok
  355. */
  356. RTS_API rtError_t rtGetRtCapability(rtFeatureType_t featureType, int32_t featureInfo, int64_t *val);
  357. /**
  358. * @ingroup dvrt_dev
  359. * @brief set target device for current thread
  360. * @param [int] devId the device id
  361. * @return RT_ERROR_NONE for ok
  362. * @return RT_ERROR_INVALID_VALUE for error input
  363. */
  364. RTS_API rtError_t rtSetDeviceWithoutTsd(int32_t devId);
  365. /**
  366. * @ingroup dvrt_dev
  367. * @brief reset all opened device
  368. * @return RT_ERROR_NONE for ok
  369. * @return RT_ERROR_INVALID_VALUE for error input
  370. */
  371. RTS_API rtError_t rtDeviceResetWithoutTsd(int32_t devId);
  372. /**
  373. * @ingroup dvrt_dev
  374. * @brief get device message
  375. * @param [in] rtGetDevMsgType_t getMsgType:msg type
  376. * @param [in] GetMsgCallback callback:acl callback function
  377. * @return RT_ERROR_NONE for ok
  378. * @return RT_ERROR_INVALID_VALUE for error input
  379. */
  380. RTS_API rtError_t rtGetDevMsg(rtGetDevMsgType_t getMsgType, rtGetMsgCallback callback);
  381. /**
  382. * @ingroup dvrt_dev
  383. * @brief get ts mem type
  384. * @param [in] rtMemRequestFeature_t mem request feature type
  385. * @param [in] mem request size
  386. * @return RT_MEMORY_TS, RT_MEMORY_HBM, RT_MEMORY_TS | RT_MEMORY_POLICY_HUGE_PAGE_ONLY
  387. */
  388. RTS_API uint32_t rtGetTsMemType(rtMemRequestFeature_t featureType, uint32_t memSize);
  389. /**
  390. * @ingroup
  391. * @brief set saturation mode for current device.
  392. * @param [in] saturation mode.
  393. * @return RT_ERROR_NONE for ok
  394. */
  395. RTS_API rtError_t rtSetDeviceSatMode(rtFloatOverflowMode_t floatOverflowMode);
  396. /**
  397. * @ingroup
  398. * @brief get saturation mode for current device.
  399. * @param [out] saturation mode.
  400. * @return RT_ERROR_NONE for ok
  401. */
  402. RTS_API rtError_t rtGetDeviceSatMode(rtFloatOverflowMode_t *floatOverflowMode);
  403. /**
  404. * @ingroup
  405. * @brief get saturation mode for target stream.
  406. * @param [in] target stm
  407. * @param [out] saturation mode.
  408. * @return RT_ERROR_NONE for ok
  409. */
  410. RTS_API rtError_t rtGetDeviceSatModeForStream(rtStream_t stm, rtFloatOverflowMode_t *floatOverflowMode);
  411. #if defined(__cplusplus)
  412. }
  413. #endif
  414. #endif // CCE_RUNTIME_DEVICE_H

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