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 13 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
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
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
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
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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. /**
  2. * Copyright 2019-2022 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. #if (defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER))
  19. #define MSVP_PROF_API __declspec(dllexport)
  20. #else
  21. #define MSVP_PROF_API __attribute__((visibility("default")))
  22. #endif
  23. #include "acl_base.h"
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #define ACL_PROF_ACL_API 0x0001ULL
  28. #define ACL_PROF_TASK_TIME 0x0002ULL
  29. #define ACL_PROF_AICORE_METRICS 0x0004ULL
  30. #define ACL_PROF_AICPU 0x0008ULL
  31. #define ACL_PROF_L2CACHE 0x0010ULL
  32. #define ACL_PROF_HCCL_TRACE 0x0020ULL
  33. #define ACL_PROF_TRAINING_TRACE 0x0040ULL
  34. #define ACL_PROF_MSPROFTX 0x0080ULL
  35. #define ACL_PROF_RUNTIME_API 0x0100ULL
  36. /**
  37. * @deprecated please use aclprofGetOpTypeLen and aclprofGetOpTNameLen instead
  38. */
  39. #define ACL_PROF_MAX_OP_NAME_LEN 257
  40. #define ACL_PROF_MAX_OP_TYPE_LEN 65
  41. typedef enum {
  42. ACL_AICORE_ARITHMETIC_UTILIZATION = 0,
  43. ACL_AICORE_PIPE_UTILIZATION = 1,
  44. ACL_AICORE_MEMORY_BANDWIDTH = 2,
  45. ACL_AICORE_L0B_AND_WIDTH = 3,
  46. ACL_AICORE_RESOURCE_CONFLICT_RATIO = 4,
  47. ACL_AICORE_MEMORY_UB = 5,
  48. ACL_AICORE_NONE = 0xFF
  49. } aclprofAicoreMetrics;
  50. typedef enum {
  51. ACL_STEP_START = 0, // step start
  52. ACL_STEP_END = 1 // step end
  53. } aclprofStepTag;
  54. typedef struct aclprofConfig aclprofConfig;
  55. typedef struct aclprofStopConfig aclprofStopConfig;
  56. typedef struct aclprofAicoreEvents aclprofAicoreEvents;
  57. typedef struct aclprofSubscribeConfig aclprofSubscribeConfig;
  58. typedef struct aclprofStepInfo aclprofStepInfo;
  59. /**
  60. * @ingroup AscendCL
  61. * @brief profiling initialize
  62. *
  63. * @param profilerResultPath [IN] path of profiling result
  64. * @param length [IN] length of profilerResultPath
  65. *
  66. * @retval ACL_SUCCESS The function is successfully executed.
  67. * @retval OtherValues Failure
  68. *
  69. * @see aclprofFinalize
  70. */
  71. MSVP_PROF_API aclError aclprofInit(const char *profilerResultPath, size_t length);
  72. /**
  73. * @ingroup AscendCL
  74. * @brief profiling finalize
  75. *
  76. * @retval ACL_SUCCESS The function is successfully executed.
  77. * @retval OtherValues Failure
  78. *
  79. * @see aclprofInit
  80. */
  81. MSVP_PROF_API aclError aclprofFinalize();
  82. /**
  83. * @ingroup AscendCL
  84. * @brief Start profiling modules by profilerConfig
  85. *
  86. * @param profilerConfig [IN] config of profiling
  87. *
  88. * @retval ACL_SUCCESS The function is successfully executed.
  89. * @retval OtherValues Failure
  90. *
  91. * @see aclprofStop
  92. */
  93. MSVP_PROF_API aclError aclprofStart(const aclprofConfig *profilerConfig);
  94. /**
  95. * @ingroup AscendCL
  96. * @brief Create data of type aclprofConfig
  97. *
  98. * @param deviceIdList [IN] list of device id
  99. * @param deviceNums [IN] number of devices
  100. * @param aicoreMetrics [IN] type of aicore metrics
  101. * @param aicoreEvents [IN] pointer to aicore events, only support NULL now
  102. * @param dataTypeConfig [IN] config modules need profiling
  103. *
  104. * @retval the aclprofConfig pointer
  105. *
  106. * @see aclprofDestroyConfig
  107. */
  108. MSVP_PROF_API aclprofConfig *aclprofCreateConfig(uint32_t *deviceIdList, uint32_t deviceNums,
  109. aclprofAicoreMetrics aicoreMetrics, aclprofAicoreEvents *aicoreEvents,
  110. uint64_t dataTypeConfig);
  111. /**
  112. * @ingroup AscendCL
  113. * @brief Destroy data of type aclprofConfig
  114. *
  115. * @param profilerConfig [IN] config of profiling
  116. *
  117. * @retval ACL_SUCCESS The function is successfully executed.
  118. * @retval OtherValues Failure
  119. *
  120. * @see aclprofCreateConfig
  121. */
  122. MSVP_PROF_API aclError aclprofDestroyConfig(const aclprofConfig *profilerConfig);
  123. /**
  124. * @ingroup AscendCL
  125. * @brief stop profiling modules by stopProfilingConfig
  126. *
  127. * @param profilerConfig [IN] pointer to stop config of profiling
  128. *
  129. * @retval ACL_SUCCESS The function is successfully executed.
  130. * @retval OtherValues Failure
  131. *
  132. * @see aclprofStart
  133. */
  134. MSVP_PROF_API aclError aclprofStop(const aclprofConfig *profilerConfig);
  135. /**
  136. * @ingroup AscendCL
  137. * @brief subscribe profiling data of model
  138. *
  139. * @param modelId [IN] the model id subscribed
  140. * @param profSubscribeConfig [IN] pointer to config of model subscribe
  141. *
  142. * @retval ACL_SUCCESS The function is successfully executed.
  143. * @retval OtherValues Failure
  144. *
  145. * @see aclprofModelUnSubscribe
  146. */
  147. MSVP_PROF_API aclError aclprofModelSubscribe(uint32_t modelId, const aclprofSubscribeConfig *profSubscribeConfig);
  148. /**
  149. * @ingroup AscendCL
  150. * @brief unsubscribe profiling data of model
  151. *
  152. * @param modelId [IN] the model id unsubscribed
  153. *
  154. * @retval ACL_SUCCESS The function is successfully executed.
  155. * @retval OtherValues Failure
  156. *
  157. * @see aclprofModelSubscribe
  158. */
  159. MSVP_PROF_API aclError aclprofModelUnSubscribe(uint32_t modelId);
  160. /**
  161. * @ingroup AscendCL
  162. * @brief create subscribe config
  163. *
  164. * @param timeInfoSwitch [IN] switch whether get time info from model
  165. * @param aicoreMetrics [IN] aicore metrics
  166. * @param fd [IN] pointer to write pipe
  167. *
  168. * @retval the aclprofSubscribeConfig pointer
  169. *
  170. * @see aclprofDestroySubscribeConfig
  171. */
  172. MSVP_PROF_API aclprofSubscribeConfig *aclprofCreateSubscribeConfig(int8_t timeInfoSwitch,
  173. aclprofAicoreMetrics aicoreMetrics, void *fd);
  174. /**
  175. * @ingroup AscendCL
  176. * @brief destroy subscribe config
  177. *
  178. * @param profSubscribeConfig [IN] subscribe config
  179. *
  180. * @retval ACL_SUCCESS The function is successfully executed.
  181. * @retval OtherValues Failure
  182. *
  183. * @see aclprofCreateSubscribeConfig
  184. */
  185. MSVP_PROF_API aclError aclprofDestroySubscribeConfig(const aclprofSubscribeConfig *profSubscribeConfig);
  186. /**
  187. * @ingroup AscendCL
  188. * @brief create subscribe config
  189. *
  190. * @param opDescSize [OUT] size of op desc
  191. *
  192. * @retval ACL_SUCCESS The function is successfully executed.
  193. * @retval OtherValues Failure
  194. */
  195. MSVP_PROF_API aclError aclprofGetOpDescSize(size_t *opDescSize);
  196. /**
  197. * @ingroup AscendCL
  198. * @brief get op number from subscription data
  199. *
  200. * @param opInfo [IN] pointer to subscription data
  201. * @param opInfoLen [IN] memory size of subscription data
  202. * @param opNumber [OUT] op number of subscription data
  203. *
  204. * @retval ACL_SUCCESS The function is successfully executed.
  205. * @retval OtherValues Failure
  206. */
  207. MSVP_PROF_API aclError aclprofGetOpNum(const void *opInfo, size_t opInfoLen, uint32_t *opNumber);
  208. /**
  209. * @ingroup AscendCL
  210. * @brief get length op type from subscription data
  211. *
  212. * @param opInfo [IN] pointer to subscription data
  213. * @param opInfoLen [IN] memory size of subscription data
  214. * @param index [IN] index of op array in opInfo
  215. * @param opTypeLen [OUT] actual length of op type string
  216. *
  217. * @retval ACL_SUCCESS The function is successfully executed.
  218. * @retval OtherValues Failure
  219. */
  220. MSVP_PROF_API aclError aclprofGetOpTypeLen(const void *opInfo, size_t opInfoLen, uint32_t index, size_t *opTypeLen);
  221. /**
  222. * @ingroup AscendCL
  223. * @brief get op type 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 opType [OUT] obtained op type string
  229. * @param opTypeLen [IN] obtained length of op type string
  230. *
  231. * @retval ACL_SUCCESS The function is successfully executed.
  232. * @retval OtherValues Failure
  233. */
  234. MSVP_PROF_API aclError aclprofGetOpType(const void *opInfo, size_t opInfoLen, uint32_t index, char *opType,
  235. size_t opTypeLen);
  236. /**
  237. * @ingroup AscendCL
  238. * @brief get length op name from subscription data
  239. *
  240. * @param opInfo [IN] pointer to subscription data
  241. * @param opInfoLen [IN] memory size of subscription data
  242. * @param index [IN] index of op array in opInfo
  243. * @param opNameLen [OUT] actual length of op name string
  244. *
  245. * @retval ACL_SUCCESS The function is successfully executed.
  246. * @retval OtherValues Failure
  247. */
  248. MSVP_PROF_API aclError aclprofGetOpNameLen(const void *opInfo, size_t opInfoLen, uint32_t index, size_t *opNameLen);
  249. /**
  250. * @ingroup AscendCL
  251. * @brief get op type from subscription data
  252. *
  253. * @param opInfo [IN] pointer to subscription data
  254. * @param opInfoLen [IN] memory size of subscription data
  255. * @param index [IN] index of op array in opInfo
  256. * @param opName [OUT] obtained op name string
  257. * @param opNameLen [IN] obtained length of op name string
  258. *
  259. * @retval ACL_SUCCESS The function is successfully executed.
  260. * @retval OtherValues Failure
  261. */
  262. MSVP_PROF_API aclError aclprofGetOpName(const void *opInfo, size_t opInfoLen, uint32_t index, char *opName,
  263. size_t opNameLen);
  264. /**
  265. * @ingroup AscendCL
  266. * @brief get start time of specified op from subscription data
  267. *
  268. * @param opInfo [IN] pointer to subscription data
  269. * @param opInfoLen [IN] memory size of subscription data
  270. * @param index [IN] index of op array in opInfo
  271. *
  272. * @retval start time(us) of specified op with timestamp
  273. * @retval 0 for failed
  274. */
  275. MSVP_PROF_API uint64_t aclprofGetOpStart(const void *opInfo, size_t opInfoLen, uint32_t index);
  276. /**
  277. * @ingroup AscendCL
  278. * @brief get end time of specified op from subscription data
  279. *
  280. * @param opInfo [IN] pointer to subscription data
  281. * @param opInfoLen [IN] memory size of subscription data
  282. * @param index [IN] index of op array in opInfo
  283. *
  284. * @retval end time(us) of specified op with timestamp
  285. * @retval 0 for failed
  286. */
  287. MSVP_PROF_API uint64_t aclprofGetOpEnd(const void *opInfo, size_t opInfoLen, uint32_t index);
  288. /**
  289. * @ingroup AscendCL
  290. * @brief get excution time of specified op from subscription data
  291. *
  292. * @param opInfo [IN] pointer to subscription data
  293. * @param opInfoLen [IN] memory size of subscription data
  294. * @param index [IN] index of op array in opInfo
  295. *
  296. * @retval execution time(us) of specified op with timestamp
  297. * @retval 0 for failed
  298. */
  299. MSVP_PROF_API uint64_t aclprofGetOpDuration(const void *opInfo, size_t opInfoLen, uint32_t index);
  300. /**
  301. * @ingroup AscendCL
  302. * @brief get model id from subscription data
  303. *
  304. * @param opInfo [IN] pointer to subscription data
  305. * @param opInfoLen [IN] memory size of subscription data
  306. *
  307. * @retval model id of subscription data
  308. * @retval 0 for failed
  309. */
  310. MSVP_PROF_API size_t aclprofGetModelId(const void *opInfo, size_t opInfoLen, uint32_t index);
  311. /**
  312. * @ingroup AscendCL
  313. * @brief
  314. *
  315. * @param stepInfo [IN] pointer to stepInfo data
  316. * @param aclprofstepTag [IN] start or end flag
  317. * @param stream [IN] steam info
  318. *
  319. * @retval 0 for failed
  320. */
  321. MSVP_PROF_API aclError aclprofGetStepTimestamp(aclprofStepInfo *stepInfo, aclprofStepTag tag, aclrtStream stream);
  322. /**
  323. * @ingroup AscendCL
  324. * @brief create pointer to aclprofStepInfo data
  325. *
  326. *
  327. * @retval aclprofStepInfo pointer
  328. */
  329. MSVP_PROF_API aclprofStepInfo *aclprofCreateStepInfo();
  330. /**
  331. * @ingroup AscendCL
  332. * @brief destroy aclprofStepInfo pointer
  333. *
  334. *
  335. * @retval void
  336. */
  337. MSVP_PROF_API void aclprofDestroyStepInfo(aclprofStepInfo *stepinfo);
  338. /**
  339. * @ingroup AscendCL
  340. * @brief create pointer to aclprofstamp
  341. *
  342. *
  343. * @retval aclprofStamp pointer
  344. */
  345. MSVP_PROF_API void *aclprofCreateStamp();
  346. /**
  347. * @ingroup AscendCL
  348. * @brief destory stamp pointer
  349. *
  350. *
  351. * @retval void
  352. */
  353. MSVP_PROF_API void aclprofDestroyStamp(void *stamp);
  354. /**
  355. * @ingroup AscendCL
  356. * @brief Record push timestamp
  357. *
  358. * @retval ACL_SUCCESS The function is successfully executed.
  359. * @retval OtherValues Failure
  360. */
  361. MSVP_PROF_API aclError aclprofPush(void *stamp);
  362. /**
  363. * @ingroup AscendCL
  364. * @brief Record pop timestamp
  365. *
  366. *
  367. * @retval ACL_SUCCESS The function is successfully executed.
  368. * @retval OtherValues Failure
  369. */
  370. MSVP_PROF_API aclError aclprofPop();
  371. /**
  372. * @ingroup AscendCL
  373. * @brief Record range start timestamp
  374. *
  375. * @retval ACL_SUCCESS The function is successfully executed.
  376. * @retval OtherValues Failure
  377. */
  378. MSVP_PROF_API aclError aclprofRangeStart(void *stamp, uint32_t *rangeId);
  379. /**
  380. * @ingroup AscendCL
  381. * @brief Record range end timestamp
  382. *
  383. * @retval ACL_SUCCESS The function is successfully executed.
  384. * @retval OtherValues Failure
  385. */
  386. MSVP_PROF_API aclError aclprofRangeStop(uint32_t rangeId);
  387. /**
  388. * @ingroup AscendCL
  389. * @brief set message to stamp
  390. *
  391. *
  392. * @retval void
  393. */
  394. MSVP_PROF_API aclError aclprofSetStampTraceMessage(void *stamp, const char *msg, uint32_t msgLen);
  395. /**
  396. * @ingroup AscendCL
  397. * @brief Record mark timestamp
  398. *
  399. * @retval ACL_SUCCESS The function is successfully executed.
  400. * @retval OtherValues Failure
  401. */
  402. MSVP_PROF_API aclError aclprofMark(void *stamp);
  403. #ifdef __cplusplus
  404. }
  405. #endif
  406. #endif // INC_EXTERNAL_ACL_PROF_H_

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