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.4 kB

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

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