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 12 kB

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
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
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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) && !defined(COMPILE_OMG_PACKAGE)
  17. extern "C" {
  18. #endif
  19. #define RT_CAPABILITY_SUPPORT (0x1)
  20. #define RT_CAPABILITY_NOT_SUPPORT (0x0)
  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 = 1,
  40. RT_RUN_MODE_AICPU_SCHED = 2,
  41. RT_RUN_MODE_RESERVED
  42. } rtRunMode;
  43. typedef enum tagRtAicpuDeployType {
  44. AICPU_DEPLOY_CROSS_OS = 0x0,
  45. AICPU_DEPLOY_CROSS_PROCESS = 0x1,
  46. AICPU_DEPLOY_CROSS_THREAD = 0x2,
  47. AICPU_DEPLOY_RESERVED
  48. } rtAicpuDeployType_t;
  49. typedef enum tagRtFeatureType {
  50. FEATURE_TYPE_MEMCPY = 0,
  51. FEATURE_TYPE_MEMORY = 1,
  52. FEATURE_TYPE_RSV
  53. } rtFeatureType_t;
  54. typedef enum tagRtDeviceFeatureType {
  55. FEATURE_TYPE_SCHE,
  56. FEATURE_TYPE_BLOCKING_OPERATOR,
  57. FEATURE_TYPE_END,
  58. } rtDeviceFeatureType_t;
  59. typedef enum tagMemcpyInfo {
  60. MEMCPY_INFO_SUPPORT_ZEROCOPY = 0,
  61. MEMCPY_INFO_RSV
  62. } rtMemcpyInfo_t;
  63. typedef enum tagMemoryInfo {
  64. MEMORY_INFO_TS_4G_LIMITED = 0,
  65. MEMORY_INFO_RSV
  66. } rtMemoryInfo_t;
  67. typedef enum tagRtDeviceModuleType {
  68. RT_MODULE_TYPE_SYSTEM = 0,
  69. RT_MODULE_TYPE_AICPU,
  70. RT_MODULE_TYPE_CCPU,
  71. RT_MODULE_TYPE_DCPU,
  72. RT_MODULE_TYPE_AICORE,
  73. RT_MODULE_TYPE_TSCPU,
  74. RT_MODULE_TYPE_PCIE,
  75. RT_MODULE_TYPE_VECTOR_CORE
  76. } tagRtDeviceModuleType_t;
  77. /**
  78. * @ingroup dvrt_dev
  79. * @brief get total device number.
  80. * @param [in|out] count the device number
  81. * @return RT_ERROR_NONE for ok
  82. * @return RT_ERROR_INVALID_VALUE for error input
  83. */
  84. RTS_API rtError_t rtGetDeviceCount(int32_t *count);
  85. /**
  86. * @ingroup dvrt_dev
  87. * @brief get device ids
  88. * @param [in|out] get details of device ids
  89. * @return RT_ERROR_NONE for ok
  90. * @return RT_ERROR_DRV_ERR for error
  91. */
  92. RTS_API rtError_t rtGetDeviceIDs(uint32_t *devices, uint32_t len);
  93. /**
  94. * @ingroup dvrt_dev
  95. * @brief get device infomation.
  96. * @param [in] device the device id
  97. * @param [in] moduleType module type
  98. typedef enum {
  99. MODULE_TYPE_SYSTEM = 0, system info
  100. MODULE_TYPE_AICPU, aicpu info
  101. MODULE_TYPE_CCPU, ccpu_info
  102. MODULE_TYPE_DCPU, dcpu info
  103. MODULE_TYPE_AICORE, AI CORE info
  104. MODULE_TYPE_TSCPU, tscpu info
  105. MODULE_TYPE_PCIE, PCIE info
  106. } DEV_MODULE_TYPE;
  107. * @param [in] infoType info type
  108. typedef enum {
  109. INFO_TYPE_ENV = 0,
  110. INFO_TYPE_VERSION,
  111. INFO_TYPE_MASTERID,
  112. INFO_TYPE_CORE_NUM,
  113. INFO_TYPE_OS_SCHED,
  114. INFO_TYPE_IN_USED,
  115. INFO_TYPE_ERROR_MAP,
  116. INFO_TYPE_OCCUPY,
  117. INFO_TYPE_ID,
  118. INFO_TYPE_IP,
  119. INFO_TYPE_ENDIAN,
  120. } DEV_INFO_TYPE;
  121. * @param [out] value the device info
  122. * @return RT_ERROR_NONE for ok
  123. * @return RT_ERROR_DRV_ERR for error
  124. */
  125. RTS_API rtError_t rtGetDeviceInfo(uint32_t deviceId, int32_t moduleType, int32_t infoType, int64_t *value);
  126. /**
  127. * @ingroup dvrt_dev
  128. * @brief set target device for current thread
  129. * @param [int] device the device id
  130. * @return RT_ERROR_NONE for ok
  131. * @return RT_ERROR_INVALID_VALUE for error input
  132. */
  133. RTS_API rtError_t rtSetDevice(int32_t device);
  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 rtSetDeviceEx(int32_t device);
  142. /**
  143. * @ingroup dvrt_dev
  144. * @brief get Index by phyId.
  145. * @param [in] phyId the physical device id
  146. * @param [out] devIndex the logic device id
  147. * @return RT_ERROR_NONE for ok
  148. * @return RT_ERROR_INVALID_VALUE for error input
  149. */
  150. RTS_API rtError_t rtGetDeviceIndexByPhyId(uint32_t phyId, uint32_t *devIndex);
  151. /**
  152. * @ingroup dvrt_dev
  153. * @brief get phyId by Index.
  154. * @param [in] devIndex the logic device id
  155. * @param [out] phyId the physical device id
  156. * @return RT_ERROR_NONE for ok
  157. * @return RT_ERROR_INVALID_VALUE for error input
  158. */
  159. RTS_API rtError_t rtGetDevicePhyIdByIndex(uint32_t devIndex, uint32_t *phyId);
  160. /**
  161. * @ingroup dvrt_dev
  162. * @brief enable direction:devIdDes---->phyIdSrc.
  163. * @param [in] devIdDes the logical device id
  164. * @param [in] phyIdSrc the physical device id
  165. * @return RT_ERROR_NONE for ok
  166. * @return RT_ERROR_INVALID_VALUE for error input
  167. */
  168. RTS_API rtError_t rtEnableP2P(uint32_t devIdDes, uint32_t phyIdSrc, uint32_t flag);
  169. /**
  170. * @ingroup dvrt_dev
  171. * @brief disable direction:devIdDes---->phyIdSrc.
  172. * @param [in] devIdDes the logical device id
  173. * @param [in] phyIdSrc the physical device id
  174. * @return RT_ERROR_NONE for ok
  175. * @return RT_ERROR_INVALID_VALUE for error input
  176. */
  177. RTS_API rtError_t rtDisableP2P(uint32_t devIdDes, uint32_t phyIdSrc);
  178. /**
  179. * @ingroup dvrt_dev
  180. * @brief get cability of P2P omemry copy betwen device and peeredevic.
  181. * @param [in] device the logical device id
  182. * @param [in] peerDevice the physical device id
  183. * @param [outv] *canAccessPeer 1:enable 0:disable
  184. * @return RT_ERROR_NONE for ok
  185. * @return RT_ERROR_INVALID_VALUE for error input
  186. */
  187. RTS_API rtError_t rtDeviceCanAccessPeer(int32_t *canAccessPeer, uint32_t device, uint32_t peerDevice);
  188. /**
  189. * @ingroup dvrt_dev
  190. * @brief get status
  191. * @param [in] devIdDes the logical device id
  192. * @param [in] phyIdSrc the physical device id
  193. * @param [in|out] status status value
  194. * @return RT_ERROR_NONE for ok
  195. * @return RT_ERROR_INVALID_VALUE for error input
  196. */
  197. RTS_API rtError_t rtGetP2PStatus(uint32_t devIdDes, uint32_t phyIdSrc, uint32_t *status);
  198. /**
  199. * @ingroup dvrt_dev
  200. * @brief get value of current thread
  201. * @param [in|out] pid value of pid
  202. * @return RT_ERROR_NONE for ok
  203. */
  204. RTS_API rtError_t rtDeviceGetBareTgid(uint32_t *pid);
  205. /**
  206. * @ingroup dvrt_dev
  207. * @brief get target device of current thread
  208. * @param [in|out] device the device id
  209. * @return RT_ERROR_NONE for ok
  210. * @return RT_ERROR_INVALID_VALUE for error input
  211. */
  212. RTS_API rtError_t rtGetDevice(int32_t *device);
  213. /**
  214. * @ingroup dvrt_dev
  215. * @brief reset all opened device
  216. * @return RT_ERROR_NONE for ok
  217. * @return RT_ERROR_INVALID_VALUE for error input
  218. */
  219. RTS_API rtError_t rtDeviceReset(int32_t device);
  220. /**
  221. * @ingroup dvrt_dev
  222. * @brief reset opened device
  223. * @return RT_ERROR_NONE for ok
  224. * @return RT_ERROR_INVALID_VALUE for error input
  225. */
  226. RTS_API rtError_t rtDeviceResetEx(int32_t device);
  227. /**
  228. * @ingroup dvrt_dev
  229. * @brief get total device infomation.
  230. * @param [in] device the device id
  231. * @param [in] type limit type RT_LIMIT_TYPE_LOW_POWER_TIMEOUT=0
  232. * @param [in] value limit value
  233. * @param [out] info the device info
  234. * @return RT_ERROR_NONE for ok
  235. * @return RT_ERROR_INVALID_VALUE for error input
  236. */
  237. RTS_API rtError_t rtDeviceSetLimit(int32_t device, rtLimitType_t type, uint32_t value);
  238. /**
  239. * @ingroup dvrt_dev
  240. * @brief Wait for compute device to finish
  241. * @return RT_ERROR_NONE for ok
  242. * @return RT_ERROR_INVALID_VALUE for error input
  243. */
  244. RTS_API rtError_t rtDeviceSynchronize(void);
  245. /**
  246. * @ingroup dvrt_dev
  247. * @brief get priority range of current device
  248. * @param [in|out] leastPriority least priority
  249. * @param [in|out] greatestPriority greatest priority
  250. * @return RT_ERROR_NONE for ok
  251. * @return RT_ERROR_INVALID_VALUE for error input
  252. */
  253. RTS_API rtError_t rtDeviceGetStreamPriorityRange(int32_t *leastPriority, int32_t *greatestPriority);
  254. /**
  255. * @ingroup dvrt_dev
  256. * @brief Set exception handling callback function
  257. * @param [in] callback rtExceptiontype
  258. * @return RT_ERROR_NONE for ok
  259. * @return RT_ERROR_INVALID_VALUE for error input
  260. */
  261. RTS_API rtError_t rtSetExceptCallback(rtErrorCallback callback);
  262. /**
  263. * @ingroup dvrt_dev
  264. * @brief Setting Scheduling Type of Graph
  265. * @param [in] tsId the ts id
  266. * @return RT_ERROR_NONE for ok
  267. * @return RT_ERROR_INVALID_VALUE for error input
  268. */
  269. RTS_API rtError_t rtSetTSDevice(uint32_t tsId);
  270. /**
  271. * @ingroup dvrt_dev
  272. * @brief init aicpu executor
  273. * @param [out] runtime run mode
  274. * @return RT_ERROR_NONE for ok
  275. * @return RT_ERROR_DRV_ERR for can not get run mode
  276. */
  277. RTS_API rtError_t rtGetRunMode(rtRunMode *mode);
  278. /**
  279. * @ingroup dvrt_dev
  280. * @brief get aicpu deploy
  281. * @param [out] aicpu deploy
  282. * @return RT_ERROR_NONE for ok
  283. * @return RT_ERROR_DRV_ERR for can not get aicpu deploy
  284. */
  285. RTS_API rtError_t rtGetAicpuDeploy(rtAicpuDeployType_t *deployType);
  286. /**
  287. * @ingroup dvrt_dev
  288. * @brief set chipType
  289. * @return RT_ERROR_NONE for ok
  290. */
  291. RTS_API rtError_t rtSetSocVersion(const char *version);
  292. /**
  293. * @ingroup dvrt_dev
  294. * @brief get chipType
  295. * @return RT_ERROR_NONE for ok
  296. */
  297. RTS_API rtError_t rtGetSocVersion(char *version, const uint32_t maxLen);
  298. /**
  299. * @ingroup dvrt_dev
  300. * @brief get status
  301. * @param [in] devId the logical device id
  302. * @param [in] otherDevId the other logical device id
  303. * @param [in] infoType info type
  304. * @param [in|out] value pair info
  305. * @return RT_ERROR_NONE for ok
  306. */
  307. RTS_API rtError_t rtGetPairDevicesInfo(uint32_t devId, uint32_t otherDevId, int32_t infoType, int64_t *value);
  308. /**
  309. * @ingroup dvrt_dev
  310. * @brief get capability infomation.
  311. * @param [in] featureType feature type
  312. typedef enum tagRtFeatureType {
  313. FEATURE_TYPE_MEMCPY = 0,
  314. FEATURE_TYPE_RSV,
  315. } rtFeatureType_t;
  316. * @param [in] featureInfo info type
  317. typedef enum tagMemcpyInfo {
  318. MEMCPY_INFO_SUPPORT_ZEROCOPY = 0,
  319. MEMCPY_INFO _RSV,
  320. } rtMemcpyInfo_t;
  321. * @param [out] value the capability info RT_CAPABILITY_SUPPORT or RT_CAPABILITY_NOT_SUPPORT
  322. * @return RT_ERROR_NONE for ok
  323. */
  324. RTS_API rtError_t rtGetRtCapability(rtFeatureType_t featureType, int32_t featureInfo, int64_t *value);
  325. /**
  326. * @ingroup dvrt_dev
  327. * @brief set target device for current thread
  328. * @param [int] device the device id
  329. * @return RT_ERROR_NONE for ok
  330. * @return RT_ERROR_INVALID_VALUE for error input
  331. */
  332. RTS_API rtError_t rtSetDeviceWithoutTsd(int32_t device);
  333. /**
  334. * @ingroup dvrt_dev
  335. * @brief reset all opened device
  336. * @return RT_ERROR_NONE for ok
  337. * @return RT_ERROR_INVALID_VALUE for error input
  338. */
  339. RTS_API rtError_t rtDeviceResetWithoutTsd(int32_t device);
  340. #if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE)
  341. }
  342. #endif
  343. #endif // __CCE_RUNTIME_DEVICE_H__

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