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.

tsd_client.h 7.8 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /**
  2. * Copyright (c) Hisilicon Technologies Co., Ltd. 2018-2021. All rights reserved.
  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 TDT_HOST_INNER_INC_TSD_CLIENT_H
  17. #define TDT_HOST_INNER_INC_TSD_CLIENT_H
  18. #include <condition_variable>
  19. #include <map>
  20. #include <memory>
  21. #include <mutex>
  22. #include "tsd/status.h"
  23. #include "toolchain/prof_callback.h"
  24. #ifdef WIN_TSD
  25. #define TDT_LIB_EXPORT __declspec(dllexport)
  26. #else
  27. #define TDT_LIB_EXPORT __attribute__((visibility("default")))
  28. #endif
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif // __cplusplus
  32. struct InitFlowGwInfo {
  33. const char_t *groupName;
  34. uint64_t schedPolicy;
  35. uint64_t reschedInterval;
  36. char_t rsv[128];
  37. };
  38. typedef enum {
  39. TSD_CAPABILITY_PIDQOS = 0,
  40. TSD_CAPABILITY_BUT
  41. } TsdCapabilityType;
  42. /**
  43. * @ingroup Open
  44. * @brief Used for the Framework process to communicate with the TSDDaemon process,
  45. * and notify TSD to complete the initialization of other processes
  46. *
  47. * @par Function
  48. * Used for the Framework process to communicate with the TSDDaemon process,
  49. * and notify TSD to complete the initialization of other processes
  50. *
  51. * @param logicDeviceId [IN] type #unsigned int. Logic device ID
  52. * @param rankSize [IN] type #unsigned int. The rankSize of the training.
  53. * The default value is 1. When rankSize is greater than 1,
  54. * HCCP will be pulled to perform set communication related operations.
  55. * @retval TDT_OK Success
  56. * @retval OtherValues Failure
  57. *
  58. * @par Dependency
  59. * @li libtsdclient.so: Library to which the interface belongs.
  60. * @li tsd_client.h: Header file where the interface declaration is located.
  61. * @li data_common.h: Header file where 'TDT_StatusT' defined
  62. */
  63. TDT_LIB_EXPORT uint32_t TsdOpen(const uint32_t logicDeviceId, const uint32_t rankSize);
  64. /**
  65. * @ingroup Open
  66. * @brief Used for the Framework process to communicate with the TSDDaemon process in 1981,
  67. * and notify TSD to complete the initialization of other processes
  68. *
  69. * @par Function
  70. * Used for the Framework process to communicate with the TSDDaemon process,
  71. * and notify TSD to complete the initialization of other processes
  72. *
  73. * @param logicDeviceId [IN] type #unsigned int. Logic device ID
  74. * @param rankSize [IN] type #unsigned int. The rankSize of the training.
  75. * The default value is 1. When rankSize is greater than 1,
  76. * HCCP will be pulled to perform set communication related operations.
  77. * @param deviceMode [IN] type unsigned int. The device running mode of aicpuSd,
  78. * it include chipMode and DieMode
  79. * @retval TDT_OK Success
  80. * @retval OtherValues Failure
  81. *
  82. * @par Dependency
  83. * @li data_common.h: Header file where 'TDT_StatusT' defined
  84. */
  85. TDT_LIB_EXPORT uint32_t TsdOpenEx(const uint32_t logicDeviceId, const uint32_t rankSize, const uint32_t deviceMode);
  86. /**
  87. * @ingroup InitialQs
  88. * @brief Used for the Framework process to communicate with the TSDDaemon process,
  89. * and notify TSD to complete the initialization of QS processes
  90. *
  91. * @par Function
  92. * Used for the Framework process to communicate with the TSDDaemon process,
  93. * and notify TSD to complete the initialization of other processes
  94. *
  95. * @param logicDeviceId [IN] type #unsigned int. Logic device ID
  96. * @param groupName [IN] type #char pointer. qs group name send by host process
  97. * @retval TDT_OK Success
  98. * @retval OtherValues Failure
  99. *
  100. * @par Dependency
  101. * @li libtsdclient.so: Library to which the interface belongs.
  102. * @li tsd_client.h: Header file where the interface declaration is located.
  103. * @li data_common.h: Header file where 'TDT_StatusT' defined
  104. */
  105. TDT_LIB_EXPORT uint32_t TsdInitQs(const uint32_t logicDeviceId, const char_t * const groupName = nullptr);
  106. /**
  107. * @ingroup InitFlowGw
  108. * @brief Used for the Framework process to communicate with the TSDDaemon process,
  109. * and notify TSD to complete the initialization of FlowGw processes
  110. *
  111. * @par Function
  112. * Used for the Framework process to communicate with the TSDDaemon process,
  113. * and notify TSD to complete the initialization of other processes
  114. *
  115. * @param logicDeviceId [IN] type #unsigned int. Logic device ID
  116. * @param initInfo [IN] type #InitFlowGwInfo pointer. Initialization parameters
  117. * @retval TDT_OK Success
  118. * @retval OtherValues Failure
  119. *
  120. * @par Dependency
  121. * @li libtsdclient.so: Library to which the interface belongs.
  122. * @li tsd_client.h: Header file where the interface declaration is located.
  123. * @li data_common.h: Header file where 'TDT_StatusT' defined
  124. */
  125. TDT_LIB_EXPORT uint32_t TsdInitFlowGw(const uint32_t logicDeviceId, const InitFlowGwInfo * const initInfo);
  126. /**
  127. * @ingroup Close
  128. * @brief notify TSDClient close resource
  129. *
  130. * @par Function
  131. * notify TSDClient close resource
  132. *
  133. * @param NA
  134. * @retval TDT_OK Success
  135. * @retval OtherValues Failure
  136. *
  137. * @par Dependency
  138. * @li libtsdclient.so: Library to which the interface belongs.
  139. * @li tsd_client.h: Header file where the interface declaration is located.
  140. * @li data_common.h: Header file where 'TDT_StatusT' defined
  141. */
  142. TDT_LIB_EXPORT uint32_t TsdClose(const uint32_t logicDeviceId);
  143. /**
  144. * @ingroup UpdateProfilingMode
  145. * @brief notify TSDClient update profiling mode
  146. *
  147. * @par Function
  148. * notify TSDClient update profiling mode
  149. *
  150. * @param NA
  151. * @retval TDT_OK Success
  152. * @retval OtherValues Failure
  153. *
  154. * @par Dependency
  155. * @li libtsdclient.so: Library to which the interface belongs.
  156. * @li tsd_client.h: Header file where the interface declaration is located.
  157. * @li data_common.h: Header file where 'TDT_StatusT' defined
  158. */
  159. TDT_LIB_EXPORT uint32_t UpdateProfilingMode(const uint32_t logicDeviceId, const uint32_t flag);
  160. /**
  161. * @ingroup TsdSetMsprofReporterCallback
  162. * @brief 用于推理场景下设置aicpu的profilng的callback函数
  163. *
  164. * @par Function
  165. * 设置offline模式下aicpu_sd进程的profiling的callback函数
  166. *
  167. * @param callback [IN] type #MsprofReporterCallback. 回调函数
  168. * @retval TDT_OK Success
  169. * @retval OtherValues Failure
  170. *
  171. * @par Dependency
  172. * @li libtsdclient.so: Library to which the interface belongs.
  173. * @li tsd_client.h: Header file where the interface declaration is located.
  174. * @li data_common.h: Header file where 'TDT_StatusT' defined
  175. * @li prof_callback.h: Headerfile where 'MsprofReporterCallback' defined
  176. */
  177. TDT_LIB_EXPORT uint32_t TsdSetMsprofReporterCallback(const MsprofReporterCallback callback);
  178. /**
  179. * @ingroup TsdSetAttr
  180. * @brief used to set tsd attr
  181. *
  182. * @par key
  183. * key set for tsd attr,now only support RunMode
  184. *
  185. * @par value
  186. * value set to run correspond mode, PROCESS_MODE or THREAD_MODE
  187. * @retval TDT_OK Success
  188. * @retval OtherValues Failure
  189. */
  190. TDT_LIB_EXPORT uint32_t TsdSetAttr(const char * const attrKey, const char * const attrValue);
  191. /**
  192. * @ingroup TsdCapabilityGet
  193. * @brief use tsd to get some capability
  194. *
  195. * @par type
  196. * capability type
  197. *
  198. * @par ptr
  199. * the result
  200. * @retval TDT_OK Success
  201. * @retval OtherValues Failure
  202. */
  203. TDT_LIB_EXPORT uint32_t TsdCapabilityGet(const uint32_t logicDeviceId, const int32_t type, const uint64_t ptr);
  204. /**
  205. * @ingroup GetHdcConctStatus
  206. * @brief used to get hdc connection status
  207. *
  208. * @par logicDeviceId
  209. * logic device id
  210. *
  211. * @par hdcSessStat
  212. * hdc session status, DRV_ERROR_SOCKET_CONNECT or DRV_ERROR_SOCKET_CLOSE
  213. * @retval TDT_OK Success
  214. * @retval OtherValues Failure
  215. */
  216. TDT_LIB_EXPORT uint32_t GetHdcConctStatus(const uint32_t logicDeviceId, int32_t *hdcSessStat);
  217. #ifdef __cplusplus
  218. }
  219. #endif // __cplusplus
  220. #endif // TDT_HOST_INNER_INC_TSD_CLIENT_H

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