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

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