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

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

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