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

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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_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. /**
  44. * @ingroup dvrt_dev
  45. * @brief get total device number.
  46. * @param [in|out] count the device number
  47. * @return RT_ERROR_NONE for ok
  48. * @return RT_ERROR_NO_DEVICE for can not find any device
  49. */
  50. RTS_API rtError_t rtGetDeviceCount(int32_t *count);
  51. /**
  52. * @ingroup dvrt_dev
  53. * @brief get device ids
  54. * @param [in|out] get details of device ids
  55. * @return RT_ERROR_NONE for ok
  56. * @return RT_ERROR_DRV_ERR for error
  57. */
  58. RTS_API rtError_t rtGetDeviceIDs(uint32_t *devices, uint32_t len);
  59. /**
  60. * @ingroup dvrt_dev
  61. * @brief get total device infomation.
  62. * @param [in] device the device id
  63. * @param [out] info the device info
  64. * @return RT_ERROR_NONE for ok
  65. * @return RT_ERROR_NO_DEVICE for can not find any device
  66. */
  67. RTS_API rtError_t rtGetDeviceInfo(int32_t device, rtDeviceInfo_t *info);
  68. /**
  69. * @ingroup dvrt_dev
  70. * @brief set target device for current thread
  71. * @param [int] device the device id
  72. * @return RT_ERROR_NONE for ok
  73. * @return RT_ERROR_INVALID_DEVICE for can not match ID and device
  74. */
  75. RTS_API rtError_t rtSetDevice(int32_t device);
  76. /**
  77. * @ingroup dvrt_dev
  78. * @brief set target device for current thread
  79. * @param [int] device the device id
  80. * @return RT_ERROR_NONE for ok
  81. * @return RT_ERROR_INVALID_DEVICE for can not match ID and device
  82. */
  83. RTS_API rtError_t rtSetDeviceEx(int32_t device);
  84. /**
  85. * @ingroup dvrt_dev
  86. * @brief get Index by phyId.
  87. * @param [in] phyId the physical device id
  88. * @param [out] devIndex the logic device id
  89. * @return RT_ERROR_NONE for ok
  90. * @return RT_ERROR_NO_DEVICE for can not find any device
  91. */
  92. RTS_API rtError_t rtGetDeviceIndexByPhyId(uint32_t phyId, uint32_t *devIndex);
  93. /**
  94. * @ingroup dvrt_dev
  95. * @brief get phyId by Index.
  96. * @param [in] devIndex the logic device id
  97. * @param [out] phyId the physical device id
  98. * @return RT_ERROR_NONE for ok
  99. * @return RT_ERROR_NO_DEVICE for can not find any device
  100. */
  101. RTS_API rtError_t rtGetDevicePhyIdByIndex(uint32_t devIndex, uint32_t *phyId);
  102. /**
  103. * @ingroup dvrt_dev
  104. * @brief enable direction:devIdDes---->phyIdSrc.
  105. * @param [in] devIdDes the logical device id
  106. * @param [in] phyIdSrc the physical device id
  107. * @return RT_ERROR_NONE for ok
  108. * @return RT_ERROR_NO_DEVICE for can not find any device
  109. */
  110. RTS_API rtError_t rtEnableP2P(uint32_t devIdDes, uint32_t phyIdSrc);
  111. /**
  112. * @ingroup dvrt_dev
  113. * @brief disable direction:devIdDes---->phyIdSrc.
  114. * @param [in] devIdDes the logical device id
  115. * @param [in] phyIdSrc the physical device id
  116. * @return RT_ERROR_NONE for ok
  117. * @return RT_ERROR_NO_DEVICE for can not find any device
  118. */
  119. RTS_API rtError_t rtDisableP2P(uint32_t devIdDes, uint32_t phyIdSrc);
  120. /**
  121. * @ingroup dvrt_dev
  122. * @brief get target device of current thread
  123. * @param [in|out] device the device id
  124. * @return RT_ERROR_NONE for ok
  125. * @return RT_ERROR_INVALID_VALUE for error input
  126. */
  127. RTS_API rtError_t rtGetDevice(int32_t *device);
  128. /**
  129. * @ingroup dvrt_dev
  130. * @brief reset all opened device
  131. * @return RT_ERROR_NONE for ok
  132. * @return RT_ERROR_INVALID_DEVICE if no device set
  133. */
  134. RTS_API rtError_t rtDeviceReset(int32_t device);
  135. /**
  136. * @ingroup dvrt_dev
  137. * @brief reset opened device
  138. * @return RT_ERROR_NONE for ok
  139. * @return RT_ERROR_INVALID_DEVICE if no device set
  140. */
  141. RTS_API rtError_t rtDeviceResetEx(int32_t device);
  142. /**
  143. * @ingroup dvrt_dev
  144. * @brief get total device infomation.
  145. * @param [in] device the device id
  146. * @param [in] type limit type RT_LIMIT_TYPE_LOW_POWER_TIMEOUT=0
  147. * @param [in] value limit value
  148. * @param [out] info the device info
  149. * @return RT_ERROR_NONE for ok
  150. * @return RT_ERROR_NO_DEVICE for can not find any device
  151. */
  152. RTS_API rtError_t rtDeviceSetLimit(int32_t device, rtLimitType_t type, uint32_t value);
  153. /**
  154. * @ingroup dvrt_dev
  155. * @brief Wait for compute device to finish
  156. * @return RT_ERROR_NONE for ok
  157. * @return RT_ERROR_INVALID_DEVICE if no device set
  158. */
  159. RTS_API rtError_t rtDeviceSynchronize(void);
  160. /**
  161. * @ingroup dvrt_dev
  162. * @brief get priority range of current device
  163. * @param [in|out] leastPriority least priority
  164. * @param [in|out] greatestPriority greatest priority
  165. * @return RT_ERROR_NONE for ok
  166. * @return RT_ERROR_INVALID_VALUE for error input
  167. */
  168. RTS_API rtError_t rtDeviceGetStreamPriorityRange(int32_t *leastPriority, int32_t *greatestPriority);
  169. /**
  170. * @ingroup dvrt_dev
  171. * @brief Set exception handling callback function
  172. * @param [in] callback rtExceptiontype
  173. * @return RT_ERROR_NONE for ok
  174. * @return RT_ERROR_INVALID_VALUE for error input
  175. */
  176. RTS_API rtError_t rtSetExceptCallback(rtErrorCallback callback);
  177. /**
  178. * @ingroup dvrt_dev
  179. * @brief Setting Scheduling Type of Graph
  180. * @param [in] tsId the ts id
  181. * @return RT_ERROR_NONE for ok
  182. * @return RT_ERROR_INVALID_VALUE for error input
  183. */
  184. RTS_API rtError_t rtSetTSDevice(uint32_t tsId);
  185. /**
  186. * @ingroup dvrt_dev
  187. * @brief init aicpu executor
  188. * @param [out] runtime run mode
  189. * @return RT_ERROR_NONE for ok
  190. * @return RT_ERROR_DRV_ERR for can not get run mode
  191. */
  192. RTS_API rtError_t rtGetRunMode(rtRunMode *mode);
  193. /**
  194. * @ingroup dvrt_dev
  195. * @brief set chipType
  196. * @return RT_ERROR_NONE for ok
  197. */
  198. RTS_API rtError_t rtSetSocVersion(const char *version);
  199. /**
  200. * @ingroup dvrt_dev
  201. * @brief get chipType
  202. * @return RT_ERROR_NONE for ok
  203. */
  204. rtError_t rtGetSocVersion(char *version, const uint32_t maxLen);
  205. #ifdef __cplusplus
  206. }
  207. #endif
  208. #endif // __CCE_RUNTIME_DEVICE_H__

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