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 12 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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. INVLID_MOUDLE_ID
  156. };
  157. #ifdef MODULE_ID_NAME
  158. /**
  159. * @ingroup slog
  160. *
  161. * set module id to map
  162. */
  163. #define SET_MOUDLE_ID_MAP_NAME(x) \
  164. { #x, x }
  165. static DCODE g_moduleIdName[] = {SET_MOUDLE_ID_MAP_NAME(SLOG),
  166. SET_MOUDLE_ID_MAP_NAME(IDEDD),
  167. SET_MOUDLE_ID_MAP_NAME(IDEDH),
  168. SET_MOUDLE_ID_MAP_NAME(HCCL),
  169. SET_MOUDLE_ID_MAP_NAME(FMK),
  170. SET_MOUDLE_ID_MAP_NAME(HIAIENGINE),
  171. SET_MOUDLE_ID_MAP_NAME(DVPP),
  172. SET_MOUDLE_ID_MAP_NAME(RUNTIME),
  173. SET_MOUDLE_ID_MAP_NAME(CCE),
  174. #if (OS_TYPE == LINUX)
  175. SET_MOUDLE_ID_MAP_NAME(HDC),
  176. #else
  177. SET_MOUDLE_ID_MAP_NAME(HDCL),
  178. #endif // OS_TYPE
  179. SET_MOUDLE_ID_MAP_NAME(DRV),
  180. SET_MOUDLE_ID_MAP_NAME(MDCFUSION),
  181. SET_MOUDLE_ID_MAP_NAME(MDCLOCATION),
  182. SET_MOUDLE_ID_MAP_NAME(MDCPERCEPTION),
  183. SET_MOUDLE_ID_MAP_NAME(MDCFSM),
  184. SET_MOUDLE_ID_MAP_NAME(MDCCOMMON),
  185. SET_MOUDLE_ID_MAP_NAME(MDCMONITOR),
  186. SET_MOUDLE_ID_MAP_NAME(MDCBSWP),
  187. SET_MOUDLE_ID_MAP_NAME(MDCDEFAULT),
  188. SET_MOUDLE_ID_MAP_NAME(MDCSC),
  189. SET_MOUDLE_ID_MAP_NAME(MDCPNC),
  190. SET_MOUDLE_ID_MAP_NAME(MLL),
  191. SET_MOUDLE_ID_MAP_NAME(DEVMM),
  192. SET_MOUDLE_ID_MAP_NAME(KERNEL),
  193. SET_MOUDLE_ID_MAP_NAME(LIBMEDIA),
  194. SET_MOUDLE_ID_MAP_NAME(CCECPU),
  195. SET_MOUDLE_ID_MAP_NAME(ASCENDDK),
  196. SET_MOUDLE_ID_MAP_NAME(ROS),
  197. SET_MOUDLE_ID_MAP_NAME(HCCP),
  198. SET_MOUDLE_ID_MAP_NAME(ROCE),
  199. SET_MOUDLE_ID_MAP_NAME(TEFUSION),
  200. SET_MOUDLE_ID_MAP_NAME(PROFILING),
  201. SET_MOUDLE_ID_MAP_NAME(DP),
  202. SET_MOUDLE_ID_MAP_NAME(APP),
  203. SET_MOUDLE_ID_MAP_NAME(TS),
  204. SET_MOUDLE_ID_MAP_NAME(TSDUMP),
  205. SET_MOUDLE_ID_MAP_NAME(AICPU),
  206. SET_MOUDLE_ID_MAP_NAME(LP),
  207. SET_MOUDLE_ID_MAP_NAME(TDT),
  208. SET_MOUDLE_ID_MAP_NAME(FE),
  209. SET_MOUDLE_ID_MAP_NAME(MD),
  210. SET_MOUDLE_ID_MAP_NAME(MB),
  211. SET_MOUDLE_ID_MAP_NAME(ME),
  212. SET_MOUDLE_ID_MAP_NAME(IMU),
  213. SET_MOUDLE_ID_MAP_NAME(IMP),
  214. SET_MOUDLE_ID_MAP_NAME(GE),
  215. SET_MOUDLE_ID_MAP_NAME(MDCFUSA),
  216. SET_MOUDLE_ID_MAP_NAME(CAMERA),
  217. SET_MOUDLE_ID_MAP_NAME(ASCENDCL),
  218. SET_MOUDLE_ID_MAP_NAME(TEEOS),
  219. SET_MOUDLE_ID_MAP_NAME(ISP),
  220. SET_MOUDLE_ID_MAP_NAME(SIS),
  221. SET_MOUDLE_ID_MAP_NAME(HSM),
  222. SET_MOUDLE_ID_MAP_NAME(DSS),
  223. SET_MOUDLE_ID_MAP_NAME(PROCMGR),
  224. SET_MOUDLE_ID_MAP_NAME(BBOX),
  225. { NULL, -1 }};
  226. #endif // MODULE_ID_NAME
  227. #if (OS_TYPE == LINUX)
  228. /**
  229. * @ingroup slog
  230. * @brief External log interface, which called by modules
  231. */
  232. extern void dlog_init(void);
  233. /**
  234. * @ingroup slog
  235. * @brief dlog_getlevel: get module level
  236. *
  237. * @param [in]moduleId: module id, eg: CCE
  238. * @param [out]enableEvent: 1: enable; 0: disable
  239. * @return: module level(0: debug, 1: info, 2: warning, 3: error, 4: null output)
  240. */
  241. extern int dlog_getlevel(int moduleId, int *enableEvent);
  242. /**
  243. * @ingroup slog
  244. * @brief CheckLogLevel: check module level enable or not
  245. *
  246. * @param [in]moduleId: module id, eg: CCE
  247. * @param [in]logLevel: eg: DLOG_EVENT/DLOG_ERROR/DLOG_WARN/DLOG_INFO/DLOG_DEBUG
  248. * @return: 1:enable, 0:disable
  249. */
  250. extern int CheckLogLevel(int moduleId, int logLevel);
  251. /**
  252. * @ingroup slog
  253. * @brief dlog_error: print error log
  254. *
  255. * @param [in]moduleId: module id, eg: CCE
  256. * @param [in]fmt: log content
  257. */
  258. #define dlog_error(moduleId, fmt, ...) \
  259. do { \
  260. DlogErrorInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  261. } while (0)
  262. /**
  263. * @ingroup slog
  264. * @brief dlog_warn: print warning log
  265. *
  266. * @param [in]moduleId: module id, eg: CCE
  267. * @param [in]fmt: log content
  268. */
  269. #define dlog_warn(moduleId, fmt, ...) \
  270. do { \
  271. DlogWarnInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  272. } while (0)
  273. /**
  274. * @ingroup slog
  275. * @brief dlog_info: print info log
  276. *
  277. * @param [in]moduleId: module id, eg: CCE
  278. * @param [in]fmt: log content
  279. */
  280. #define dlog_info(moduleId, fmt, ...) \
  281. do { \
  282. DlogInfoInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  283. } while (0)
  284. /**
  285. * @ingroup slog
  286. * @brief dlog_debug: print debug log
  287. *
  288. * @param [in]moduleId: module id, eg: CCE
  289. * @param [in]fmt: log content
  290. */
  291. #define dlog_debug(moduleId, fmt, ...) \
  292. do { \
  293. DlogDebugInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  294. } while (0)
  295. /**
  296. * @ingroup slog
  297. * @brief dlog_event: print event log
  298. *
  299. * @param [in]moduleId: module id, eg: CCE
  300. * @param [in]fmt: log content
  301. */
  302. #define dlog_event(moduleId, fmt, ...) \
  303. do { \
  304. DlogEventInner(moduleId, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  305. } while (0)
  306. /**
  307. * @ingroup slog
  308. * @brief Dlog: print log, need caller to specify level
  309. *
  310. * @param [in]moduleId: module id, eg: CCE
  311. * @param [in]level(0: debug, 1: info, 2: warning, 3: error, 5: trace, 6: oplog, 16: event)
  312. * @param [in]fmt: log content
  313. */
  314. #define Dlog(moduleId, level, fmt, ...) \
  315. do { \
  316. DlogInner(moduleId, level, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  317. } while (0)
  318. /**
  319. * @ingroup slog
  320. * @brief DlogSub: print log, need caller to specify level and submodule
  321. *
  322. * @param [in]moduleId: module id, eg: CCE
  323. * @param [in]submodule: eg: engine
  324. * @param [in]level(0: debug, 1: info, 2: warning, 3: error, 5: trace, 6: oplog, 16: event)
  325. * @param [in]fmt: log content
  326. */
  327. #define DlogSub(moduleId, submodule, level, fmt, ...) \
  328. do { \
  329. DlogInner(moduleId, level, "[%s:%d][%s]" fmt, __FILE__, __LINE__, submodule, ##__VA_ARGS__); \
  330. } while (0)
  331. /**
  332. * @ingroup slog
  333. * @brief DlogWithKV: print log, need caller to specify level and other paramters
  334. *
  335. * @param [in]moduleId: module id, eg: CCE
  336. * @param [in]level(0: debug, 1: info, 2: warning, 3: error, 5: trace, 6: oplog, 16: event)
  337. * @param [in]pstKVArray: key-value array
  338. * @param [in]kvNum: key-value element num in array
  339. * @param [in]fmt: log content
  340. */
  341. #define DlogWithKV(moduleId, level, pstKVArray, kvNum, fmt, ...) \
  342. do { \
  343. DlogWithKVInner(moduleId, level, pstKVArray, kvNum, "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
  344. } while (0)
  345. /**
  346. * @ingroup slog
  347. * @brief Internal log interface, other modules are not allowed to call this interface
  348. */
  349. void DlogErrorInner(int moduleId, const char *fmt, ...);
  350. void DlogWarnInner(int moduleId, const char *fmt, ...);
  351. void DlogInfoInner(int moduleId, const char *fmt, ...);
  352. void DlogDebugInner(int moduleId, const char *fmt, ...);
  353. void DlogEventInner(int moduleId, const char *fmt, ...);
  354. void DlogInner(int moduleId, int level, const char *fmt, ...);
  355. void DlogWithKVInner(int moduleId, int level, KeyValue *pstKVArray, int kvNum, const char *fmt, ...);
  356. #else
  357. _declspec(dllexport) void dlog_init(void);
  358. _declspec(dllexport) int dlog_getlevel(int moduleId, int *enableEvent);
  359. #endif // OS_TYPE
  360. #ifdef __cplusplus
  361. }
  362. #endif // __cplusplus
  363. #endif // D_SYSLOG_H_

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