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 14 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
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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 enum {
  55. ACL_SUBSCRIBE_OP = 0,
  56. ACL_SUBSCRIBE_SUBGRAPH = 1,
  57. ACL_SUBSCRIBE_OP_THREAD = 2,
  58. ACL_SUBSCRIBE_NONE
  59. } aclprofSubscribeOpFlag;
  60. typedef enum { ACL_SUBSCRIBE_ATTRI_THREADID = 0, ACL_SUBSCRIBE_ATTRI_NONE } aclprofSubscribeOpAttri;
  61. typedef struct aclprofConfig aclprofConfig;
  62. typedef struct aclprofStopConfig aclprofStopConfig;
  63. typedef struct aclprofAicoreEvents aclprofAicoreEvents;
  64. typedef struct aclprofSubscribeConfig aclprofSubscribeConfig;
  65. typedef struct aclprofStepInfo aclprofStepInfo;
  66. /**
  67. * @ingroup AscendCL
  68. * @brief profiling initialize
  69. *
  70. * @param profilerResultPath [IN] path of profiling result
  71. * @param length [IN] length of profilerResultPath
  72. *
  73. * @retval ACL_SUCCESS The function is successfully executed.
  74. * @retval OtherValues Failure
  75. *
  76. * @see aclprofFinalize
  77. */
  78. MSVP_PROF_API aclError aclprofInit(const char *profilerResultPath, size_t length);
  79. /**
  80. * @ingroup AscendCL
  81. * @brief profiling finalize
  82. *
  83. * @retval ACL_SUCCESS The function is successfully executed.
  84. * @retval OtherValues Failure
  85. *
  86. * @see aclprofInit
  87. */
  88. MSVP_PROF_API aclError aclprofFinalize();
  89. /**
  90. * @ingroup AscendCL
  91. * @brief Start profiling modules by profilerConfig
  92. *
  93. * @param profilerConfig [IN] config of profiling
  94. *
  95. * @retval ACL_SUCCESS The function is successfully executed.
  96. * @retval OtherValues Failure
  97. *
  98. * @see aclprofStop
  99. */
  100. MSVP_PROF_API aclError aclprofStart(const aclprofConfig *profilerConfig);
  101. /**
  102. * @ingroup AscendCL
  103. * @brief Create data of type aclprofConfig
  104. *
  105. * @param deviceIdList [IN] list of device id
  106. * @param deviceNums [IN] number of devices
  107. * @param aicoreMetrics [IN] type of aicore metrics
  108. * @param aicoreEvents [IN] pointer to aicore events, only support NULL now
  109. * @param dataTypeConfig [IN] config modules need profiling
  110. *
  111. * @retval the aclprofConfig pointer
  112. *
  113. * @see aclprofDestroyConfig
  114. */
  115. MSVP_PROF_API aclprofConfig *aclprofCreateConfig(uint32_t *deviceIdList, uint32_t deviceNums,
  116. aclprofAicoreMetrics aicoreMetrics,
  117. const aclprofAicoreEvents *aicoreEvents, uint64_t dataTypeConfig);
  118. /**
  119. * @ingroup AscendCL
  120. * @brief Destroy data of type aclprofConfig
  121. *
  122. * @param profilerConfig [IN] config of profiling
  123. *
  124. * @retval ACL_SUCCESS The function is successfully executed.
  125. * @retval OtherValues Failure
  126. *
  127. * @see aclprofCreateConfig
  128. */
  129. MSVP_PROF_API aclError aclprofDestroyConfig(const aclprofConfig *profilerConfig);
  130. /**
  131. * @ingroup AscendCL
  132. * @brief stop profiling modules by stopProfilingConfig
  133. *
  134. * @param profilerConfig [IN] pointer to stop config of profiling
  135. *
  136. * @retval ACL_SUCCESS The function is successfully executed.
  137. * @retval OtherValues Failure
  138. *
  139. * @see aclprofStart
  140. */
  141. MSVP_PROF_API aclError aclprofStop(const aclprofConfig *profilerConfig);
  142. /**
  143. * @ingroup AscendCL
  144. * @brief subscribe profiling data of model
  145. *
  146. * @param modelId [IN] the model id subscribed
  147. * @param profSubscribeConfig [IN] pointer to config of model subscribe
  148. *
  149. * @retval ACL_SUCCESS The function is successfully executed.
  150. * @retval OtherValues Failure
  151. *
  152. * @see aclprofModelUnSubscribe
  153. */
  154. MSVP_PROF_API aclError aclprofModelSubscribe(uint32_t modelId, const aclprofSubscribeConfig *profSubscribeConfig);
  155. /**
  156. * @ingroup AscendCL
  157. * @brief unsubscribe profiling data of model
  158. *
  159. * @param modelId [IN] the model id unsubscribed
  160. *
  161. * @retval ACL_SUCCESS The function is successfully executed.
  162. * @retval OtherValues Failure
  163. *
  164. * @see aclprofModelSubscribe
  165. */
  166. MSVP_PROF_API aclError aclprofModelUnSubscribe(uint32_t modelId);
  167. /**
  168. * @ingroup AscendCL
  169. * @brief create subscribe config
  170. *
  171. * @param timeInfoSwitch [IN] switch whether get time info from model
  172. * @param aicoreMetrics [IN] aicore metrics
  173. * @param fd [IN] pointer to write pipe
  174. *
  175. * @retval the aclprofSubscribeConfig pointer
  176. *
  177. * @see aclprofDestroySubscribeConfig
  178. */
  179. MSVP_PROF_API aclprofSubscribeConfig *aclprofCreateSubscribeConfig(int8_t timeInfoSwitch,
  180. aclprofAicoreMetrics aicoreMetrics, void *fd);
  181. /**
  182. * @ingroup AscendCL
  183. * @brief destroy subscribe config
  184. *
  185. * @param profSubscribeConfig [IN] subscribe config
  186. *
  187. * @retval ACL_SUCCESS The function is successfully executed.
  188. * @retval OtherValues Failure
  189. *
  190. * @see aclprofCreateSubscribeConfig
  191. */
  192. MSVP_PROF_API aclError aclprofDestroySubscribeConfig(const aclprofSubscribeConfig *profSubscribeConfig);
  193. /**
  194. * @ingroup AscendCL
  195. * @brief create subscribe config
  196. *
  197. * @param opDescSize [OUT] size of op desc
  198. *
  199. * @retval ACL_SUCCESS The function is successfully executed.
  200. * @retval OtherValues Failure
  201. */
  202. MSVP_PROF_API aclError aclprofGetOpDescSize(size_t *opDescSize);
  203. /**
  204. * @ingroup AscendCL
  205. * @brief get op number from subscription data
  206. *
  207. * @param opInfo [IN] pointer to subscription data
  208. * @param opInfoLen [IN] memory size of subscription data
  209. * @param opNumber [OUT] op number of subscription data
  210. *
  211. * @retval ACL_SUCCESS The function is successfully executed.
  212. * @retval OtherValues Failure
  213. */
  214. MSVP_PROF_API aclError aclprofGetOpNum(const void *opInfo, size_t opInfoLen, uint32_t *opNumber);
  215. /**
  216. * @ingroup AscendCL
  217. * @brief get length op type from subscription data
  218. *
  219. * @param opInfo [IN] pointer to subscription data
  220. * @param opInfoLen [IN] memory size of subscription data
  221. * @param index [IN] index of op array in opInfo
  222. * @param opTypeLen [OUT] actual length of op type string
  223. *
  224. * @retval ACL_SUCCESS The function is successfully executed.
  225. * @retval OtherValues Failure
  226. */
  227. MSVP_PROF_API aclError aclprofGetOpTypeLen(const void *opInfo, size_t opInfoLen, uint32_t index, size_t *opTypeLen);
  228. /**
  229. * @ingroup AscendCL
  230. * @brief get op type from subscription data
  231. *
  232. * @param opInfo [IN] pointer to subscription data
  233. * @param opInfoLen [IN] memory size of subscription data
  234. * @param index [IN] index of op array in opInfo
  235. * @param opType [OUT] obtained op type string
  236. * @param opTypeLen [IN] obtained length of op type string
  237. *
  238. * @retval ACL_SUCCESS The function is successfully executed.
  239. * @retval OtherValues Failure
  240. */
  241. MSVP_PROF_API aclError aclprofGetOpType(const void *opInfo, size_t opInfoLen, uint32_t index, char *opType,
  242. size_t opTypeLen);
  243. /**
  244. * @ingroup AscendCL
  245. * @brief get length op name from subscription data
  246. *
  247. * @param opInfo [IN] pointer to subscription data
  248. * @param opInfoLen [IN] memory size of subscription data
  249. * @param index [IN] index of op array in opInfo
  250. * @param opNameLen [OUT] actual length of op name string
  251. *
  252. * @retval ACL_SUCCESS The function is successfully executed.
  253. * @retval OtherValues Failure
  254. */
  255. MSVP_PROF_API aclError aclprofGetOpNameLen(const void *opInfo, size_t opInfoLen, uint32_t index, size_t *opNameLen);
  256. /**
  257. * @ingroup AscendCL
  258. * @brief get op type 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. * @param opName [OUT] obtained op name string
  264. * @param opNameLen [IN] obtained length of op name string
  265. *
  266. * @retval ACL_SUCCESS The function is successfully executed.
  267. * @retval OtherValues Failure
  268. */
  269. MSVP_PROF_API aclError aclprofGetOpName(const void *opInfo, size_t opInfoLen, uint32_t index, char *opName,
  270. size_t opNameLen);
  271. /**
  272. * @ingroup AscendCL
  273. * @brief get start time of specified op from subscription data
  274. *
  275. * @param opInfo [IN] pointer to subscription data
  276. * @param opInfoLen [IN] memory size of subscription data
  277. * @param index [IN] index of op array in opInfo
  278. *
  279. * @retval start time(us) of specified op with timestamp
  280. * @retval 0 for failed
  281. */
  282. MSVP_PROF_API uint64_t aclprofGetOpStart(const void *opInfo, size_t opInfoLen, uint32_t index);
  283. /**
  284. * @ingroup AscendCL
  285. * @brief get end time of specified op from subscription data
  286. *
  287. * @param opInfo [IN] pointer to subscription data
  288. * @param opInfoLen [IN] memory size of subscription data
  289. * @param index [IN] index of op array in opInfo
  290. *
  291. * @retval end time(us) of specified op with timestamp
  292. * @retval 0 for failed
  293. */
  294. MSVP_PROF_API uint64_t aclprofGetOpEnd(const void *opInfo, size_t opInfoLen, uint32_t index);
  295. /**
  296. * @ingroup AscendCL
  297. * @brief get excution time of specified op from subscription data
  298. *
  299. * @param opInfo [IN] pointer to subscription data
  300. * @param opInfoLen [IN] memory size of subscription data
  301. * @param index [IN] index of op array in opInfo
  302. *
  303. * @retval execution time(us) of specified op with timestamp
  304. * @retval 0 for failed
  305. */
  306. MSVP_PROF_API uint64_t aclprofGetOpDuration(const void *opInfo, size_t opInfoLen, uint32_t index);
  307. /**
  308. * @ingroup AscendCL
  309. * @brief get model id from subscription data
  310. *
  311. * @param opInfo [IN] pointer to subscription data
  312. * @param opInfoLen [IN] memory size of subscription data
  313. *
  314. * @retval model id of subscription data
  315. * @retval 0 for failed
  316. */
  317. MSVP_PROF_API size_t aclprofGetModelId(const void *opInfo, size_t opInfoLen, uint32_t index);
  318. /**
  319. * @ingroup AscendCL
  320. * @brief get op flag from subscription data
  321. *
  322. * @param opInfo [IN] pointer to subscription data
  323. * @param opInfoLen [IN] memory size of subscription data
  324. * @param index [IN] index of op array in opInfo
  325. *
  326. * @retval op flag
  327. * @retval ACL_SUBSCRIBE_NONE for failed
  328. */
  329. MSVP_PROF_API aclprofSubscribeOpFlag aclprofGetOpFlag(const void *opInfo, size_t opInfoLen, uint32_t index);
  330. /**
  331. * @ingroup AscendCL
  332. * @brief get op flag from subscription data
  333. *
  334. * @param opInfo [IN] pointer to subscription data
  335. * @param opInfoLen [IN] memory size of subscription data
  336. * @param index [IN] index of op array in opInfo
  337. * @param attri [IN] attribute of op
  338. *
  339. * @retval op flag
  340. * @retval NULL for failed
  341. */
  342. MSVP_PROF_API const char *aclprofGetOpAttriValue(const void *opInfo, size_t opInfoLen, uint32_t index,
  343. aclprofSubscribeOpAttri attri);
  344. /**
  345. * @ingroup AscendCL
  346. * @brief
  347. *
  348. * @param stepInfo [IN] pointer to stepInfo data
  349. * @param aclprofstepTag [IN] start or end flag
  350. * @param stream [IN] steam info
  351. *
  352. * @retval 0 for failed
  353. */
  354. MSVP_PROF_API aclError aclprofGetStepTimestamp(aclprofStepInfo *stepInfo, aclprofStepTag tag, aclrtStream stream);
  355. /**
  356. * @ingroup AscendCL
  357. * @brief create pointer to aclprofStepInfo data
  358. *
  359. *
  360. * @retval aclprofStepInfo pointer
  361. */
  362. MSVP_PROF_API aclprofStepInfo *aclprofCreateStepInfo();
  363. /**
  364. * @ingroup AscendCL
  365. * @brief destroy aclprofStepInfo pointer
  366. *
  367. *
  368. * @retval void
  369. */
  370. MSVP_PROF_API void aclprofDestroyStepInfo(aclprofStepInfo *stepinfo);
  371. /**
  372. * @ingroup AscendCL
  373. * @brief create pointer to aclprofstamp
  374. *
  375. *
  376. * @retval aclprofStamp pointer
  377. */
  378. MSVP_PROF_API void *aclprofCreateStamp();
  379. /**
  380. * @ingroup AscendCL
  381. * @brief destory stamp pointer
  382. *
  383. *
  384. * @retval void
  385. */
  386. MSVP_PROF_API void aclprofDestroyStamp(void *stamp);
  387. /**
  388. * @ingroup AscendCL
  389. * @brief Record push timestamp
  390. *
  391. * @retval ACL_SUCCESS The function is successfully executed.
  392. * @retval OtherValues Failure
  393. */
  394. MSVP_PROF_API aclError aclprofPush(void *stamp);
  395. /**
  396. * @ingroup AscendCL
  397. * @brief Record pop timestamp
  398. *
  399. *
  400. * @retval ACL_SUCCESS The function is successfully executed.
  401. * @retval OtherValues Failure
  402. */
  403. MSVP_PROF_API aclError aclprofPop();
  404. /**
  405. * @ingroup AscendCL
  406. * @brief Record range start timestamp
  407. *
  408. * @retval ACL_SUCCESS The function is successfully executed.
  409. * @retval OtherValues Failure
  410. */
  411. MSVP_PROF_API aclError aclprofRangeStart(void *stamp, uint32_t *rangeId);
  412. /**
  413. * @ingroup AscendCL
  414. * @brief Record range end timestamp
  415. *
  416. * @retval ACL_SUCCESS The function is successfully executed.
  417. * @retval OtherValues Failure
  418. */
  419. MSVP_PROF_API aclError aclprofRangeStop(uint32_t rangeId);
  420. /**
  421. * @ingroup AscendCL
  422. * @brief set message to stamp
  423. *
  424. *
  425. * @retval void
  426. */
  427. MSVP_PROF_API aclError aclprofSetStampTraceMessage(void *stamp, const char *msg, uint32_t msgLen);
  428. /**
  429. * @ingroup AscendCL
  430. * @brief Record mark timestamp
  431. *
  432. * @retval ACL_SUCCESS The function is successfully executed.
  433. * @retval OtherValues Failure
  434. */
  435. MSVP_PROF_API aclError aclprofMark(void *stamp);
  436. #ifdef __cplusplus
  437. }
  438. #endif
  439. #endif // INC_EXTERNAL_ACL_PROF_H_

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