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

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