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

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

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