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

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