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

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