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.

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

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

Contributors (1)