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 9.1 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /**
  2. * Copyright 2019-2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef __CCE_RUNTIME_DEVICE_H__
  17. #define __CCE_RUNTIME_DEVICE_H__
  18. #include "base.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. typedef struct tagRTDeviceInfo {
  23. uint8_t env_type; // 0: FPGA 1: EMU 2: ESL
  24. uint32_t ctrl_cpu_ip;
  25. uint32_t ctrl_cpu_id;
  26. uint32_t ctrl_cpu_core_num;
  27. uint32_t ctrl_cpu_endian_little;
  28. uint32_t ts_cpu_core_num;
  29. uint32_t ai_cpu_core_num;
  30. uint32_t ai_core_num;
  31. uint32_t ai_core_freq;
  32. uint32_t ai_cpu_core_id;
  33. uint32_t ai_core_id;
  34. uint32_t aicpu_occupy_bitmap;
  35. uint32_t hardware_version;
  36. uint32_t ts_num;
  37. } rtDeviceInfo_t;
  38. typedef enum tagRtRunMode {
  39. RT_RUN_MODE_OFFLINE = 0,
  40. RT_RUN_MODE_ONLINE = 1,
  41. RT_RUN_MODE_AICPU_SCHED = 2,
  42. RT_RUN_MODE_RESERVED
  43. } rtRunMode;
  44. typedef enum tagRtAicpuDeployType {
  45. AICPU_DEPLOY_CROSS_OS = 0x0,
  46. AICPU_DEPLOY_CROSS_PROCESS = 0x1,
  47. AICPU_DEPLOY_CROSS_THREAD = 0x2,
  48. AICPU_DEPLOY_RESERVED
  49. } rtAicpuDeployType_t;
  50. /**
  51. * @ingroup dvrt_dev
  52. * @brief get total device number.
  53. * @param [in|out] count the device number
  54. * @return RT_ERROR_NONE for ok
  55. * @return RT_ERROR_NO_DEVICE for can not find any device
  56. */
  57. RTS_API rtError_t rtGetDeviceCount(int32_t *count);
  58. /**
  59. * @ingroup dvrt_dev
  60. * @brief get device ids
  61. * @param [in|out] get details of device ids
  62. * @return RT_ERROR_NONE for ok
  63. * @return RT_ERROR_DRV_ERR for error
  64. */
  65. RTS_API rtError_t rtGetDeviceIDs(uint32_t *devices, uint32_t len);
  66. /**
  67. * @ingroup dvrt_dev
  68. * @brief get device infomation.
  69. * @param [in] device the device id
  70. * @param [in] moduleType module type
  71. typedef enum {
  72. MODULE_TYPE_SYSTEM = 0, system info
  73. MODULE_TYPE_AICPU, aicpu info
  74. MODULE_TYPE_CCPU, ccpu_info
  75. MODULE_TYPE_DCPU, dcpu info
  76. MODULE_TYPE_AICORE, AI CORE info
  77. MODULE_TYPE_TSCPU, tscpu info
  78. MODULE_TYPE_PCIE, PCIE info
  79. } DEV_MODULE_TYPE;
  80. * @param [in] infoType info type
  81. typedef enum {
  82. INFO_TYPE_ENV = 0,
  83. INFO_TYPE_VERSION,
  84. INFO_TYPE_MASTERID,
  85. INFO_TYPE_CORE_NUM,
  86. INFO_TYPE_OS_SCHED,
  87. INFO_TYPE_IN_USED,
  88. INFO_TYPE_ERROR_MAP,
  89. INFO_TYPE_OCCUPY,
  90. INFO_TYPE_ID,
  91. INFO_TYPE_IP,
  92. INFO_TYPE_ENDIAN,
  93. } DEV_INFO_TYPE;
  94. * @param [out] value the device info
  95. * @return RT_ERROR_NONE for ok
  96. * @return RT_ERROR_NO_DEVICE for can not find any device
  97. */
  98. RTS_API rtError_t rtGetDeviceInfo(uint32_t deviceId, int32_t moduleType, int32_t infoType, int64_t *value);
  99. /**
  100. * @ingroup dvrt_dev
  101. * @brief set target device for current thread
  102. * @param [int] device the device id
  103. * @return RT_ERROR_NONE for ok
  104. * @return RT_ERROR_INVALID_DEVICE for can not match ID and device
  105. */
  106. RTS_API rtError_t rtSetDevice(int32_t device);
  107. /**
  108. * @ingroup dvrt_dev
  109. * @brief set target device for current thread
  110. * @param [int] device the device id
  111. * @return RT_ERROR_NONE for ok
  112. * @return RT_ERROR_INVALID_DEVICE for can not match ID and device
  113. */
  114. RTS_API rtError_t rtSetDeviceEx(int32_t device);
  115. /**
  116. * @ingroup dvrt_dev
  117. * @brief get Index by phyId.
  118. * @param [in] phyId the physical device id
  119. * @param [out] devIndex the logic device id
  120. * @return RT_ERROR_NONE for ok
  121. * @return RT_ERROR_NO_DEVICE for can not find any device
  122. */
  123. RTS_API rtError_t rtGetDeviceIndexByPhyId(uint32_t phyId, uint32_t *devIndex);
  124. /**
  125. * @ingroup dvrt_dev
  126. * @brief get phyId by Index.
  127. * @param [in] devIndex the logic device id
  128. * @param [out] phyId the physical device id
  129. * @return RT_ERROR_NONE for ok
  130. * @return RT_ERROR_NO_DEVICE for can not find any device
  131. */
  132. RTS_API rtError_t rtGetDevicePhyIdByIndex(uint32_t devIndex, uint32_t *phyId);
  133. /**
  134. * @ingroup dvrt_dev
  135. * @brief enable direction:devIdDes---->phyIdSrc.
  136. * @param [in] devIdDes the logical device id
  137. * @param [in] phyIdSrc the physical device id
  138. * @return RT_ERROR_NONE for ok
  139. * @return RT_ERROR_NO_DEVICE for can not find any device
  140. */
  141. RTS_API rtError_t rtEnableP2P(uint32_t devIdDes, uint32_t phyIdSrc);
  142. /**
  143. * @ingroup dvrt_dev
  144. * @brief disable direction:devIdDes---->phyIdSrc.
  145. * @param [in] devIdDes the logical device id
  146. * @param [in] phyIdSrc the physical device id
  147. * @return RT_ERROR_NONE for ok
  148. * @return RT_ERROR_NO_DEVICE for can not find any device
  149. */
  150. RTS_API rtError_t rtDisableP2P(uint32_t devIdDes, uint32_t phyIdSrc);
  151. /**
  152. * @ingroup dvrt_dev
  153. * @brief get status
  154. * @param [in] devIdDes the logical device id
  155. * @param [in] phyIdSrc the physical device id
  156. * @param [in|out] status status value
  157. * @return RT_ERROR_NONE for ok
  158. * @return RT_ERROR_NO_DEVICE for can not find any device
  159. */
  160. RTS_API rtError_t rtGetP2PStatus(uint32_t devIdDes, uint32_t phyIdSrc, uint32_t *status);
  161. /**
  162. * @ingroup dvrt_dev
  163. * @brief get value of current thread
  164. * @param [in|out] pid value of pid
  165. * @return RT_ERROR_NONE for ok
  166. */
  167. RTS_API rtError_t rtDeviceGetBareTgid(uint32_t *pid);
  168. /**
  169. * @ingroup dvrt_dev
  170. * @brief get target device of current thread
  171. * @param [in|out] device the device id
  172. * @return RT_ERROR_NONE for ok
  173. * @return RT_ERROR_INVALID_VALUE for error input
  174. */
  175. RTS_API rtError_t rtGetDevice(int32_t *device);
  176. /**
  177. * @ingroup dvrt_dev
  178. * @brief reset all opened device
  179. * @return RT_ERROR_NONE for ok
  180. * @return RT_ERROR_INVALID_DEVICE if no device set
  181. */
  182. RTS_API rtError_t rtDeviceReset(int32_t device);
  183. /**
  184. * @ingroup dvrt_dev
  185. * @brief reset opened device
  186. * @return RT_ERROR_NONE for ok
  187. * @return RT_ERROR_INVALID_DEVICE if no device set
  188. */
  189. RTS_API rtError_t rtDeviceResetEx(int32_t device);
  190. /**
  191. * @ingroup dvrt_dev
  192. * @brief get total device infomation.
  193. * @param [in] device the device id
  194. * @param [in] type limit type RT_LIMIT_TYPE_LOW_POWER_TIMEOUT=0
  195. * @param [in] value limit value
  196. * @param [out] info the device info
  197. * @return RT_ERROR_NONE for ok
  198. * @return RT_ERROR_NO_DEVICE for can not find any device
  199. */
  200. RTS_API rtError_t rtDeviceSetLimit(int32_t device, rtLimitType_t type, uint32_t value);
  201. /**
  202. * @ingroup dvrt_dev
  203. * @brief Wait for compute device to finish
  204. * @return RT_ERROR_NONE for ok
  205. * @return RT_ERROR_INVALID_DEVICE if no device set
  206. */
  207. RTS_API rtError_t rtDeviceSynchronize(void);
  208. /**
  209. * @ingroup dvrt_dev
  210. * @brief get priority range of current device
  211. * @param [in|out] leastPriority least priority
  212. * @param [in|out] greatestPriority greatest priority
  213. * @return RT_ERROR_NONE for ok
  214. * @return RT_ERROR_INVALID_VALUE for error input
  215. */
  216. RTS_API rtError_t rtDeviceGetStreamPriorityRange(int32_t *leastPriority, int32_t *greatestPriority);
  217. /**
  218. * @ingroup dvrt_dev
  219. * @brief Set exception handling callback function
  220. * @param [in] callback rtExceptiontype
  221. * @return RT_ERROR_NONE for ok
  222. * @return RT_ERROR_INVALID_VALUE for error input
  223. */
  224. RTS_API rtError_t rtSetExceptCallback(rtErrorCallback callback);
  225. /**
  226. * @ingroup dvrt_dev
  227. * @brief Setting Scheduling Type of Graph
  228. * @param [in] tsId the ts id
  229. * @return RT_ERROR_NONE for ok
  230. * @return RT_ERROR_INVALID_VALUE for error input
  231. */
  232. RTS_API rtError_t rtSetTSDevice(uint32_t tsId);
  233. /**
  234. * @ingroup dvrt_dev
  235. * @brief init aicpu executor
  236. * @param [out] runtime run mode
  237. * @return RT_ERROR_NONE for ok
  238. * @return RT_ERROR_DRV_ERR for can not get run mode
  239. */
  240. RTS_API rtError_t rtGetRunMode(rtRunMode *mode);
  241. /**
  242. * @ingroup dvrt_dev
  243. * @brief get aicpu deploy
  244. * @param [out] aicpu deploy
  245. * @return RT_ERROR_NONE for ok
  246. * @return RT_ERROR_DRV_ERR for can not get aicpu deploy
  247. */
  248. RTS_API rtError_t rtGetAicpuDeploy(rtAicpuDeployType_t *deplyType);
  249. /**
  250. * @ingroup dvrt_dev
  251. * @brief set chipType
  252. * @return RT_ERROR_NONE for ok
  253. */
  254. RTS_API rtError_t rtSetSocVersion(const char *version);
  255. /**
  256. * @ingroup dvrt_dev
  257. * @brief get chipType
  258. * @return RT_ERROR_NONE for ok
  259. */
  260. rtError_t rtGetSocVersion(char *version, const uint32_t maxLen);
  261. /**
  262. * @ingroup dvrt_dev
  263. * @brief get status
  264. * @param [in] devId the logical device id
  265. * @param [in] otherDevId the other logical device id
  266. * @param [in] infoType info type
  267. * @param [in|out] value pair info
  268. * @return RT_ERROR_NONE for ok
  269. */
  270. RTS_API rtError_t rtGetPairDevicesInfo(uint32_t devId, uint32_t otherDevId, int32_t infoType, int64_t *value);
  271. #ifdef __cplusplus
  272. }
  273. #endif
  274. #endif // __CCE_RUNTIME_DEVICE_H__

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