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.

acl_prof.h 9.4 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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 INC_EXTERNAL_ACL_PROF_H_
  17. #define INC_EXTERNAL_ACL_PROF_H_
  18. #include "acl_base.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. #define ACL_PROF_ACL_API 0x0001
  23. #define ACL_PROF_TASK_TIME 0x0002
  24. #define ACL_PROF_AICORE_METRICS 0x0004
  25. #define ACL_PROF_AICPU 0x0008
  26. #define ACL_PROF_MAX_OP_NAME_LEN 257
  27. #define ACL_PROF_MAX_OP_TYPE_LEN 65
  28. typedef enum {
  29. ACL_AICORE_ARITHMETIC_UTILIZATION = 0,
  30. ACL_AICORE_PIPE_UTILIZATION = 1,
  31. ACL_AICORE_MEMORY_BANDWIDTH = 2,
  32. ACL_AICORE_L0B_AND_WIDTH = 3,
  33. ACL_AICORE_RESOURCE_CONFLICT_RATIO = 4,
  34. ACL_AICORE_NONE = 0xFF
  35. } aclprofAicoreMetrics;
  36. typedef struct aclprofConfig aclprofConfig;
  37. typedef struct aclprofStopConfig aclprofStopConfig;
  38. typedef struct aclprofAicoreEvents aclprofAicoreEvents;
  39. typedef struct aclprofSubscribeConfig aclprofSubscribeConfig;
  40. /**
  41. * @ingroup AscendCL
  42. * @brief profiling initialize
  43. *
  44. * @param profilerResultPath [IN] path of profiling result
  45. * @param length [IN] length of profilerResultPath
  46. *
  47. * @retval ACL_SUCCESS The function is successfully executed.
  48. * @retval OtherValues Failure
  49. *
  50. * @see aclprofFinalize
  51. */
  52. ACL_FUNC_VISIBILITY aclError aclprofInit(const char *profilerResultPath, size_t length);
  53. /**
  54. * @ingroup AscendCL
  55. * @brief profiling finalize
  56. *
  57. * @retval ACL_SUCCESS The function is successfully executed.
  58. * @retval OtherValues Failure
  59. *
  60. * @see aclprofInit
  61. */
  62. ACL_FUNC_VISIBILITY aclError aclprofFinalize();
  63. /**
  64. * @ingroup AscendCL
  65. * @brief Start profiling modules by profilerConfig
  66. *
  67. * @param profilerConfig [IN] config of profiling
  68. *
  69. * @retval ACL_SUCCESS The function is successfully executed.
  70. * @retval OtherValues Failure
  71. *
  72. * @see aclprofStop
  73. */
  74. ACL_FUNC_VISIBILITY aclError aclprofStart(const aclprofConfig *profilerConfig);
  75. /**
  76. * @ingroup AscendCL
  77. * @brief Create data of type aclprofConfig
  78. *
  79. * @param deviceIdList [IN] list of device id
  80. * @param deviceNums [IN] number of devices
  81. * @param aicoreMetrics [IN] type of aicore metrics
  82. * @param aicoreEvents [IN] pointer to aicore events, only support NULL now
  83. * @param dataTypeConfig [IN] config modules need profiling
  84. *
  85. * @retval the aclprofConfig pointer
  86. *
  87. * @see aclprofDestroyConfig
  88. */
  89. ACL_FUNC_VISIBILITY aclprofConfig *aclprofCreateConfig(uint32_t *deviceIdList, uint32_t deviceNums,
  90. aclprofAicoreMetrics aicoreMetrics,
  91. aclprofAicoreEvents *aicoreEvents, uint64_t dataTypeConfig);
  92. /**
  93. * @ingroup AscendCL
  94. * @brief Destroy data of type aclprofConfig
  95. *
  96. * @param profilerConfig [IN] config of profiling
  97. *
  98. * @retval ACL_SUCCESS The function is successfully executed.
  99. * @retval OtherValues Failure
  100. *
  101. * @see aclprofCreateConfig
  102. */
  103. ACL_FUNC_VISIBILITY aclError aclprofDestroyConfig(const aclprofConfig *profilerConfig);
  104. /**
  105. * @ingroup AscendCL
  106. * @brief stop profiling modules by stopProfilingConfig
  107. *
  108. * @param profilerConfig [IN] pointer to stop config of profiling
  109. *
  110. * @retval ACL_SUCCESS The function is successfully executed.
  111. * @retval OtherValues Failure
  112. *
  113. * @see aclprofStart
  114. */
  115. ACL_FUNC_VISIBILITY aclError aclprofStop(const aclprofConfig *profilerConfig);
  116. /**
  117. * @ingroup AscendCL
  118. * @brief subscribe profiling data of model
  119. *
  120. * @param modelId [IN] the model id subscribed
  121. * @param profSubscribeConfig [IN] pointer to config of model subscribe
  122. *
  123. * @retval ACL_SUCCESS The function is successfully executed.
  124. * @retval OtherValues Failure
  125. *
  126. * @see aclprofModelUnSubscribe
  127. */
  128. ACL_FUNC_VISIBILITY aclError aclprofModelSubscribe(uint32_t modelId, const aclprofSubscribeConfig *profSubscribeConfig);
  129. /**
  130. * @ingroup AscendCL
  131. * @brief unsubscribe profiling data of model
  132. *
  133. * @param modelId [IN] the model id unsubscribed
  134. *
  135. * @retval ACL_SUCCESS The function is successfully executed.
  136. * @retval OtherValues Failure
  137. *
  138. * @see aclprofModelSubscribe
  139. */
  140. ACL_FUNC_VISIBILITY aclError aclprofModelUnSubscribe(uint32_t modelId);
  141. /**
  142. * @ingroup AscendCL
  143. * @brief create subscribe config
  144. *
  145. * @param timeInfoSwitch [IN] switch whether get time info from model
  146. * @param aicoreMetrics [IN] aicore metrics
  147. * @param fd [IN] pointer to write pipe
  148. *
  149. * @retval the aclprofSubscribeConfig pointer
  150. *
  151. * @see aclprofDestroySubscribeConfig
  152. */
  153. ACL_FUNC_VISIBILITY aclprofSubscribeConfig *aclprofCreateSubscribeConfig(int8_t timeInfoSwitch,
  154. aclprofAicoreMetrics aicoreMetrics, void *fd);
  155. /**
  156. * @ingroup AscendCL
  157. * @brief destroy subscribe config
  158. *
  159. * @param profSubscribeConfig [IN] subscribe config
  160. *
  161. * @retval ACL_SUCCESS The function is successfully executed.
  162. * @retval OtherValues Failure
  163. *
  164. * @see aclprofCreateSubscribeConfig
  165. */
  166. ACL_FUNC_VISIBILITY aclError aclprofDestroySubscribeConfig(const aclprofSubscribeConfig *profSubscribeConfig);
  167. /**
  168. * @ingroup AscendCL
  169. * @brief create subscribe config
  170. *
  171. * @param opDescSize [OUT] size of op desc
  172. *
  173. * @retval ACL_SUCCESS The function is successfully executed.
  174. * @retval OtherValues Failure
  175. */
  176. ACL_FUNC_VISIBILITY aclError aclprofGetOpDescSize(size_t *opDescSize);
  177. /**
  178. * @ingroup AscendCL
  179. * @brief get op number from subscription data
  180. *
  181. * @param opInfo [IN] pointer to subscription data
  182. * @param opInfoLen [IN] memory size of subscription data
  183. * @param opNumber [OUT] op number of subscription data
  184. *
  185. * @retval ACL_SUCCESS The function is successfully executed.
  186. * @retval OtherValues Failure
  187. */
  188. ACL_FUNC_VISIBILITY aclError aclprofGetOpNum(const void *opInfo, size_t opInfoLen, uint32_t *opNumber);
  189. /**
  190. * @ingroup AscendCL
  191. * @brief get op type from subscription data
  192. *
  193. * @param opInfo [IN] pointer to subscription data
  194. * @param opInfoLen [IN] memory size of subscription data
  195. * @param index [IN] index of op array in opInfo
  196. * @param opType [OUT] obtained op type string
  197. * @param opTypeLen [IN] obtained length of op type string
  198. *
  199. * @retval ACL_SUCCESS The function is successfully executed.
  200. * @retval OtherValues Failure
  201. */
  202. ACL_FUNC_VISIBILITY aclError aclprofGetOpType(const void *opInfo, size_t opInfoLen, uint32_t index, char *opType,
  203. size_t opTypeLen);
  204. /**
  205. * @ingroup AscendCL
  206. * @brief get op type from subscription data
  207. *
  208. * @param opInfo [IN] pointer to subscription data
  209. * @param opInfoLen [IN] memory size of subscription data
  210. * @param index [IN] index of op array in opInfo
  211. * @param opName [OUT] obtained op name string
  212. * @param opNameLen [IN] obtained length of op name string
  213. *
  214. * @retval ACL_SUCCESS The function is successfully executed.
  215. * @retval OtherValues Failure
  216. */
  217. ACL_FUNC_VISIBILITY aclError aclprofGetOpName(const void *opInfo, size_t opInfoLen, uint32_t index, char *opName,
  218. size_t opNameLen);
  219. /**
  220. * @ingroup AscendCL
  221. * @brief get start time of specified op from subscription data
  222. *
  223. * @param opInfo [IN] pointer to subscription data
  224. * @param opInfoLen [IN] memory size of subscription data
  225. * @param index [IN] index of op array in opInfo
  226. *
  227. * @retval start time(us) of specified op with timestamp
  228. * @retval 0 for failed
  229. */
  230. ACL_FUNC_VISIBILITY uint64_t aclprofGetOpStart(const void *opInfo, size_t opInfoLen, uint32_t index);
  231. /**
  232. * @ingroup AscendCL
  233. * @brief get end time of specified op from subscription data
  234. *
  235. * @param opInfo [IN] pointer to subscription data
  236. * @param opInfoLen [IN] memory size of subscription data
  237. * @param index [IN] index of op array in opInfo
  238. *
  239. * @retval end time(us) of specified op with timestamp
  240. * @retval 0 for failed
  241. */
  242. ACL_FUNC_VISIBILITY uint64_t aclprofGetOpEnd(const void *opInfo, size_t opInfoLen, uint32_t index);
  243. /**
  244. * @ingroup AscendCL
  245. * @brief get excution time of specified op from subscription data
  246. *
  247. * @param opInfo [IN] pointer to subscription data
  248. * @param opInfoLen [IN] memory size of subscription data
  249. * @param index [IN] index of op array in opInfo
  250. *
  251. * @retval execution time(us) of specified op with timestamp
  252. * @retval 0 for failed
  253. */
  254. ACL_FUNC_VISIBILITY uint64_t aclprofGetOpDuration(const void *opInfo, size_t opInfoLen, uint32_t index);
  255. /**
  256. * @ingroup AscendCL
  257. * @brief get model id from subscription data
  258. *
  259. * @param opInfo [IN] pointer to subscription data
  260. * @param opInfoLen [IN] memory size of subscription data
  261. *
  262. * @retval model id of subscription data
  263. * @retval 0 for failed
  264. */
  265. ACL_FUNC_VISIBILITY size_t aclprofGetModelId(const void *opInfo, size_t opInfoLen, uint32_t index);
  266. #ifdef __cplusplus
  267. }
  268. #endif
  269. #endif // INC_EXTERNAL_ACL_PROF_H_

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