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 14 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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 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. /**
  47. * @ingroup AscendCL
  48. * @brief create queue
  49. *
  50. * @param attr [IN] pointer to the queue attr
  51. * @param qid [OUT] pointer to the qid
  52. *
  53. * @retval ACL_SUCCESS The function is successfully executed.
  54. * @retval OtherValues Failure
  55. *
  56. * @see acltdtDestroyQueue
  57. */
  58. ACL_FUNC_VISIBILITY aclError acltdtCreateQueue(const acltdtQueueAttr *attr, uint32_t *qid);
  59. /**
  60. * @ingroup AscendCL
  61. * @brief destroy queue
  62. *
  63. * @param qid [IN] qid which to be destroyed
  64. *
  65. * @retval ACL_SUCCESS The function is successfully executed.
  66. * @retval OtherValues Failure
  67. *
  68. * @see acltdtCreateQueue
  69. */
  70. ACL_FUNC_VISIBILITY aclError acltdtDestroyQueue(uint32_t qid);
  71. /**
  72. * @ingroup AscendCL
  73. * @brief enqueue function
  74. *
  75. * @param qid [IN] qid
  76. * @param buf [IN] acltdtBuf
  77. * @param timeout [IN] timeout, -1 means blocking
  78. *
  79. * @retval ACL_SUCCESS The function is successfully executed.
  80. * @retval OtherValues Failure
  81. *
  82. * @see acltdtDequeue
  83. */
  84. ACL_FUNC_VISIBILITY aclError acltdtEnqueue(uint32_t qid, acltdtBuf buf, int32_t timeout);
  85. /**
  86. * @ingroup AscendCL
  87. * @brief dequeue function
  88. *
  89. * @param qid [IN] qid
  90. * @param buf [OUT] pointer to the acltdtBuf
  91. * @param timeout [IN] timeout, -1 means blocking
  92. *
  93. * @retval ACL_SUCCESS The function is successfully executed.
  94. * @retval OtherValues Failure
  95. *
  96. * @see acltdtEnqueue
  97. */
  98. ACL_FUNC_VISIBILITY aclError acltdtDequeue(uint32_t qid, acltdtBuf *buf, int32_t timeout);
  99. /**
  100. * @ingroup AscendCL
  101. * @brief enqueue function
  102. *
  103. * @param qid [IN] qid
  104. * @param data [IN] the pointer to data buf
  105. * @param dataSize [IN] the size of data buf
  106. * @param userData [IN] the pointer to user data buf
  107. * @param userDataSize [IN] the size of user data buf
  108. * @param timeout [IN] timeout, -1 means blocking
  109. * @param rsv [IN] reserved param
  110. * @retval ACL_SUCCESS The function is successfully executed.
  111. * @retval OtherValues Failure
  112. *
  113. * @see acltdtDequeueData
  114. */
  115. ACL_FUNC_VISIBILITY aclError acltdtEnqueueData(uint32_t qid, const void *data, size_t dataSize, const void *userData,
  116. size_t userDataSize, int32_t timeout, uint32_t rsv);
  117. /**
  118. * @ingroup AscendCL
  119. * @brief dequeue function
  120. *
  121. * @param qid [IN] qid
  122. * @param data [IN|OUT] the pointer to data buf
  123. * @param dataSize [IN] the size of data buf
  124. * @param retDataSize [OUT] the return size of data buf
  125. * @param userData [IN|OUT] the pointer to user data buf
  126. * @param userDataSize [IN] the size of user data buf
  127. * @param timeout [IN] timeout, -1 means blocking
  128. * @retval ACL_SUCCESS The function is successfully executed.
  129. * @retval OtherValues Failure
  130. *
  131. * @see acltdtEnqueueData
  132. */
  133. ACL_FUNC_VISIBILITY aclError acltdtDequeueData(uint32_t qid, void *data, size_t dataSize, size_t *retDataSize,
  134. void *userData, size_t userDataSize, int32_t timeout);
  135. /**
  136. * @ingroup AscendCL
  137. * @brief grant queue to other process
  138. *
  139. * @param qid [IN] qid
  140. * @param pid [IN] pid of dst process
  141. * @param permission [IN] permission of queue
  142. * @param timeout [IN] timeout, -1 means blocking
  143. *
  144. * @retval ACL_SUCCESS The function is successfully executed.
  145. * @retval OtherValues Failure
  146. *
  147. * @see ACL_TDT_QUEUE_PERMISSION_MANAGE | ACL_TDT_QUEUE_PERMISSION_DEQUEUE | ACL_TDT_QUEUE_PERMISSION_ENQUEUE
  148. */
  149. ACL_FUNC_VISIBILITY aclError acltdtGrantQueue(uint32_t qid, int32_t pid, uint32_t permission, int32_t timeout);
  150. /**
  151. * @ingroup AscendCL
  152. * @brief attach queue in current process
  153. *
  154. * @param qid [IN] qid
  155. * @param timeout [IN] timeout, -1 means blocking
  156. * @param permission [OUT] permission of queue
  157. *
  158. * @retval ACL_SUCCESS The function is successfully executed.
  159. * @retval OtherValues Failure
  160. *
  161. * @see acltdtGrantQueue
  162. */
  163. ACL_FUNC_VISIBILITY aclError acltdtAttachQueue(uint32_t qid, int32_t timeout, uint32_t *permission);
  164. /**
  165. * @ingroup AscendCL
  166. * @brief bind queue routes
  167. *
  168. * @param qRouteList [IN|OUT] pointer to the route list
  169. *
  170. * @retval ACL_SUCCESS The function is successfully executed.
  171. * @retval OtherValues Failure
  172. */
  173. ACL_FUNC_VISIBILITY aclError acltdtBindQueueRoutes(acltdtQueueRouteList *qRouteList);
  174. /**
  175. * @ingroup AscendCL
  176. * @brief unbind queue routes
  177. *
  178. * @param qRouteList [IN|OUT] pointer to the route list
  179. *
  180. * @retval ACL_SUCCESS The function is successfully executed.
  181. * @retval OtherValues Failure
  182. */
  183. ACL_FUNC_VISIBILITY aclError acltdtUnbindQueueRoutes(acltdtQueueRouteList *qRouteList);
  184. /**
  185. * @ingroup AscendCL
  186. * @brief query queue routes according to query mode
  187. *
  188. * @param queryInfo [IN] pointer to the queue route query info
  189. * @param qRouteList [IN|OUT] pointer to the route list
  190. *
  191. * @retval ACL_SUCCESS The function is successfully executed.
  192. * @retval OtherValues Failure
  193. */
  194. ACL_FUNC_VISIBILITY aclError acltdtQueryQueueRoutes(const acltdtQueueRouteQueryInfo *queryInfo,
  195. acltdtQueueRouteList *qRouteList);
  196. /**
  197. * @ingroup AscendCL
  198. * @brief alloc acltdtBuf
  199. *
  200. * @param size [IN] alloc buf size
  201. * @param buf [OUT] pointer to the acltdtBuf
  202. *
  203. * @retval ACL_SUCCESS The function is successfully executed.
  204. * @retval OtherValues Failure
  205. *
  206. * @see acltdtFreeBuf
  207. */
  208. ACL_FUNC_VISIBILITY aclError acltdtAllocBuf(size_t size, acltdtBuf *buf);
  209. /**
  210. * @ingroup AscendCL
  211. * @brief free acltdtBuf
  212. *
  213. * @param buf [IN] pointer to the acltdtBuf
  214. *
  215. * @retval ACL_SUCCESS The function is successfully executed.
  216. * @retval OtherValues Failure
  217. *
  218. * @see acltdtAllocBuf
  219. */
  220. ACL_FUNC_VISIBILITY aclError acltdtFreeBuf(acltdtBuf buf);
  221. /**
  222. * @ingroup AscendCL
  223. * @brief get data buf address
  224. *
  225. * @param buf [IN] acltdtBuf
  226. * @param dataPtr [OUT] pointer to the data ptr which is acquired from acltdtBuf
  227. * @param size [OUT] pointer to the size
  228. *
  229. * @retval ACL_SUCCESS The function is successfully executed.
  230. * @retval OtherValues Failure
  231. *
  232. * @see acltdtAllocBuf
  233. */
  234. ACL_FUNC_VISIBILITY aclError acltdtGetBufData(const acltdtBuf buf, void **dataPtr, size_t *size);
  235. /**
  236. * @ingroup AscendCL
  237. * @brief Create the queue attr
  238. *
  239. * @retval null for failed
  240. * @retval OtherValues success
  241. *
  242. * @see acltdtDestroyQueueAttr
  243. */
  244. ACL_FUNC_VISIBILITY acltdtQueueAttr *acltdtCreateQueueAttr();
  245. /**
  246. * @ingroup AscendCL
  247. * @brief Destroy the queue attr
  248. *
  249. * @param attr [IN] pointer to the queue attr
  250. *
  251. * @retval ACL_SUCCESS The function is successfully executed.
  252. * @retval OtherValues Failure
  253. *
  254. * @see acltdtCreateQueueAttr
  255. */
  256. ACL_FUNC_VISIBILITY aclError acltdtDestroyQueueAttr(const acltdtQueueAttr *attr);
  257. /**
  258. * @ingroup AscendCL
  259. * @brief Set parameter for queue attr
  260. *
  261. * @param attr [IN|OUT] pointer to the queue attr
  262. * @param type [IN] parameter type
  263. * @param len [IN] parameter length
  264. * @param param [IN] pointer to parameter value
  265. *
  266. * @retval ACL_SUCCESS for success, other for failure
  267. *
  268. * @see acltdtCreateQueueAttr
  269. */
  270. ACL_FUNC_VISIBILITY aclError acltdtSetQueueAttr(acltdtQueueAttr *attr, acltdtQueueAttrType type, size_t len,
  271. const void *param);
  272. /**
  273. * @ingroup AscendCL
  274. *
  275. * @brief Get parameter for queue attr.
  276. *
  277. * @param attr [IN] pointer to the queue attr
  278. * @param type [IN] parameter type
  279. * @param len [IN] parameter length
  280. * @param paramRetSize [OUT] pointer to parameter real length
  281. * @param param [OUT] pointer to parameter value
  282. *
  283. * @retval ACL_SUCCESS for success, other for failure
  284. *
  285. * @see acltdtCreateQueueAttr
  286. */
  287. ACL_FUNC_VISIBILITY aclError acltdtGetQueueAttr(const acltdtQueueAttr *attr, acltdtQueueAttrType type, size_t len,
  288. size_t *paramRetSize, void *param);
  289. /**
  290. * @ingroup AscendCL
  291. * @brief Create the queue route
  292. *
  293. * @param srcId [IN] src id of queue route
  294. * @param dstId [IN] dst id of queue route
  295. *
  296. * @retval null for failed
  297. * @retval OtherValues success
  298. *
  299. * @see acltdtDestroyQueueRoute
  300. */
  301. ACL_FUNC_VISIBILITY acltdtQueueRoute *acltdtCreateQueueRoute(uint32_t srcId, uint32_t dstId);
  302. /**
  303. * @ingroup AscendCL
  304. * @brief Destroy the queue attr
  305. *
  306. * @param route [IN] pointer to the queue route
  307. *
  308. * @retval ACL_SUCCESS The function is successfully executed.
  309. * @retval OtherValues Failure
  310. *
  311. * @see acltdtCreateQueueRoute
  312. */
  313. ACL_FUNC_VISIBILITY aclError acltdtDestroyQueueRoute(const acltdtQueueRoute *route);
  314. /**
  315. * @ingroup AscendCL
  316. *
  317. * @brief Get parameter for queue route.
  318. *
  319. * @param route [IN] pointer to the queue route
  320. * @param type [IN] parameter type
  321. * @param len [IN] parameter length
  322. * @param paramRetSize [OUT] pointer to parameter real length
  323. * @param param [OUT] pointer to parameter value
  324. *
  325. * @retval ACL_SUCCESS for success, other for failure
  326. *
  327. * @see acltdtCreateQueueRoute
  328. */
  329. ACL_FUNC_VISIBILITY aclError acltdtGetQueueRouteParam(const acltdtQueueRoute *route, acltdtQueueRouteParamType type,
  330. size_t len, size_t *paramRetSize, void *param);
  331. /**
  332. * @ingroup AscendCL
  333. * @brief Create the queue route list
  334. *
  335. * @retval null for failed
  336. * @retval OtherValues success
  337. *
  338. * @see acltdtDestroyQueueRouteList
  339. */
  340. ACL_FUNC_VISIBILITY acltdtQueueRouteList *acltdtCreateQueueRouteList();
  341. /**
  342. * @ingroup AscendCL
  343. * @brief Destroy the queue route list
  344. *
  345. * @param routeList [IN] pointer to the queue route list
  346. *
  347. * @retval ACL_SUCCESS The function is successfully executed.
  348. * @retval OtherValues Failure
  349. *
  350. * @see acltdtCreateQueueRouteList
  351. */
  352. ACL_FUNC_VISIBILITY aclError acltdtDestroyQueueRouteList(const acltdtQueueRouteList *routeList);
  353. /**
  354. * @ingroup AscendCL
  355. * @brief add queue route to the route list
  356. *
  357. * @param routeList [IN|OUT] pointer to the queue route list
  358. * @param route [IN] pointer to the queue route
  359. *
  360. * @retval ACL_SUCCESS The function is successfully executed.
  361. * @retval OtherValues Failure
  362. *
  363. * @see acltdtCreateQueueRouteList | acltdtCreateQueueRoute
  364. *
  365. */
  366. ACL_FUNC_VISIBILITY aclError acltdtAddQueueRoute(acltdtQueueRouteList *routeList, const acltdtQueueRoute *route);
  367. /**
  368. * @ingroup AscendCL
  369. * @brief get queue route from route list
  370. *
  371. * @param routeList [IN] pointer to the queue route list
  372. * @param index [IN] index of queue route in route list
  373. * @param route [IN|OUT] pointer to the queue route
  374. *
  375. * @retval ACL_SUCCESS The function is successfully executed.
  376. * @retval OtherValues Failure
  377. *
  378. * @see acltdtCreateQueueRouteList | acltdtCreateQueueRoute
  379. *
  380. */
  381. ACL_FUNC_VISIBILITY aclError acltdtGetQueueRoute(const acltdtQueueRouteList *routeList, size_t index,
  382. acltdtQueueRoute *route);
  383. /**
  384. * @ingroup AscendCL
  385. * @brief get queue route num from route list
  386. *
  387. * @param routeList [IN] pointer to the queue route list
  388. *
  389. * @retval the number of queue route
  390. *
  391. */
  392. ACL_FUNC_VISIBILITY size_t acltdtGetQueueRouteNum(const acltdtQueueRouteList *routeList);
  393. /**
  394. * @ingroup AscendCL
  395. * @brief Create the queue route query info
  396. *
  397. * @retval null for failed
  398. * @retval OtherValues success
  399. *
  400. * @see acltdtDestroyQueueRouteQueryInfo
  401. */
  402. ACL_FUNC_VISIBILITY acltdtQueueRouteQueryInfo *acltdtCreateQueueRouteQueryInfo();
  403. /**
  404. * @ingroup AscendCL
  405. * @brief Destroy the queue route query info
  406. *
  407. * @param info [IN] pointer to the queue route info
  408. *
  409. * @retval ACL_SUCCESS The function is successfully executed.
  410. * @retval OtherValues Failure
  411. *
  412. * @see acltdtCreateQueueRouteQueryInfo
  413. *
  414. */
  415. ACL_FUNC_VISIBILITY aclError acltdtDestroyQueueRouteQueryInfo(const acltdtQueueRouteQueryInfo *info);
  416. /**
  417. * @ingroup AscendCL
  418. * @brief Set parameter for queue route info
  419. *
  420. * @param attr [IN|OUT] pointer to the queue route info
  421. * @param type [IN] parameter type
  422. * @param len [IN] parameter length
  423. * @param param [IN] pointer to parameter value
  424. *
  425. * @retval ACL_SUCCESS for success, other for failure
  426. *
  427. * @see acltdtCreateQueueRouteQueryInfo
  428. */
  429. ACL_FUNC_VISIBILITY aclError acltdtSetQueueRouteQueryInfo(acltdtQueueRouteQueryInfo *param,
  430. acltdtQueueRouteQueryInfoParamType type, size_t len,
  431. const void *value);
  432. #ifdef __cplusplus
  433. }
  434. #endif
  435. #endif // INC_EXTERNAL_ACL_ACL_TDT_QUEUE_H_

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