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.

5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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 D_SYSLOG_H_
  17. #define D_SYSLOG_H_
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif // __cplusplus
  21. /**
  22. * @ingroup slog
  23. *
  24. * debug level id
  25. */
  26. #define DLOG_DEBUG 0
  27. /**
  28. * @ingroup slog
  29. *
  30. * info level id
  31. */
  32. #define DLOG_INFO 1
  33. /**
  34. * @ingroup slog
  35. *
  36. * warning level id
  37. */
  38. #define DLOG_WARN 2
  39. /**
  40. * @ingroup slog
  41. *
  42. * error level id
  43. */
  44. #define DLOG_ERROR 3
  45. /**
  46. * @ingroup slog
  47. *
  48. * don't print log
  49. */
  50. #define DLOG_NULL 4
  51. /**
  52. * @ingroup slog
  53. *
  54. * trace log print level id
  55. */
  56. #define DLOG_TRACE 5
  57. /**
  58. * @ingroup slog
  59. *
  60. * oplog log print level id
  61. */
  62. #define DLOG_OPLOG 6
  63. /**
  64. * @ingroup slog
  65. *
  66. * event log print level id
  67. */
  68. #define DLOG_EVENT 0x10
  69. /**
  70. * @ingroup slog
  71. *
  72. * max log length
  73. */
  74. #define MSG_LENGTH 1024
  75. typedef struct tagDCODE {
  76. const char *cName;
  77. int cVal;
  78. } DCODE;
  79. typedef struct tagKV {
  80. char *kname;
  81. char *value;
  82. } KeyValue;
  83. /**
  84. * @ingroup slog
  85. *
  86. * module id
  87. */
  88. enum {
  89. SLOG, /**< Slog */
  90. IDEDD, /**< IDE daemon device */
  91. IDEDH, /**< IDE daemon host */
  92. HCCL, /**< HCCL */
  93. FMK, /**< Framework */
  94. HIAIENGINE, /**< Matrix */
  95. DVPP, /**< DVPP */
  96. RUNTIME, /**< Runtime */
  97. CCE, /**< CCE */
  98. HDC, /**< HDC */
  99. DRV, /**< Driver */
  100. MDCFUSION, /**< Mdc fusion */
  101. MDCLOCATION, /**< Mdc location */
  102. MDCPERCEPTION, /**< Mdc perception */
  103. MDCFSM,
  104. MDCCOMMON,
  105. MDCMONITOR,
  106. MDCBSWP, /**< MDC base software platform */
  107. MDCDEFAULT, /**< MDC undefine */
  108. MDCSC, /**< MDC spatial cognition */
  109. MDCPNC,
  110. MLL,
  111. DEVMM, /**< Dlog memory managent */
  112. KERNEL, /**< Kernel */
  113. LIBMEDIA, /**< Libmedia */
  114. CCECPU, /**< ai cpu */
  115. ASCENDDK, /**< AscendDK */
  116. ROS, /**< ROS */
  117. HCCP,
  118. ROCE,
  119. TEFUSION,
  120. PROFILING, /**< Profiling */
  121. DP, /**< Data Preprocess */
  122. APP, /**< User Application */
  123. TS, /**< TS module */
  124. TSDUMP, /**< TSDUMP module */
  125. AICPU, /**< AICPU module */
  126. LP, /**< LP module */
  127. TDT,
  128. FE,
  129. MD,
  130. MB,
  131. ME,
  132. IMU,
  133. IMP,
  134. GE, /**< Fmk */
  135. MDCFUSA,
  136. CAMERA,
  137. ASCENDCL,
  138. TEEOS,
  139. SIS,
  140. HSM,
  141. INVLID_MOUDLE_ID
  142. };
  143. #ifdef MODULE_ID_NAME
  144. /**
  145. * @ingroup slog
  146. *
  147. * set module id to map
  148. */
  149. #define SET_MOUDLE_ID_MAP_NAME(x) \
  150. { #x, x }
  151. static DCODE g_moduleIdName[] = {SET_MOUDLE_ID_MAP_NAME(SLOG),
  152. SET_MOUDLE_ID_MAP_NAME(IDEDD),
  153. SET_MOUDLE_ID_MAP_NAME(IDEDH),
  154. SET_MOUDLE_ID_MAP_NAME(HCCL),
  155. SET_MOUDLE_ID_MAP_NAME(FMK),
  156. SET_MOUDLE_ID_MAP_NAME(HIAIENGINE),
  157. SET_MOUDLE_ID_MAP_NAME(DVPP),
  158. SET_MOUDLE_ID_MAP_NAME(RUNTIME),
  159. SET_MOUDLE_ID_MAP_NAME(CCE),
  160. SET_MOUDLE_ID_MAP_NAME(HDC),
  161. SET_MOUDLE_ID_MAP_NAME(DRV),
  162. SET_MOUDLE_ID_MAP_NAME(MDCFUSION),
  163. SET_MOUDLE_ID_MAP_NAME(MDCLOCATION),
  164. SET_MOUDLE_ID_MAP_NAME(MDCPERCEPTION),
  165. SET_MOUDLE_ID_MAP_NAME(MDCFSM),
  166. SET_MOUDLE_ID_MAP_NAME(MDCCOMMON),
  167. SET_MOUDLE_ID_MAP_NAME(MDCMONITOR),
  168. SET_MOUDLE_ID_MAP_NAME(MDCBSWP),
  169. SET_MOUDLE_ID_MAP_NAME(MDCDEFAULT),
  170. SET_MOUDLE_ID_MAP_NAME(MDCSC),
  171. SET_MOUDLE_ID_MAP_NAME(MDCPNC),
  172. SET_MOUDLE_ID_MAP_NAME(MLL),
  173. SET_MOUDLE_ID_MAP_NAME(DEVMM),
  174. SET_MOUDLE_ID_MAP_NAME(KERNEL),
  175. SET_MOUDLE_ID_MAP_NAME(LIBMEDIA),
  176. SET_MOUDLE_ID_MAP_NAME(CCECPU),
  177. SET_MOUDLE_ID_MAP_NAME(ASCENDDK),
  178. SET_MOUDLE_ID_MAP_NAME(ROS),
  179. SET_MOUDLE_ID_MAP_NAME(HCCP),
  180. SET_MOUDLE_ID_MAP_NAME(ROCE),
  181. SET_MOUDLE_ID_MAP_NAME(TEFUSION),
  182. SET_MOUDLE_ID_MAP_NAME(PROFILING),
  183. SET_MOUDLE_ID_MAP_NAME(DP),
  184. SET_MOUDLE_ID_MAP_NAME(APP),
  185. SET_MOUDLE_ID_MAP_NAME(TS),
  186. SET_MOUDLE_ID_MAP_NAME(TSDUMP),
  187. SET_MOUDLE_ID_MAP_NAME(AICPU),
  188. SET_MOUDLE_ID_MAP_NAME(LP),
  189. SET_MOUDLE_ID_MAP_NAME(TDT),
  190. SET_MOUDLE_ID_MAP_NAME(FE),
  191. SET_MOUDLE_ID_MAP_NAME(MD),
  192. SET_MOUDLE_ID_MAP_NAME(MB),
  193. SET_MOUDLE_ID_MAP_NAME(ME),
  194. SET_MOUDLE_ID_MAP_NAME(IMU),
  195. SET_MOUDLE_ID_MAP_NAME(IMP),
  196. SET_MOUDLE_ID_MAP_NAME(GE),
  197. SET_MOUDLE_ID_MAP_NAME(MDCFUSA),
  198. SET_MOUDLE_ID_MAP_NAME(CAMERA),
  199. SET_MOUDLE_ID_MAP_NAME(ASCENDCL),
  200. SET_MOUDLE_ID_MAP_NAME(TEEOS),
  201. SET_MOUDLE_ID_MAP_NAME(SIS),
  202. SET_MOUDLE_ID_MAP_NAME(HSM),
  203. {NULL, -1}};
  204. #endif // SET_MOUDLE_ID_MAP_NAME
  205. /**
  206. * @ingroup slog
  207. * @brief External log interface, which called by modules
  208. */
  209. extern void dlog_init(void);
  210. /**
  211. * @ingroup slog
  212. * @brief dlog_getlevel: get module level
  213. *
  214. * @param [in]moduleId: module id, eg: CCE
  215. * @param [out]enableEvent: 1: enable; 0: disable
  216. * @return: module level(0: debug, 1: info, 2: warning, 3: error, 4: null output)
  217. */
  218. extern int dlog_getlevel(int moduleId, int *enableEvent);
  219. /**
  220. * @ingroup slog
  221. * @brief dlog_error: print error log
  222. *
  223. * @param [in]moduleId: module id, eg: CCE
  224. * @param [in]fmt: log content
  225. */
  226. #define dlog_error(moduleId, fmt, ...) \
  227. do { \
  228. DlogErrorInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  229. } while (0)
  230. /**
  231. * @ingroup slog
  232. * @brief dlog_warn: print warning log
  233. *
  234. * @param [in]moduleId: module id, eg: CCE
  235. * @param [in]fmt: log content
  236. */
  237. #define dlog_warn(moduleId, fmt, ...) \
  238. do { \
  239. DlogWarnInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  240. } while (0)
  241. /**
  242. * @ingroup slog
  243. * @brief dlog_info: print info log
  244. *
  245. * @param [in]moduleId: module id, eg: CCE
  246. * @param [in]fmt: log content
  247. */
  248. #define dlog_info(moduleId, fmt, ...) \
  249. do { \
  250. DlogInfoInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  251. } while (0)
  252. /**
  253. * @ingroup slog
  254. * @brief dlog_debug: print debug log
  255. *
  256. * @param [in]moduleId: module id, eg: CCE
  257. * @param [in]fmt: log content
  258. */
  259. #define dlog_debug(moduleId, fmt, ...) \
  260. do { \
  261. DlogDebugInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  262. } while (0)
  263. /**
  264. * @ingroup slog
  265. * @brief dlog_event: print event log
  266. *
  267. * @param [in]moduleId: module id, eg: CCE
  268. * @param [in]fmt: log content
  269. */
  270. #define dlog_event(moduleId, fmt, ...) \
  271. do { \
  272. DlogEventInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  273. } while (0)
  274. /**
  275. * @ingroup slog
  276. * @brief Dlog: print log, need caller to specify level
  277. *
  278. * @param [in]moduleId: module id, eg: CCE
  279. * @param [in]level(0: debug, 1: info, 2: warning, 3: error, 5: trace, 6: oplog, 16: event)
  280. * @param [in]fmt: log content
  281. */
  282. #define Dlog(moduleId, level, fmt, ...) \
  283. do { \
  284. DlogInner(moduleId, level, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  285. } while (0)
  286. /**
  287. * @ingroup slog
  288. * @brief DlogSub: print log, need caller to specify level and submodule
  289. *
  290. * @param [in]moduleId: module id, eg: CCE
  291. * @param [in]submodule: eg: engine
  292. * @param [in]level(0: debug, 1: info, 2: warning, 3: error, 5: trace, 6: oplog, 16: event)
  293. * @param [in]fmt: log content
  294. */
  295. #define DlogSub(moduleId, submodule, level, fmt, ...) \
  296. do { \
  297. DlogInner(moduleId, level, "[%s:%d][%s]" fmt, __FILE__, __LINE__, submodule, ##__VA_ARGS__); \
  298. } while (0)
  299. /**
  300. * @ingroup slog
  301. * @brief DlogWithKV: print log, need caller to specify level and other paramters
  302. *
  303. * @param [in]moduleId: module id, eg: CCE
  304. * @param [in]level(0: debug, 1: info, 2: warning, 3: error, 5: trace, 6: oplog, 16: event)
  305. * @param [in]pstKVArray: key-value array
  306. * @param [in]kvNum: key-value element num in array
  307. * @param [in]fmt: log content
  308. */
  309. #define DlogWithKV(moduleId, level, pstKVArray, kvNum, fmt, ...) \
  310. do { \
  311. DlogWithKVInner(moduleId, level, pstKVArray, kvNum, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  312. } while (0)
  313. /**
  314. * @ingroup slog
  315. * @brief Internal log interface, other modules are not allowed to call this interface
  316. */
  317. void DlogErrorInner(int moduleId, const char *fmt, ...);
  318. void DlogWarnInner(int moduleId, const char *fmt, ...);
  319. void DlogInfoInner(int moduleId, const char *fmt, ...);
  320. void DlogDebugInner(int moduleId, const char *fmt, ...);
  321. void DlogEventInner(int moduleId, const char *fmt, ...);
  322. void DlogInner(int moduleId, int level, const char *fmt, ...);
  323. void DlogWithKVInner(int moduleId, int level, KeyValue *pstKVArray, int kvNum, const char *fmt, ...);
  324. #ifdef __cplusplus
  325. }
  326. #endif // __cplusplus
  327. #endif // D_SYSLOG_H_

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