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

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