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.

slog.h 17 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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. #ifndef LINUX
  22. #define LINUX 0
  23. #endif // LINUX
  24. #ifndef OS_TYPE
  25. #define OS_TYPE 0
  26. #endif // OS_TYPE
  27. /**
  28. * @ingroup slog
  29. *
  30. * debug level id
  31. */
  32. #define DLOG_DEBUG 0
  33. /**
  34. * @ingroup slog
  35. *
  36. * info level id
  37. */
  38. #define DLOG_INFO 1
  39. /**
  40. * @ingroup slog
  41. *
  42. * warning level id
  43. */
  44. #define DLOG_WARN 2
  45. /**
  46. * @ingroup slog
  47. *
  48. * error level id
  49. */
  50. #define DLOG_ERROR 3
  51. /**
  52. * @ingroup slog
  53. *
  54. * don't print log
  55. */
  56. #define DLOG_NULL 4
  57. /**
  58. * @ingroup slog
  59. *
  60. * trace log print level id
  61. */
  62. #define DLOG_TRACE 5
  63. /**
  64. * @ingroup slog
  65. *
  66. * oplog log print level id
  67. */
  68. #define DLOG_OPLOG 6
  69. /**
  70. * @ingroup slog
  71. *
  72. * event log print level id
  73. */
  74. #define DLOG_EVENT 0x10
  75. /**
  76. * @ingroup slog
  77. *
  78. * max log length
  79. */
  80. #define MSG_LENGTH 1024
  81. typedef struct tagDCODE {
  82. const char *cName;
  83. int cVal;
  84. } DCODE;
  85. typedef struct tagKV {
  86. char *kname;
  87. char *value;
  88. } KeyValue;
  89. /**
  90. * @ingroup slog
  91. *
  92. * module id
  93. */
  94. enum {
  95. SLOG, /**< Slog */
  96. IDEDD, /**< IDE daemon device */
  97. IDEDH, /**< IDE daemon host */
  98. HCCL, /**< HCCL */
  99. FMK, /**< Framework */
  100. HIAIENGINE, /**< Matrix */
  101. DVPP, /**< DVPP */
  102. RUNTIME, /**< Runtime */
  103. CCE, /**< CCE */
  104. #if (OS_TYPE == LINUX)
  105. HDC, /**< HDC */
  106. #else
  107. HDCL,
  108. #endif // OS_TYPE
  109. DRV, /**< Driver */
  110. MDCFUSION, /**< Mdc fusion */
  111. MDCLOCATION, /**< Mdc location */
  112. MDCPERCEPTION, /**< Mdc perception */
  113. MDCFSM,
  114. MDCCOMMON,
  115. MDCMONITOR,
  116. MDCBSWP, /**< MDC base software platform */
  117. MDCDEFAULT, /**< MDC undefine */
  118. MDCSC, /**< MDC spatial cognition */
  119. MDCPNC,
  120. MLL,
  121. DEVMM, /**< Dlog memory managent */
  122. KERNEL, /**< Kernel */
  123. LIBMEDIA, /**< Libmedia */
  124. CCECPU, /**< ai cpu */
  125. ASCENDDK, /**< AscendDK */
  126. ROS, /**< ROS */
  127. HCCP,
  128. ROCE,
  129. TEFUSION,
  130. PROFILING, /**< Profiling */
  131. DP, /**< Data Preprocess */
  132. APP, /**< User Application */
  133. TS, /**< TS module */
  134. TSDUMP, /**< TSDUMP module */
  135. AICPU, /**< AICPU module */
  136. LP, /**< LP module */
  137. TDT,
  138. FE,
  139. MD,
  140. MB,
  141. ME,
  142. IMU,
  143. IMP,
  144. GE, /**< Fmk */
  145. MDCFUSA,
  146. CAMERA,
  147. ASCENDCL,
  148. TEEOS,
  149. ISP,
  150. SIS,
  151. HSM,
  152. DSS,
  153. PROCMGR, // Process Manager, Base Platform
  154. BBOX,
  155. AIVECTOR,
  156. INVLID_MOUDLE_ID
  157. };
  158. #ifdef MODULE_ID_NAME
  159. /**
  160. * @ingroup slog
  161. *
  162. * set module id to map
  163. */
  164. #define SET_MOUDLE_ID_MAP_NAME(x) \
  165. { #x, x }
  166. static DCODE g_moduleIdName[] = {SET_MOUDLE_ID_MAP_NAME(SLOG),
  167. SET_MOUDLE_ID_MAP_NAME(IDEDD),
  168. SET_MOUDLE_ID_MAP_NAME(IDEDH),
  169. SET_MOUDLE_ID_MAP_NAME(HCCL),
  170. SET_MOUDLE_ID_MAP_NAME(FMK),
  171. SET_MOUDLE_ID_MAP_NAME(HIAIENGINE),
  172. SET_MOUDLE_ID_MAP_NAME(DVPP),
  173. SET_MOUDLE_ID_MAP_NAME(RUNTIME),
  174. SET_MOUDLE_ID_MAP_NAME(CCE),
  175. #if (OS_TYPE == LINUX)
  176. SET_MOUDLE_ID_MAP_NAME(HDC),
  177. #else
  178. SET_MOUDLE_ID_MAP_NAME(HDCL),
  179. #endif // OS_TYPE
  180. SET_MOUDLE_ID_MAP_NAME(DRV),
  181. SET_MOUDLE_ID_MAP_NAME(MDCFUSION),
  182. SET_MOUDLE_ID_MAP_NAME(MDCLOCATION),
  183. SET_MOUDLE_ID_MAP_NAME(MDCPERCEPTION),
  184. SET_MOUDLE_ID_MAP_NAME(MDCFSM),
  185. SET_MOUDLE_ID_MAP_NAME(MDCCOMMON),
  186. SET_MOUDLE_ID_MAP_NAME(MDCMONITOR),
  187. SET_MOUDLE_ID_MAP_NAME(MDCBSWP),
  188. SET_MOUDLE_ID_MAP_NAME(MDCDEFAULT),
  189. SET_MOUDLE_ID_MAP_NAME(MDCSC),
  190. SET_MOUDLE_ID_MAP_NAME(MDCPNC),
  191. SET_MOUDLE_ID_MAP_NAME(MLL),
  192. SET_MOUDLE_ID_MAP_NAME(DEVMM),
  193. SET_MOUDLE_ID_MAP_NAME(KERNEL),
  194. SET_MOUDLE_ID_MAP_NAME(LIBMEDIA),
  195. SET_MOUDLE_ID_MAP_NAME(CCECPU),
  196. SET_MOUDLE_ID_MAP_NAME(ASCENDDK),
  197. SET_MOUDLE_ID_MAP_NAME(ROS),
  198. SET_MOUDLE_ID_MAP_NAME(HCCP),
  199. SET_MOUDLE_ID_MAP_NAME(ROCE),
  200. SET_MOUDLE_ID_MAP_NAME(TEFUSION),
  201. SET_MOUDLE_ID_MAP_NAME(PROFILING),
  202. SET_MOUDLE_ID_MAP_NAME(DP),
  203. SET_MOUDLE_ID_MAP_NAME(APP),
  204. SET_MOUDLE_ID_MAP_NAME(TS),
  205. SET_MOUDLE_ID_MAP_NAME(TSDUMP),
  206. SET_MOUDLE_ID_MAP_NAME(AICPU),
  207. SET_MOUDLE_ID_MAP_NAME(LP),
  208. SET_MOUDLE_ID_MAP_NAME(TDT),
  209. SET_MOUDLE_ID_MAP_NAME(FE),
  210. SET_MOUDLE_ID_MAP_NAME(MD),
  211. SET_MOUDLE_ID_MAP_NAME(MB),
  212. SET_MOUDLE_ID_MAP_NAME(ME),
  213. SET_MOUDLE_ID_MAP_NAME(IMU),
  214. SET_MOUDLE_ID_MAP_NAME(IMP),
  215. SET_MOUDLE_ID_MAP_NAME(GE),
  216. SET_MOUDLE_ID_MAP_NAME(MDCFUSA),
  217. SET_MOUDLE_ID_MAP_NAME(CAMERA),
  218. SET_MOUDLE_ID_MAP_NAME(ASCENDCL),
  219. SET_MOUDLE_ID_MAP_NAME(TEEOS),
  220. SET_MOUDLE_ID_MAP_NAME(ISP),
  221. SET_MOUDLE_ID_MAP_NAME(SIS),
  222. SET_MOUDLE_ID_MAP_NAME(HSM),
  223. SET_MOUDLE_ID_MAP_NAME(DSS),
  224. SET_MOUDLE_ID_MAP_NAME(PROCMGR),
  225. SET_MOUDLE_ID_MAP_NAME(BBOX),
  226. SET_MOUDLE_ID_MAP_NAME(AIVECTOR),
  227. { NULL, -1 }};
  228. #endif // MODULE_ID_NAME
  229. #if (OS_TYPE == LINUX)
  230. /**
  231. * @ingroup slog
  232. * @brief External log interface, which called by modules
  233. */
  234. extern void dlog_init(void);
  235. /**
  236. * @ingroup slog
  237. * @brief dlog_getlevel: get module loglevel and enableEvent
  238. *
  239. * @param [in]moduleId: moudule id(see slog.h, eg: CCE), others: invalid
  240. * @param [out]enableEvent: 1: enable; 0: disable
  241. * @return: module level(0: debug, 1: info, 2: warning, 3: error, 4: null output)
  242. */
  243. extern int dlog_getlevel(int moduleId, int *enableEvent);
  244. /**
  245. * @ingroup slog
  246. * @brief dlog_setlevel: set module loglevel and enableEvent
  247. *
  248. * @param [in]moduleId: moudule id(see slog.h, eg: CCE), -1: all modules, others: invalid
  249. * @param [in]level: log level(0: debug, 1: info, 2: warning, 3: error, 4: null output)
  250. * @param [in]enableEvent: 1: enable; 0: disable, others:invalid
  251. * @return: 0: SUCCEED, others: FAILED
  252. */
  253. extern int dlog_setlevel(int moduleId, int level, int enableEvent);
  254. /**
  255. * @ingroup slog
  256. * @brief CheckLogLevel: check module level enable or not
  257. * users no need to call it because all dlog interface(include inner interface) has already called
  258. *
  259. * @param [in]moduleId: module id, eg: CCE
  260. * @param [in]logLevel: eg: DLOG_EVENT/DLOG_ERROR/DLOG_WARN/DLOG_INFO/DLOG_DEBUG
  261. * @return: 1:enable, 0:disable
  262. */
  263. extern int CheckLogLevel(int moduleId, int logLevel);
  264. /**
  265. * @ingroup slog
  266. * @brief dlog_error: print error log
  267. *
  268. * @param [in]moduleId: module id, eg: CCE
  269. * @param [in]fmt: log content
  270. */
  271. #define dlog_error(moduleId, fmt, ...) \
  272. do { \
  273. DlogErrorInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  274. } while (0)
  275. /**
  276. * @ingroup slog
  277. * @brief dlog_warn: print warning log
  278. * call CheckLogLevel in advance to optimize performance, call interface with fmt input take time
  279. *
  280. * @param [in]moduleId: module id, eg: CCE
  281. * @param [in]fmt: log content
  282. */
  283. #ifdef _SKIP_TOOLCHAIN_LOG_FUNC_ABCD
  284. #define dlog_warn(moduleId, fmt, ...) \
  285. do { \
  286. DlogWarnInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  287. } while (0)
  288. #else
  289. #define dlog_warn(moduleId, fmt, ...) \
  290. do { \
  291. if(CheckLogLevel(moduleId, DLOG_WARN) == 1) { \
  292. DlogWarnInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  293. } \
  294. } while (0)
  295. #endif
  296. /**
  297. * @ingroup slog
  298. * @brief dlog_info: print info log
  299. * call CheckLogLevel in advance to optimize performance, call interface with fmt input take time
  300. *
  301. * @param [in]moduleId: module id, eg: CCE
  302. * @param [in]fmt: log content
  303. */
  304. #ifdef _SKIP_TOOLCHAIN_LOG_FUNC_ABCD
  305. #define dlog_info(moduleId, fmt, ...) \
  306. do { \
  307. DlogInfoInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  308. } while (0)
  309. #else
  310. #define dlog_info(moduleId, fmt, ...) \
  311. do { \
  312. if(CheckLogLevel(moduleId, DLOG_INFO) == 1) { \
  313. DlogInfoInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  314. } \
  315. } while (0)
  316. #endif
  317. /**
  318. * @ingroup slog
  319. * @brief dlog_debug: print debug log
  320. * call CheckLogLevel in advance to optimize performance, call interface with fmt input take time
  321. *
  322. * @param [in]moduleId: module id, eg: CCE
  323. * @param [in]fmt: log content
  324. */
  325. #ifdef _SKIP_TOOLCHAIN_LOG_FUNC_ABCD
  326. #define dlog_debug(moduleId, fmt, ...) \
  327. do { \
  328. DlogDebugInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  329. } while (0)
  330. #else
  331. #define dlog_debug(moduleId, fmt, ...) \
  332. do { \
  333. if(CheckLogLevel(moduleId, DLOG_DEBUG) == 1) { \
  334. DlogDebugInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  335. } \
  336. } while (0)
  337. #endif
  338. /**
  339. * @ingroup slog
  340. * @brief dlog_event: print event log
  341. *
  342. * @param [in]moduleId: module id, eg: CCE
  343. * @param [in]fmt: log content
  344. */
  345. #define dlog_event(moduleId, fmt, ...) \
  346. do { \
  347. DlogEventInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  348. } while (0)
  349. /**
  350. * @ingroup slog
  351. * @brief Dlog: print log, need caller to specify level
  352. *
  353. * @param [in]moduleId: module id, eg: CCE
  354. * @param [in]level(0: debug, 1: info, 2: warning, 3: error, 5: trace, 6: oplog, 16: event)
  355. * @param [in]fmt: log content
  356. */
  357. #ifdef _SKIP_TOOLCHAIN_LOG_FUNC_ABCD
  358. #define Dlog(moduleId, level, fmt, ...) \
  359. do { \
  360. DlogInner(moduleId, level, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  361. } while (0)
  362. #else
  363. #define Dlog(moduleId, level, fmt, ...) \
  364. do { \
  365. if(CheckLogLevel(moduleId, level) == 1) { \
  366. DlogInner(moduleId, level, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  367. } \
  368. } while (0)
  369. #endif
  370. /**
  371. * @ingroup slog
  372. * @brief DlogSub: print log, need caller to specify level and submodule
  373. *
  374. * @param [in]moduleId: module id, eg: CCE
  375. * @param [in]submodule: eg: engine
  376. * @param [in]level(0: debug, 1: info, 2: warning, 3: error, 5: trace, 6: oplog, 16: event)
  377. * @param [in]fmt: log content
  378. */
  379. #ifdef _SKIP_TOOLCHAIN_LOG_FUNC_ABCD
  380. #define DlogSub(moduleId, submodule, level, fmt, ...) \
  381. do { \
  382. DlogInner(moduleId, level, "[%s:%d][%s]" fmt, __FILE__, __LINE__, submodule, ##__VA_ARGS__); \
  383. } while (0)
  384. #else
  385. #define DlogSub(moduleId, submodule, level, fmt, ...) \
  386. do { \
  387. if(CheckLogLevel(moduleId, level) == 1) { \
  388. DlogInner(moduleId, level, "[%s:%d][%s]" fmt, __FILE__, __LINE__, submodule, ##__VA_ARGS__); \
  389. } \
  390. } while (0)
  391. #endif
  392. /**
  393. * @ingroup slog
  394. * @brief DlogWithKV: print log, need caller to specify level and other paramters
  395. *
  396. * @param [in]moduleId: module id, eg: CCE
  397. * @param [in]level(0: debug, 1: info, 2: warning, 3: error, 5: trace, 6: oplog, 16: event)
  398. * @param [in]pstKVArray: key-value array
  399. * @param [in]kvNum: key-value element num in array
  400. * @param [in]fmt: log content
  401. */
  402. #ifdef _SKIP_TOOLCHAIN_LOG_FUNC_ABCD
  403. #define DlogWithKV(moduleId, level, pstKVArray, kvNum, fmt, ...) \
  404. do { \
  405. DlogWithKVInner(moduleId, level, pstKVArray, kvNum, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  406. } while (0)
  407. #else
  408. #define DlogWithKV(moduleId, level, pstKVArray, kvNum, fmt, ...) \
  409. do { \
  410. if(CheckLogLevel(moduleId, level) == 1) { \
  411. DlogWithKVInner(moduleId, level, pstKVArray, kvNum, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  412. } \
  413. } while (0)
  414. #endif
  415. /**
  416. * @ingroup slog
  417. * @brief Internal log interface, other modules are not allowed to call this interface
  418. */
  419. void DlogErrorInner(int moduleId, const char *fmt, ...);
  420. void DlogWarnInner(int moduleId, const char *fmt, ...);
  421. void DlogInfoInner(int moduleId, const char *fmt, ...);
  422. void DlogDebugInner(int moduleId, const char *fmt, ...);
  423. void DlogEventInner(int moduleId, const char *fmt, ...);
  424. void DlogInner(int moduleId, int level, const char *fmt, ...);
  425. void DlogWithKVInner(int moduleId, int level, KeyValue *pstKVArray, int kvNum, const char *fmt, ...);
  426. #else
  427. _declspec(dllexport) void dlog_init(void);
  428. _declspec(dllexport) int dlog_getlevel(int moduleId, int *enableEvent);
  429. #endif // OS_TYPE
  430. #ifdef __cplusplus
  431. }
  432. #endif // __cplusplus
  433. #endif // D_SYSLOG_H_

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