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.

rt_mem_queue.h 19 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /*
  2. * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
  3. * Description: mbuf and queue interface
  4. */
  5. #ifndef CCE_RUNTIME_RT_MEM_QUEUE_H
  6. #define CCE_RUNTIME_RT_MEM_QUEUE_H
  7. #include "base.h"
  8. #if defined(__cplusplus)
  9. extern "C" {
  10. #endif
  11. #define RT_MQ_MAX_NAME_LEN 128 // same as driver's
  12. #define RT_MQ_DEPTH_MIN 2U
  13. #define RT_MQ_MODE_PUSH 1
  14. #define RT_MQ_MODE_PULL 2
  15. #define RT_MQ_MODE_DEFAULT RT_MQ_MODE_PUSH
  16. #define RT_EVENT_SUMMARY_RSV 4
  17. #define RT_EVENT_MAX_MSG_LEN 128
  18. typedef struct tagMemQueueInfo {
  19. int32_t id;
  20. int32_t size;
  21. uint32_t depth;
  22. int32_t status;
  23. } rtMemQueueInfo_t;
  24. typedef struct tagMemQueueAttr {
  25. char_t name[RT_MQ_MAX_NAME_LEN];
  26. uint32_t depth;
  27. uint32_t workMode;
  28. uint32_t flowCtrlDropTime;
  29. bool flowCtrlFlag;
  30. bool overWriteFlag;
  31. } rtMemQueueAttr_t;
  32. typedef struct tagMemQueueShareAttr {
  33. uint32_t manage : 1;
  34. uint32_t read : 1;
  35. uint32_t write : 1;
  36. uint32_t rsv : 29;
  37. } rtMemQueueShareAttr_t;
  38. typedef struct tagMemQueueBuffInfo {
  39. void *addr;
  40. size_t len;
  41. } rtMemQueueBuffInfo;
  42. typedef struct tagMemQueueBuff {
  43. void *contextAddr;
  44. size_t contextLen;
  45. rtMemQueueBuffInfo *buffInfo;
  46. uint32_t buffCount;
  47. } rtMemQueueBuff_t;
  48. typedef enum tagMemQueueQueryCmd {
  49. RT_MQ_QUERY_QUE_ATTR_OF_CUR_PROC = 0, // input is qid(4bytes), output is rtMemQueueShareAttr_t
  50. RT_MQ_QUERY_QUES_OF_CUR_PROC = 1,
  51. RT_MQ_QUERY_CMD_MAX = 2
  52. } rtMemQueueQueryCmd_t;
  53. #define RT_MQ_EVENT_QS_MSG 27 // same as driver's
  54. #define RT_MQ_SCHED_PRIORITY_LEVEL0 0 // same as driver's
  55. #define RT_MQ_SCHED_PRIORITY_LEVEL1 1
  56. #define RT_MQ_SCHED_PRIORITY_LEVEL2 2
  57. #define RT_MQ_SCHED_PRIORITY_LEVEL3 3
  58. #define RT_MQ_SCHED_PRIORITY_LEVEL4 4
  59. #define RT_MQ_SCHED_PRIORITY_LEVEL5 5
  60. #define RT_MQ_SCHED_PRIORITY_LEVEL6 6
  61. #define RT_MQ_SCHED_PRIORITY_LEVEL7 7
  62. /* Events can be released between different systems. This parameter specifies the destination type of events
  63. to be released. The destination type is defined based on the CPU type of the destination system. */
  64. #define RT_MQ_DST_ENGINE_ACPU_DEVICE 0 // device AICPU, same as driver's
  65. #define RT_MQ_DST_ENGINE_ACPU_HOST 1 // Host AICPU
  66. #define RT_MQ_DST_ENGINE_CCPU_DEVICE 2 // device CtrlCPU
  67. #define RT_MQ_DST_ENGINE_CCPU_HOST 3 // Host CtrlCPU
  68. #define RT_MQ_DST_ENGINE_DCPU_DEVICE 4 // device DataCPU
  69. #define RT_MQ_DST_ENGINE_TS_CPU 5 // device TS CPU
  70. #define RT_MQ_DST_ENGINE_DVPP_CPU 6 // device DVPP CPU
  71. #define RT_MQ_SCHED_EVENT_QS_MSG 25 // same as driver's EVENT_QS_MSG
  72. /* When the destination engine is AICPU, select a policy.
  73. ONLY: The command is executed only on the local AICPU.
  74. FIRST: The local AICPU is preferentially executed. If the local AICPU is busy, the remote AICPU can be used. */
  75. #define RT_SCHEDULE_POLICY_ONLY 0 // same as driver's schedule_policy
  76. #define RT_SCHEDULE_POLICY_FIRST 1 // same as driver's schedule_policy
  77. typedef struct tagEschedEventSummary {
  78. int32_t pid; // dst PID
  79. uint32_t grpId;
  80. int32_t eventId; // only RT_MQ_SCHED_EVENT_QS_MSG is supported
  81. uint32_t subeventId;
  82. uint32_t msgLen;
  83. char_t *msg;
  84. uint32_t dstEngine; // dst system cpu type
  85. int32_t policy; // RT_SCHEDULE_POLICY_ONLY or RT_SCHEDULE_POLICY_FIRST
  86. } rtEschedEventSummary_t;
  87. typedef struct tagEschedEventReply {
  88. char_t *buf;
  89. uint32_t bufLen;
  90. uint32_t replyLen; // output, ack msg len, same with msgLen in halEschedAckEvent
  91. } rtEschedEventReply_t;
  92. #define RT_DEV_PROCESS_CP1 0
  93. #define RT_DEV_PROCESS_CP2 1
  94. #define RT_DEV_PROCESS_DEV_ONLY 2
  95. #define RT_DEV_PROCESS_QS 3
  96. #define RT_DEV_PROCESS_SIGN_LENGTH 49
  97. typedef struct tagBindHostpidInfo {
  98. int32_t hostPid;
  99. uint32_t vfid;
  100. uint32_t chipId;
  101. int32_t cpType; // type of custom-process, see RT_DEV_PROCESS_XXX
  102. } rtBindHostpidInfo_t;
  103. #define RT_MEM_BUFF_MAX_CFG_NUM 64
  104. typedef struct {
  105. uint32_t cfgId; // cfg id, start from 0
  106. uint32_t totalSize; // one zone total size
  107. uint32_t blkSize; // blk size, 2^n (0, 2M]
  108. uint32_t maxBufSize; // max size can alloc from zone
  109. uint32_t pageType; // page type, small page / huge page
  110. int32_t elasticEnable; // elastic enable
  111. int32_t elasticRate;
  112. int32_t elasticRateMax;
  113. int32_t elasticHighLevel;
  114. int32_t elasticLowLevel;
  115. } rtMemZoneCfg_t;
  116. typedef struct {
  117. rtMemZoneCfg_t cfg[RT_MEM_BUFF_MAX_CFG_NUM];
  118. }rtMemBuffCfg_t;
  119. typedef enum rt_queue_work_mode {
  120. RT_QUEUE_MODE_PUSH = 1,
  121. RT_QUEUE_MODE_PULL,
  122. } RT_QUEUE_WORK_MODE;
  123. typedef void *rtMbufPtr_t;
  124. typedef enum rtEventIdType {
  125. RT_EVENT_RANDOM_KERNEL, /* Random operator event */
  126. RT_EVENT_DVPP_MSG, /* operator events commited by DVPP */
  127. RT_EVENT_FR_MSG, /* operator events commited by Feature retrieves */
  128. RT_EVENT_TS_HWTS_KERNEL, /* operator events commited by ts/hwts */
  129. RT_EVENT_AICPU_MSG, /* aicpu activates its own stream events */
  130. RT_EVENT_TS_CTRL_MSG, /* controls message events of TS */
  131. RT_EVENT_QUEUE_ENQUEUE, /* entry event of Queue(consumer) */
  132. RT_EVENT_QUEUE_FULL_TO_NOT_FULL, /* full to non-full events of Queue(producers) */
  133. RT_EVENT_QUEUE_EMPTY_TO_NOT_EMPTY, /* empty to non-empty event of Queue(consumer) */
  134. RT_EVENT_TDT_ENQUEUE, /* data entry event of TDT */
  135. RT_EVENT_TIMER, /* ros timer */
  136. RT_EVENT_HCFI_SCHED_MSG, /* scheduling events of HCFI */
  137. RT_EVENT_HCFI_EXEC_MSG, /* performs the event of HCFI */
  138. RT_EVENT_ROS_MSG_LEVEL0,
  139. RT_EVENT_ROS_MSG_LEVEL1,
  140. RT_EVENT_ROS_MSG_LEVEL2,
  141. RT_EVENT_ACPU_MSG_TYPE0,
  142. RT_EVENT_ACPU_MSG_TYPE1,
  143. RT_EVENT_ACPU_MSG_TYPE2,
  144. RT_EVENT_CCPU_CTRL_MSG,
  145. RT_EVENT_SPLIT_KERNEL,
  146. RT_EVENT_DVPP_MPI_MSG,
  147. RT_EVENT_CDQ_MSG,
  148. /* Add a new event here */
  149. RT_EVENT_TEST, /* Reserve for test */
  150. RT_EVENT_MAX_NUM
  151. } rtEventIdType_t;
  152. typedef enum rtGroupType {
  153. /* Bound to a AICPU, multiple threads can be woken up simultaneously within a group */
  154. RT_GRP_TYPE_BIND_DP_CPU = 1,
  155. RT_GRP_TYPE_BIND_CP_CPU, /* Bind to the control CPU */
  156. RT_GRP_TYPE_BIND_DP_CPU_EXCLUSIVE /* Bound to a AICPU, intra-group threads are mutex awakened */
  157. } rtGroupType_t;
  158. typedef struct tagInitFlowGwInfo {
  159. const char_t *groupName;
  160. uint64_t schedPolicy;
  161. uint64_t reschedInterval;
  162. char_t rsv[128];
  163. } rtInitFlowGwInfo_t;
  164. /**
  165. * @ingroup rt_mem_queue
  166. * @brief init queue schedule
  167. * @param [in] devId the logical device id
  168. * @param [in] grpName the name of group, can be nullptr
  169. * @return RT_ERROR_NONE for ok
  170. */
  171. RTS_API rtError_t rtMemQueueInitQS(int32_t devId, const char_t *grpName);
  172. /**
  173. * @ingroup rt_mem_queue
  174. * @brief init flow gateway
  175. * @param [in] devId the logical device id
  176. * @param [in] initInfo Initialization parameters
  177. * @return RT_ERROR_NONE for ok
  178. */
  179. RTS_API rtError_t rtMemQueueInitFlowGw(int32_t devId, const rtInitFlowGwInfo_t * const initInfo);
  180. /**
  181. * @ingroup rt_mem_queue
  182. * @brief create mbuf queue
  183. * @param [in] devId the logical device id
  184. * @param [in] queAttr attribute of queue
  185. * @param [out] qid queue id
  186. * @return RT_ERROR_NONE for ok
  187. */
  188. RTS_API rtError_t rtMemQueueCreate(int32_t devId, const rtMemQueueAttr_t *queAttr, uint32_t *qid);
  189. /**
  190. * @ingroup rt_mem_queue
  191. * @brief destroy mbuf queue
  192. * @param [in] devId the logical device id
  193. * @param [in] qid queue id
  194. * @return RT_ERROR_NONE for ok
  195. */
  196. RTS_API rtError_t rtMemQueueDestroy(int32_t devId, uint32_t qid);
  197. /**
  198. * @ingroup rt_mem_queue
  199. * @brief destroy mbuf queue init
  200. * @param [in] devId the logical device id
  201. * @return RT_ERROR_NONE for ok
  202. */
  203. RTS_API rtError_t rtMemQueueInit(int32_t devId);
  204. /**
  205. * @ingroup rt_mem_queue
  206. * @brief enqueue memBuf
  207. * @param [in] devId the logical device id
  208. * @param [in] qid queue id
  209. * @param [in] memBuf enqueue memBuf
  210. * @return RT_ERROR_NONE for ok
  211. */
  212. RTS_API rtError_t rtMemQueueEnQueue(int32_t devId, uint32_t qid, void *memBuf);
  213. /**
  214. * @ingroup rt_mem_queue
  215. * @brief dequeue memBuf
  216. * @param [in] devId the logical device id
  217. * @param [in] qid queue id
  218. * @param [out] memBuf dequeue memBuf
  219. * @return RT_ERROR_NONE for ok
  220. */
  221. RTS_API rtError_t rtMemQueueDeQueue(int32_t devId, uint32_t qid, void **memBuf);
  222. /**
  223. * @ingroup rt_mem_queue
  224. * @brief enqueu peek
  225. * @param [in] devId the logical device id
  226. * @param [in] qid queue id
  227. * @param [out] bufLen length of mbuf in queue
  228. * @param [in] timeout peek timeout (ms), -1: wait all the time until peeking success
  229. * @return RT_ERROR_NONE for ok
  230. */
  231. RTS_API rtError_t rtMemQueuePeek(int32_t devId, uint32_t qid, size_t *bufLen, int32_t timeout);
  232. /**
  233. * @ingroup rt_mem_queue
  234. * @brief enqueu buff
  235. * @param [in] devId the logical device id
  236. * @param [in] qid queue id
  237. * @param [in] inBuf enqueue buff
  238. * @param [in] timeout enqueue timeout (ms), -1: wait all the time until enqueue success
  239. * @return RT_ERROR_NONE for ok
  240. */
  241. RTS_API rtError_t rtMemQueueEnQueueBuff(int32_t devId, uint32_t qid, rtMemQueueBuff_t *inBuf, int32_t timeout);
  242. /**
  243. * @ingroup rt_mem_queue
  244. * @brief enqueu buff
  245. * @param [in] devId the logical device id
  246. * @param [in] qid queue id
  247. * @param [out] outBuf dequeue buff
  248. * @param [in] timeout dequeue timeout (ms), -1: wait all the time until dequeue success
  249. * @return RT_ERROR_NONE for ok
  250. */
  251. RTS_API rtError_t rtMemQueueDeQueueBuff(int32_t devId, uint32_t qid, rtMemQueueBuff_t *outBuf, int32_t timeout);
  252. /**
  253. * @ingroup rt_mem_queue
  254. * @brief query current queue info
  255. * @param [in] devId the logical device id
  256. * @param [in] qid queue id
  257. * @param [out] queInfo current queue info
  258. * @return RT_ERROR_NONE for ok
  259. */
  260. RTS_API rtError_t rtMemQueueQueryInfo(int32_t devId, uint32_t qid, rtMemQueueInfo_t *queInfo);
  261. /**
  262. * @ingroup rt_mem_queue
  263. * @brief query queue status
  264. * @param [in] devId: the logical device id
  265. * @param [in] cmd: query cmd
  266. * @param [in] inBuff: input buff
  267. * @param [in] inLen: the length of input
  268. * @param [in|out] outBuff: output buff
  269. * @param [in|out] outLen: the length of output
  270. * @return RT_ERROR_NONE for ok
  271. */
  272. RTS_API rtError_t rtMemQueueQuery(int32_t devId, rtMemQueueQueryCmd_t cmd, const void *inBuff, uint32_t inLen,
  273. void *outBuff, uint32_t *outLen);
  274. /**
  275. * @ingroup rt_mem_queue
  276. * @brief grant queue
  277. * @param [in] devId: logic devid
  278. * @param [in] qid: queue id
  279. * @param [in] pid: pid
  280. * @param [in] attr: queue share attr
  281. * @return RT_ERROR_NONE for ok
  282. */
  283. RTS_API rtError_t rtMemQueueGrant(int32_t devId, uint32_t qid, int32_t pid, rtMemQueueShareAttr_t *attr);
  284. /**
  285. * @ingroup rt_mem_queue
  286. * @brief attach queue
  287. * @param [in] devId: logic devid
  288. * @param [in] qid: queue id
  289. * @param [in] timeOut: timeOut
  290. * @return RT_ERROR_NONE for ok
  291. */
  292. RTS_API rtError_t rtMemQueueAttach(int32_t devId, uint32_t qid, int32_t timeOut);
  293. /**
  294. * @ingroup rt_mem_queue
  295. * @brief Commit the event to a specific process
  296. * @param [in] devId: logic devid
  297. * @param [in] evt: event summary info
  298. * @param [out] ack: event reply info
  299. * @return RT_ERROR_NONE for ok
  300. */
  301. RTS_API rtError_t rtEschedSubmitEventSync(int32_t devId, rtEschedEventSummary_t *evt,
  302. rtEschedEventReply_t *ack);
  303. /**
  304. * @ingroup rt_mem_queue
  305. * @brief query device proccess id
  306. * @param [in] info: see struct rtBindHostpidInfo_t
  307. * @param [out] devPid: device proccess id
  308. * @return RT_ERROR_NONE for ok
  309. */
  310. RTS_API rtError_t rtQueryDevPid(rtBindHostpidInfo_t *info, int32_t *devPid);
  311. /**
  312. * @ingroup rt_mem_queue
  313. * @brief device buff init
  314. * @param [in] cfg, init cfg
  315. * @return RT_ERROR_NONE for ok
  316. */
  317. RTS_API rtError_t rtMbufInit(rtMemBuffCfg_t *cfg);
  318. /**
  319. * @ingroup rt_mem_queue
  320. * @brief alloc buff
  321. * @param [out] memBuf: buff addr alloced
  322. * @param [in] size: The amount of memory space requested
  323. * @return RT_ERROR_NONE for ok
  324. */
  325. RTS_API rtError_t rtMbufAlloc(rtMbufPtr_t *memBuf, uint64_t size);
  326. /**
  327. * @ingroup rt_mem_queue
  328. * @brief free buff
  329. * @param [in] memBuf: buff addr to be freed
  330. * @return RT_ERROR_NONE for ok
  331. */
  332. RTS_API rtError_t rtMbufFree(rtMbufPtr_t memBuf);
  333. /**
  334. * @ingroup rt_mem_queue
  335. * @brief set Data len of Mbuf
  336. * @param [in] memBuf: Mbuf addr
  337. * @param [in] len: data len
  338. * @return RT_ERROR_NONE for success, others for fail
  339. */
  340. RTS_API rtError_t rtMbufSetDataLen(rtMbufPtr_t memBuf, uint64_t len);
  341. /**
  342. * @ingroup rt_mem_queue
  343. * @brief get Data addr of Mbuf
  344. * @param [in] memBuf: Mbuf addr
  345. * @param [out] buf: Mbuf data addr
  346. * @return RT_ERROR_NONE for ok
  347. */
  348. RTS_API rtError_t rtMbufGetBuffAddr(rtMbufPtr_t memBuf, void **buf);
  349. /**
  350. * @ingroup rt_mem_queue
  351. * @brief get total Buffer size of Mbuf
  352. * @param [in] memBuf: Mbuf addr
  353. * @param [out] totalSize: total buffer size of Mbuf
  354. * @return RT_ERROR_NONE for ok
  355. */
  356. RTS_API rtError_t rtMbufGetBuffSize(rtMbufPtr_t memBuf, uint64_t *totalSize);
  357. /**
  358. * @ingroup rt_mem_queue
  359. * @brief Get the address and length of its user_data from the specified Mbuf
  360. * @param [in] memBuf: Mbuf addr
  361. * @param [out] priv: address of its user_data
  362. * @param [out] size: length of its user_data
  363. * @return RT_ERROR_NONE for ok
  364. */
  365. RTS_API rtError_t rtMbufGetPrivInfo(rtMbufPtr_t memBuf, void **priv, uint64_t *size);
  366. // mem group
  367. typedef struct {
  368. uint64_t maxMemSize; // max buf size in grp, in KB. = 0 means no limit
  369. } rtMemGrpConfig_t;
  370. typedef struct {
  371. uint32_t admin : 1; // admin permission, can add other proc to grp
  372. uint32_t read : 1; // read only permission
  373. uint32_t write : 1; // read and write permission
  374. uint32_t alloc : 1; // alloc permission (have read and write permission)
  375. uint32_t rsv : 28;
  376. } rtMemGrpShareAttr_t;
  377. #define RT_MEM_GRP_QUERY_GROUPS_OF_PROCESS 1 // query process all grp
  378. typedef struct {
  379. int32_t pid;
  380. } rtMemGrpQueryByProc_t; // cmd: GRP_QUERY_GROUPS_OF_PROCESS
  381. typedef struct {
  382. int32_t cmd;
  383. union {
  384. rtMemGrpQueryByProc_t grpQueryByProc; // cmd: GRP_QUERY_GROUPS_OF_PROCESS
  385. };
  386. } rtMemGrpQueryInput_t;
  387. #define RT_MEM_GRP_NAME_LEN 32 // it must be same as driver define BUFF_GRP_NAME_LEN
  388. typedef struct {
  389. char_t groupName[RT_MEM_GRP_NAME_LEN]; // group name
  390. rtMemGrpShareAttr_t attr; // process in group attribute
  391. } rtMemGrpOfProc_t; // cmd: GRP_QUERY_GROUPS_OF_PROCESS
  392. typedef struct {
  393. rtMemGrpOfProc_t *groupsOfProc; // cmd: GRP_QUERY_GROUPS_OF_PROCESS
  394. size_t maxNum; // max number of result
  395. size_t resultNum; // if the number of results exceeds 'maxNum', only 'maxNum' results are filled in buffer
  396. } rtMemGrpQueryOutput_t;
  397. /**
  398. * @ingroup rt_mem_queue
  399. * @brief create mem group
  400. * @attention null
  401. * @param [in] name, group name
  402. * @param [in] cfg, group cfg
  403. * @return 0 for success, others for fail
  404. */
  405. RTS_API rtError_t rtMemGrpCreate(const char_t *name, const rtMemGrpConfig_t *cfg);
  406. /**
  407. * @ingroup rt_mem_queue
  408. * @brief add process to group
  409. * @param [in] name, group name
  410. * @param [in] pid, process id
  411. * @param [in] attr, process permission in group
  412. * @return 0 for success, others for fail
  413. */
  414. RTS_API rtError_t rtMemGrpAddProc(const char_t *name, int32_t pid, const rtMemGrpShareAttr_t *attr);
  415. /**
  416. * @ingroup rt_mem_queue
  417. * @brief attach proccess to check permission in group
  418. * @param [in] name, group name
  419. * @param [in] timeout, time out ms
  420. * @return 0 for success, others for fail
  421. */
  422. RTS_API rtError_t rtMemGrpAttach(const char_t *name, int32_t timeout);
  423. /**
  424. * @ingroup rt_mem_queue
  425. * @brief buff group query
  426. * @param [in] input, query input
  427. * @param [in|out] output, query output
  428. * @return 0 for success, others for fail
  429. */
  430. RTS_API rtError_t rtMemGrpQuery(const rtMemGrpQueryInput_t *input, rtMemGrpQueryOutput_t *output);
  431. /**
  432. * @ingroup rt_mem_queue
  433. * @brief buff group query
  434. * @param [in] devId, cdevice id
  435. * @param [in] name, group name
  436. * @param [out] qid, queue id
  437. * @return 0 for success, others for fail
  438. */
  439. RTS_API rtError_t rtMemQueueGetQidByName(int32_t devId, const char_t *name, uint32_t *qId);
  440. /**
  441. * @ingroup rt_mem_queue
  442. * @brief esched attach device
  443. * @param [in] devId, device id
  444. * @return 0 for success, others for fail
  445. */
  446. RTS_API rtError_t rtEschedAttachDevice(int32_t devId);
  447. /**
  448. * @ingroup rt_mem_queue
  449. * @brief esched dettach device
  450. * @param [in] devId, device id
  451. * @return 0 for success, others for fail
  452. */
  453. RTS_API rtError_t rtEschedDettachDevice(int32_t devId);
  454. /**
  455. * @ingroup rt_mem_queue
  456. * @brief esched wait event
  457. * @param [in] devId, device id
  458. * @param [in] grpId, group id
  459. * @param [in] threadId, thread id
  460. * @param [in] timeout
  461. * @param [in] evt
  462. * @return 0 for success, others for fail
  463. */
  464. RTS_API rtError_t rtEschedWaitEvent(int32_t devId, uint32_t grpId, uint32_t threadId,
  465. int32_t timeout, rtEschedEventSummary_t *evt);
  466. /**
  467. * @ingroup rt_mem_queue
  468. * @brief esched create group
  469. * @param [in] devId, device id
  470. * @param [in] grpId, group id
  471. * @param [in] type, group type
  472. * @return 0 for success, others for fail
  473. */
  474. RTS_API rtError_t rtEschedCreateGrp(int32_t devId, uint32_t grpId, rtGroupType_t type);
  475. /**
  476. * @ingroup rt_mem_queue
  477. * @brief esched submit event
  478. * @param [in] devId, device id
  479. * @param [in] evt
  480. * @return 0 for success, others for fail
  481. */
  482. RTS_API rtError_t rtEschedSubmitEvent(int32_t devId, rtEschedEventSummary_t *evt);
  483. /**
  484. * @ingroup rt_mem_queue
  485. * @brief esched submit event
  486. * @param [in] devId, device id
  487. * @param [in] grpId, group id
  488. * @param [in] threadId, thread id
  489. * @param [in] eventBitmap
  490. * @return 0 for success, others for fail
  491. */
  492. RTS_API rtError_t rtEschedSubscribeEvent(int32_t devId, uint32_t grpId, uint32_t threadId, uint64_t eventBitmap);
  493. /**
  494. * @ingroup rtEschedAckEvent
  495. * @brief esched ack event
  496. * @param [in] devId, device id
  497. * @param [in] evtId, event type
  498. * @param [in] subEvtId, sub event type
  499. * @param [in] msg, message info
  500. * @param [in] len, message length
  501. * @return 0 for success, others for fail
  502. */
  503. RTS_API rtError_t rtEschedAckEvent(int32_t devId, rtEventIdType_t evtId,
  504. uint32_t subEvtId, char_t *msg, uint32_t len);
  505. /**
  506. * @ingroup rtQueueSubF2NFEvent
  507. * @brief full to not full event
  508. * @param [in] devId, device id
  509. * @param [in] qid, queue id
  510. * @param [in] groupId, group id
  511. * @return 0 for success, others for fail
  512. */
  513. RTS_API rtError_t rtQueueSubF2NFEvent(int32_t devId, uint32_t qId, uint32_t groupId);
  514. /**
  515. * @ingroup rtQueueSubscribe
  516. * @brief queue subscribe
  517. * @param [in] devId, device id
  518. * @param [in] qid, queue id
  519. * @param [in] groupId, group id
  520. * @param [in] type
  521. * @return 0 for success, others for fail
  522. */
  523. RTS_API rtError_t rtQueueSubscribe(int32_t devId, uint32_t qId, uint32_t groupId, int32_t type);
  524. /**
  525. * @ingroup rtBufEventTrigger
  526. * @brief buf event trigger
  527. * @param [in] name, group name
  528. * @return 0 for success, others for fail
  529. */
  530. RTS_API rtError_t rtBufEventTrigger(const char_t *name);
  531. #if defined(__cplusplus)
  532. }
  533. #endif
  534. #endif // CCE_RUNTIME_RT_MEM_QUEUE_H

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