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

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