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

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

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