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

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

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