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

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