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.

acl_tdt_queue.h 16 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. /**
  2. * Copyright 2019-2022 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 INC_EXTERNAL_ACL_ACL_TDT_QUEUE_H_
  17. #define INC_EXTERNAL_ACL_ACL_TDT_QUEUE_H_
  18. #include "acl/acl_base.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. #define ACL_TDT_QUEUE_PERMISSION_MANAGE 1
  23. #define ACL_TDT_QUEUE_PERMISSION_DEQUEUE 2
  24. #define ACL_TDT_QUEUE_PERMISSION_ENQUEUE 4
  25. typedef void *acltdtBuf;
  26. typedef struct tagMemQueueAttr acltdtQueueAttr;
  27. typedef struct acltdtQueueRouteList acltdtQueueRouteList;
  28. typedef struct acltdtQueueRouteQueryInfo acltdtQueueRouteQueryInfo;
  29. typedef struct acltdtQueueRoute acltdtQueueRoute;
  30. typedef enum { ACL_TDT_QUEUE_NAME_PTR = 0, ACL_TDT_QUEUE_DEPTH_UINT32 } acltdtQueueAttrType;
  31. typedef enum {
  32. ACL_TDT_QUEUE_ROUTE_SRC_UINT32 = 0,
  33. ACL_TDT_QUEUE_ROUTE_DST_UINT32,
  34. ACL_TDT_QUEUE_ROUTE_STATUS_INT32
  35. } acltdtQueueRouteParamType;
  36. typedef enum {
  37. ACL_TDT_QUEUE_ROUTE_QUERY_SRC = 0,
  38. ACL_TDT_QUEUE_ROUTE_QUERY_DST,
  39. ACL_TDT_QUEUE_ROUTE_QUERY_SRC_AND_DST
  40. } acltdtQueueRouteQueryMode;
  41. typedef enum {
  42. ACL_TDT_QUEUE_ROUTE_QUERY_MODE_ENUM = 0,
  43. ACL_TDT_QUEUE_ROUTE_QUERY_SRC_ID_UINT32,
  44. ACL_TDT_QUEUE_ROUTE_QUERY_DST_ID_UINT32
  45. } acltdtQueueRouteQueryInfoParamType;
  46. typedef enum { ACL_TDT_NORMAL_MEM = 0, ACL_TDT_DVPP_MEM } acltdtAllocBufType;
  47. /**
  48. * @ingroup AscendCL
  49. * @brief create queue
  50. *
  51. * @param attr [IN] pointer to the queue attr
  52. * @param qid [OUT] pointer to the qid
  53. *
  54. * @retval ACL_SUCCESS The function is successfully executed.
  55. * @retval OtherValues Failure
  56. *
  57. * @see acltdtDestroyQueue
  58. */
  59. ACL_FUNC_VISIBILITY aclError acltdtCreateQueue(const acltdtQueueAttr *attr, uint32_t *qid);
  60. /**
  61. * @ingroup AscendCL
  62. * @brief destroy queue
  63. *
  64. * @param qid [IN] qid which to be destroyed
  65. *
  66. * @retval ACL_SUCCESS The function is successfully executed.
  67. * @retval OtherValues Failure
  68. *
  69. * @see acltdtCreateQueue
  70. */
  71. ACL_FUNC_VISIBILITY aclError acltdtDestroyQueue(uint32_t qid);
  72. /**
  73. * @ingroup AscendCL
  74. * @brief enqueue function
  75. *
  76. * @param qid [IN] qid
  77. * @param buf [IN] acltdtBuf
  78. * @param timeout [IN] timeout, -1 means blocking
  79. *
  80. * @retval ACL_SUCCESS The function is successfully executed.
  81. * @retval OtherValues Failure
  82. *
  83. * @see acltdtDequeue
  84. */
  85. ACL_FUNC_VISIBILITY aclError acltdtEnqueue(uint32_t qid, acltdtBuf buf, int32_t timeout);
  86. /**
  87. * @ingroup AscendCL
  88. * @brief dequeue function
  89. *
  90. * @param qid [IN] qid
  91. * @param buf [OUT] pointer to the acltdtBuf
  92. * @param timeout [IN] timeout, -1 means blocking
  93. *
  94. * @retval ACL_SUCCESS The function is successfully executed.
  95. * @retval OtherValues Failure
  96. *
  97. * @see acltdtEnqueue
  98. */
  99. ACL_FUNC_VISIBILITY aclError acltdtDequeue(uint32_t qid, acltdtBuf *buf, int32_t timeout);
  100. /**
  101. * @ingroup AscendCL
  102. * @brief enqueue function
  103. *
  104. * @param qid [IN] qid
  105. * @param data [IN] the pointer to data buf
  106. * @param dataSize [IN] the size of data buf
  107. * @param userData [IN] the pointer to user data buf
  108. * @param userDataSize [IN] the size of user data buf
  109. * @param timeout [IN] timeout, -1 means blocking
  110. * @param rsv [IN] reserved param
  111. * @retval ACL_SUCCESS The function is successfully executed.
  112. * @retval OtherValues Failure
  113. *
  114. * @see acltdtDequeueData
  115. */
  116. ACL_FUNC_VISIBILITY aclError acltdtEnqueueData(uint32_t qid, const void *data, size_t dataSize, const void *userData,
  117. size_t userDataSize, int32_t timeout, uint32_t rsv);
  118. /**
  119. * @ingroup AscendCL
  120. * @brief dequeue function
  121. *
  122. * @param qid [IN] qid
  123. * @param data [IN|OUT] the pointer to data buf
  124. * @param dataSize [IN] the size of data buf
  125. * @param retDataSize [OUT] the return size of data buf
  126. * @param userData [IN|OUT] the pointer to user data buf
  127. * @param userDataSize [IN] the size of user data buf
  128. * @param timeout [IN] timeout, -1 means blocking
  129. * @retval ACL_SUCCESS The function is successfully executed.
  130. * @retval OtherValues Failure
  131. *
  132. * @see acltdtEnqueueData
  133. */
  134. ACL_FUNC_VISIBILITY aclError acltdtDequeueData(uint32_t qid, void *data, size_t dataSize, size_t *retDataSize,
  135. void *userData, size_t userDataSize, int32_t timeout);
  136. /**
  137. * @ingroup AscendCL
  138. * @brief grant queue to other process
  139. *
  140. * @param qid [IN] qid
  141. * @param pid [IN] pid of dst process
  142. * @param permission [IN] permission of queue
  143. * @param timeout [IN] timeout, -1 means blocking
  144. *
  145. * @retval ACL_SUCCESS The function is successfully executed.
  146. * @retval OtherValues Failure
  147. *
  148. * @see ACL_TDT_QUEUE_PERMISSION_MANAGE | ACL_TDT_QUEUE_PERMISSION_DEQUEUE | ACL_TDT_QUEUE_PERMISSION_ENQUEUE
  149. */
  150. ACL_FUNC_VISIBILITY aclError acltdtGrantQueue(uint32_t qid, int32_t pid, uint32_t permission, int32_t timeout);
  151. /**
  152. * @ingroup AscendCL
  153. * @brief attach queue in current process
  154. *
  155. * @param qid [IN] qid
  156. * @param timeout [IN] timeout, -1 means blocking
  157. * @param permission [OUT] permission of queue
  158. *
  159. * @retval ACL_SUCCESS The function is successfully executed.
  160. * @retval OtherValues Failure
  161. *
  162. * @see acltdtGrantQueue
  163. */
  164. ACL_FUNC_VISIBILITY aclError acltdtAttachQueue(uint32_t qid, int32_t timeout, uint32_t *permission);
  165. /**
  166. * @ingroup AscendCL
  167. * @brief bind queue routes
  168. *
  169. * @param qRouteList [IN|OUT] pointer to the route list
  170. *
  171. * @retval ACL_SUCCESS The function is successfully executed.
  172. * @retval OtherValues Failure
  173. */
  174. ACL_FUNC_VISIBILITY aclError acltdtBindQueueRoutes(acltdtQueueRouteList *qRouteList);
  175. /**
  176. * @ingroup AscendCL
  177. * @brief unbind queue routes
  178. *
  179. * @param qRouteList [IN|OUT] pointer to the route list
  180. *
  181. * @retval ACL_SUCCESS The function is successfully executed.
  182. * @retval OtherValues Failure
  183. */
  184. ACL_FUNC_VISIBILITY aclError acltdtUnbindQueueRoutes(acltdtQueueRouteList *qRouteList);
  185. /**
  186. * @ingroup AscendCL
  187. * @brief query queue routes according to query mode
  188. *
  189. * @param queryInfo [IN] pointer to the queue route query info
  190. * @param qRouteList [IN|OUT] pointer to the route list
  191. *
  192. * @retval ACL_SUCCESS The function is successfully executed.
  193. * @retval OtherValues Failure
  194. */
  195. ACL_FUNC_VISIBILITY aclError acltdtQueryQueueRoutes(const acltdtQueueRouteQueryInfo *queryInfo,
  196. acltdtQueueRouteList *qRouteList);
  197. /**
  198. * @ingroup AscendCL
  199. * @brief alloc acltdtBuf
  200. *
  201. * @param size [IN] alloc buf size
  202. * @param type [IN] reserved parameters, need to set zero currently
  203. * @param buf [OUT] pointer to the acltdtBuf
  204. *
  205. * @retval ACL_SUCCESS The function is successfully executed.
  206. * @retval OtherValues Failure
  207. *
  208. * @see acltdtFreeBuf
  209. */
  210. ACL_FUNC_VISIBILITY aclError acltdtAllocBuf(size_t size, uint32_t type, acltdtBuf *buf);
  211. /**
  212. * @ingroup AscendCL
  213. * @brief free acltdtBuf
  214. *
  215. * @param buf [IN] pointer to the acltdtBuf
  216. *
  217. * @retval ACL_SUCCESS The function is successfully executed.
  218. * @retval OtherValues Failure
  219. *
  220. * @see acltdtAllocBuf
  221. */
  222. ACL_FUNC_VISIBILITY aclError acltdtFreeBuf(acltdtBuf buf);
  223. /**
  224. * @ingroup AscendCL
  225. * @brief get data buf address
  226. *
  227. * @param buf [IN] acltdtBuf
  228. * @param dataPtr [OUT] pointer to the data ptr which is acquired from acltdtBuf
  229. * @param size [OUT] pointer to the size
  230. *
  231. * @retval ACL_SUCCESS The function is successfully executed.
  232. * @retval OtherValues Failure
  233. *
  234. * @see acltdtAllocBuf
  235. */
  236. ACL_FUNC_VISIBILITY aclError acltdtGetBufData(const acltdtBuf buf, void **dataPtr, size_t *size);
  237. /**
  238. * @ingroup AscendCL
  239. * @brief get private data buf address and size
  240. *
  241. * @param buf [IN] acltdtBuf
  242. * @param dataPtr [IN/OUT] pointer to the user ptr
  243. * @param size [IN] the current private data area size, less than or equal to 96B
  244. * @param offset [IN] address offset, less than or equal to 96B
  245. *
  246. * @retval ACL_SUCCESS The function is successfully executed.
  247. * @retval OtherValues Failure
  248. *
  249. * @see acltdtGetBufUserData
  250. */
  251. ACL_FUNC_VISIBILITY aclError acltdtGetBufUserData(const acltdtBuf buf, void *dataPtr, size_t size, size_t offset);
  252. /**
  253. * @ingroup AscendCL
  254. * @brief set private data buf address and size
  255. *
  256. * @param buf [OUT] acltdtBuf
  257. * @param dataPtr [IN] pointer to the user ptr
  258. * @param size [IN] the current private data area size, less than or equal to 96B
  259. * @param offset [IN] address offset, less than or equal to 96B
  260. *
  261. * @retval ACL_SUCCESS The function is successfully executed.
  262. * @retval OtherValues Failure
  263. *
  264. * @see acltdtSetBufUserData
  265. */
  266. ACL_FUNC_VISIBILITY aclError acltdtSetBufUserData(acltdtBuf buf, const void *dataPtr, size_t size, size_t offset);
  267. /**
  268. * @ingroup AscendCL
  269. * @brief copy buf ref
  270. *
  271. * @param buf [IN] acltdtBuf
  272. * @param newBuf [OUT] Make a reference copy of the data area of buf and
  273. * create a new buf header pointing to the same data area
  274. *
  275. * @retval ACL_SUCCESS The function is successfully executed.
  276. * @retval OtherValues Failure
  277. *
  278. * @see acltdtCopyBufRef
  279. */
  280. ACL_FUNC_VISIBILITY aclError acltdtCopyBufRef(const acltdtBuf buf, acltdtBuf *newBuf);
  281. /**
  282. * @ingroup AscendCL
  283. * @brief Create the queue attr
  284. *
  285. * @retval null for failed
  286. * @retval OtherValues success
  287. *
  288. * @see acltdtDestroyQueueAttr
  289. */
  290. ACL_FUNC_VISIBILITY acltdtQueueAttr *acltdtCreateQueueAttr();
  291. /**
  292. * @ingroup AscendCL
  293. * @brief Destroy the queue attr
  294. *
  295. * @param attr [IN] pointer to the queue attr
  296. *
  297. * @retval ACL_SUCCESS The function is successfully executed.
  298. * @retval OtherValues Failure
  299. *
  300. * @see acltdtCreateQueueAttr
  301. */
  302. ACL_FUNC_VISIBILITY aclError acltdtDestroyQueueAttr(const acltdtQueueAttr *attr);
  303. /**
  304. * @ingroup AscendCL
  305. * @brief Set parameter for queue attr
  306. *
  307. * @param attr [IN|OUT] pointer to the queue attr
  308. * @param type [IN] parameter type
  309. * @param len [IN] parameter length
  310. * @param param [IN] pointer to parameter value
  311. *
  312. * @retval ACL_SUCCESS for success, other for failure
  313. *
  314. * @see acltdtCreateQueueAttr
  315. */
  316. ACL_FUNC_VISIBILITY aclError acltdtSetQueueAttr(acltdtQueueAttr *attr, acltdtQueueAttrType type, size_t len,
  317. const void *param);
  318. /**
  319. * @ingroup AscendCL
  320. *
  321. * @brief Get parameter for queue attr.
  322. *
  323. * @param attr [IN] pointer to the queue attr
  324. * @param type [IN] parameter type
  325. * @param len [IN] parameter length
  326. * @param paramRetSize [OUT] pointer to parameter real length
  327. * @param param [OUT] pointer to parameter value
  328. *
  329. * @retval ACL_SUCCESS for success, other for failure
  330. *
  331. * @see acltdtCreateQueueAttr
  332. */
  333. ACL_FUNC_VISIBILITY aclError acltdtGetQueueAttr(const acltdtQueueAttr *attr, acltdtQueueAttrType type, size_t len,
  334. size_t *paramRetSize, void *param);
  335. /**
  336. * @ingroup AscendCL
  337. * @brief Create the queue route
  338. *
  339. * @param srcId [IN] src id of queue route
  340. * @param dstId [IN] dst id of queue route
  341. *
  342. * @retval null for failed
  343. * @retval OtherValues success
  344. *
  345. * @see acltdtDestroyQueueRoute
  346. */
  347. ACL_FUNC_VISIBILITY acltdtQueueRoute *acltdtCreateQueueRoute(uint32_t srcId, uint32_t dstId);
  348. /**
  349. * @ingroup AscendCL
  350. * @brief Destroy the queue attr
  351. *
  352. * @param route [IN] pointer to the queue route
  353. *
  354. * @retval ACL_SUCCESS The function is successfully executed.
  355. * @retval OtherValues Failure
  356. *
  357. * @see acltdtCreateQueueRoute
  358. */
  359. ACL_FUNC_VISIBILITY aclError acltdtDestroyQueueRoute(const acltdtQueueRoute *route);
  360. /**
  361. * @ingroup AscendCL
  362. *
  363. * @brief Get parameter for queue route.
  364. *
  365. * @param route [IN] pointer to the queue route
  366. * @param type [IN] parameter type
  367. * @param len [IN] parameter length
  368. * @param paramRetSize [OUT] pointer to parameter real length
  369. * @param param [OUT] pointer to parameter value
  370. *
  371. * @retval ACL_SUCCESS for success, other for failure
  372. *
  373. * @see acltdtCreateQueueRoute
  374. */
  375. ACL_FUNC_VISIBILITY aclError acltdtGetQueueRouteParam(const acltdtQueueRoute *route, acltdtQueueRouteParamType type,
  376. size_t len, size_t *paramRetSize, void *param);
  377. /**
  378. * @ingroup AscendCL
  379. * @brief Create the queue route list
  380. *
  381. * @retval null for failed
  382. * @retval OtherValues success
  383. *
  384. * @see acltdtDestroyQueueRouteList
  385. */
  386. ACL_FUNC_VISIBILITY acltdtQueueRouteList *acltdtCreateQueueRouteList();
  387. /**
  388. * @ingroup AscendCL
  389. * @brief Destroy the queue route list
  390. *
  391. * @param routeList [IN] pointer to the queue route list
  392. *
  393. * @retval ACL_SUCCESS The function is successfully executed.
  394. * @retval OtherValues Failure
  395. *
  396. * @see acltdtCreateQueueRouteList
  397. */
  398. ACL_FUNC_VISIBILITY aclError acltdtDestroyQueueRouteList(const acltdtQueueRouteList *routeList);
  399. /**
  400. * @ingroup AscendCL
  401. * @brief add queue route to the route list
  402. *
  403. * @param routeList [IN|OUT] pointer to the queue route list
  404. * @param route [IN] pointer to the queue route
  405. *
  406. * @retval ACL_SUCCESS The function is successfully executed.
  407. * @retval OtherValues Failure
  408. *
  409. * @see acltdtCreateQueueRouteList | acltdtCreateQueueRoute
  410. *
  411. */
  412. ACL_FUNC_VISIBILITY aclError acltdtAddQueueRoute(acltdtQueueRouteList *routeList, const acltdtQueueRoute *route);
  413. /**
  414. * @ingroup AscendCL
  415. * @brief get queue route from route list
  416. *
  417. * @param routeList [IN] pointer to the queue route list
  418. * @param index [IN] index of queue route in route list
  419. * @param route [IN|OUT] pointer to the queue route
  420. *
  421. * @retval ACL_SUCCESS The function is successfully executed.
  422. * @retval OtherValues Failure
  423. *
  424. * @see acltdtCreateQueueRouteList | acltdtCreateQueueRoute
  425. *
  426. */
  427. ACL_FUNC_VISIBILITY aclError acltdtGetQueueRoute(const acltdtQueueRouteList *routeList, size_t index,
  428. acltdtQueueRoute *route);
  429. /**
  430. * @ingroup AscendCL
  431. * @brief get queue route num from route list
  432. *
  433. * @param routeList [IN] pointer to the queue route list
  434. *
  435. * @retval the number of queue route
  436. *
  437. */
  438. ACL_FUNC_VISIBILITY size_t acltdtGetQueueRouteNum(const acltdtQueueRouteList *routeList);
  439. /**
  440. * @ingroup AscendCL
  441. * @brief Create the queue route query info
  442. *
  443. * @retval null for failed
  444. * @retval OtherValues success
  445. *
  446. * @see acltdtDestroyQueueRouteQueryInfo
  447. */
  448. ACL_FUNC_VISIBILITY acltdtQueueRouteQueryInfo *acltdtCreateQueueRouteQueryInfo();
  449. /**
  450. * @ingroup AscendCL
  451. * @brief Destroy the queue route query info
  452. *
  453. * @param info [IN] pointer to the queue route info
  454. *
  455. * @retval ACL_SUCCESS The function is successfully executed.
  456. * @retval OtherValues Failure
  457. *
  458. * @see acltdtCreateQueueRouteQueryInfo
  459. *
  460. */
  461. ACL_FUNC_VISIBILITY aclError acltdtDestroyQueueRouteQueryInfo(const acltdtQueueRouteQueryInfo *info);
  462. /**
  463. * @ingroup AscendCL
  464. * @brief Set parameter for queue route info
  465. *
  466. * @param attr [IN|OUT] pointer to the queue route info
  467. * @param type [IN] parameter type
  468. * @param len [IN] parameter length
  469. * @param param [IN] pointer to parameter value
  470. *
  471. * @retval ACL_SUCCESS for success, other for failure
  472. *
  473. * @see acltdtCreateQueueRouteQueryInfo
  474. */
  475. ACL_FUNC_VISIBILITY aclError acltdtSetQueueRouteQueryInfo(acltdtQueueRouteQueryInfo *param,
  476. acltdtQueueRouteQueryInfoParamType type, size_t len,
  477. const void *value);
  478. #ifdef __cplusplus
  479. }
  480. #endif
  481. #endif // INC_EXTERNAL_ACL_ACL_TDT_QUEUE_H_

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