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.6 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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 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 "tdt/status.h"
  23. #include "tdt/data_common.h"
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif // __cplusplus
  27. /**
  28. * @ingroup Open
  29. * @brief Used for the Framework process to communicate with the TSDDaemon process,
  30. * and notify TSD to complete the initialization of other processes
  31. *
  32. * @par Function
  33. * Used for the Framework process to communicate with the TSDDaemon process,
  34. * and notify TSD to complete the initialization of other processes
  35. *
  36. * @param phyDeviceId [IN] type #unsigned int. Physical device ID
  37. * @param rankSize [IN] type #unsigned int. The rankSize of the training.
  38. * The default value is 1. When rankSize is greater than 1,
  39. * HCCP will be pulled to perform set communication related operations.
  40. * @retval TDT_OK Success
  41. * @retval OtherValues Failure
  42. *
  43. * @par Dependency
  44. * @li libtsdclient.so: Library to which the interface belongs.
  45. * @li tsd_client.h: Header file where the interface declaration is located.
  46. * @li data_common.h: Header file where 'TDT_StatusT' defined
  47. */
  48. TDT_StatusT TsdOpen(const uint32_t phyDeviceId, const uint32_t rankSize);
  49. /**
  50. * @ingroup Close
  51. * @brief notify TSDClient close resource
  52. *
  53. * @par Function
  54. * notify TSDClient close resource
  55. *
  56. * @param NA
  57. * @retval TDT_OK Success
  58. * @retval OtherValues Failure
  59. *
  60. * @par Dependency
  61. * @li libtsdclient.so: Library to which the interface belongs.
  62. * @li tsd_client.h: Header file where the interface declaration is located.
  63. * @li data_common.h: Header file where 'TDT_StatusT' defined
  64. */
  65. TDT_StatusT TsdClose(const uint32_t phyDeviceId);
  66. /**
  67. * @ingroup CreateCmdParameterObj
  68. * @brief creat tsdclient func parameter obj.
  69. *
  70. * @par Function
  71. * creat tsdclient func parameter obj.
  72. *
  73. * @param type [IN] type tdt::TsdCmdType, tsd func type.
  74. * @param cmdParameterObj [IN] type void *, func parameter obj.
  75. * @retval TDT_OK Success
  76. * @retval TDT_INTERFACE_NOT_SUPPORT
  77. *
  78. * @par Dependency
  79. * @li libtsdclient.so: Library to which the interface belongs.
  80. * @li data_common.h: Header file where tdt::TsdCmdType and tdt::InputItem defined.
  81. * @li status.h: Header file where 'TDT_StatusT' defined
  82. */
  83. TDT_StatusT CreateCmdParameterObj(tdt::TsdCmdType type, void **cmdParameterObj);
  84. /**
  85. * @ingroup SetCmdParameterObjAttribute
  86. * @brief set cmdParameterObj input value.
  87. *
  88. * @par Function
  89. * set cmdParameterObj input value.
  90. *
  91. * @param type [IN] type tdt::TsdCmdType, tsd func type.
  92. * @param cmdParameterObj [IN] type void *, func parameter obj.
  93. * @param itemType [IN] type tdt::InputItem, func input type.
  94. * @param valuePtr [IN] type const void *, input value.
  95. * @param valueLength [IN] type int, input value length.
  96. * @retval TDT_OK Success
  97. * @retval TDT_INTERFACE_NOT_SUPPORT
  98. *
  99. * @par Dependency
  100. * @li libtsdclient.so: Library to which the interface belongs.
  101. * @li data_common.h: Header file where tdt::TsdCmdType and tdt::InputItem defined.
  102. * @li status.h: Header file where 'TDT_StatusT' defined
  103. */
  104. TDT_StatusT SetCmdParameterObjAttribute(tdt::TsdCmdType type, void *cmdParameterObj, tdt::InputItem itemType, const void *valuePtr, int valueLength);
  105. /**
  106. * @ingroup GetCmdParameterObjAttribute
  107. * @brief set cmdParameterObj input value.
  108. *
  109. * @par Function
  110. * set cmdParameterObj input value.
  111. *
  112. * @param type [IN] type tdt::TsdCmdType, tsd func type.
  113. * @param cmdParameterObj [IN] type void *, func parameter obj.
  114. * @param itemType [IN] type tdt::InputItem, func input type.
  115. * @param valuePtr [IN] type const void *, input value.
  116. * @param valueLength [IN] type int, input value length.
  117. * @retval TDT_OK Success
  118. * @retval TDT_INTERFACE_NOT_SUPPORT
  119. *
  120. * @par Dependency
  121. * @li libtsdclient.so: Library to which the interface belongs.
  122. * @li data_common.h: Header file where tdt::TsdCmdType and tdt::InputItem defined.
  123. * @li status.h: Header file where 'TDT_StatusT' defined
  124. */
  125. TDT_StatusT GetCmdParameterObjAttribute(tdt::TsdCmdType type, void *cmdParameterObj, tdt::InputItem itemType, void *valuePtr, int &valueLength);
  126. /**
  127. * @ingroup TsdClientCmd
  128. * @brief creat tsdclient func parameter obj.
  129. *
  130. * @par Function
  131. * creat tsdclient func parameter obj.
  132. *
  133. * @param type [IN] type tdt::TsdCmdType, tsd func type.
  134. * @param cmdParameterObj [IN] type void *, func parameter obj.
  135. * @retval TDT_OK Success
  136. * @retval TDT_INTERFACE_NOT_SUPPORT
  137. *
  138. * @par Dependency
  139. * @li libtsdclient.so: Library to which the interface belongs.
  140. * @li data_common.h: Header file where tdt::TsdCmdType and tdt::InputItem defined.
  141. * @li status.h: Header file where 'TDT_StatusT' defined
  142. */
  143. TDT_StatusT TsdClientCmd(tdt::TsdCmdType cmd, void *cmdParameterObj);
  144. namespace tdt {
  145. /**
  146. * @ingroup RANK_SIZE_DEFAULT_VALUE。
  147. * The default value of Rank size is 1 by default.
  148. * It does not pull up HCCP to perform set communication related operations.
  149. *
  150. */
  151. constexpr uint32_t RANK_SIZE_DEFAULT_VALUE = 1;
  152. class TsdClient {
  153. public:
  154. /**
  155. * @ingroup GetInstance
  156. * @brief Get TsdClient instance
  157. *
  158. * @par Function
  159. * Get TsdClient instance
  160. *
  161. * @param NA
  162. * @retval TsdClient TsdClient instance
  163. *
  164. * @par Dependency
  165. * @li libtsdclient.so: Library to which the interface belongs.
  166. * @li tsd_client.h: Header file where the interface declaration is located.
  167. */
  168. static TsdClient *GetInstance();
  169. /**
  170. * @ingroup ~TsdClient
  171. * @brief TsdClient destructor
  172. *
  173. * @par Function
  174. * TsdClient destructor
  175. *
  176. * @param NA
  177. * @retval NA
  178. *
  179. * @par Dependency
  180. * @li libtsdclient.so: Library to which the interface belongs.
  181. * @li tsd_client.h: Header file where the interface declaration is located.
  182. */
  183. ~TsdClient();
  184. /**
  185. * @ingroup Open
  186. * @brief Used for the Framework process to communicate with the TSDDaemon process,
  187. * and notify TSD to complete the initialization of other processes
  188. *
  189. * @par Function
  190. * Used for the Framework process to communicate with the TSDDaemon process,
  191. * and notify TSD to complete the initialization of other processes
  192. *
  193. * @param phyDeviceId [IN] type #unsigned int. Physical device ID
  194. * @param rankSize [IN] type #unsigned int. The rankSize of the training.
  195. * The default value is 1. When rankSize is greater than 1,
  196. * HCCP will be pulled to perform set communication related operations.
  197. * @retval TDT_OK Success
  198. * @retval OtherValues Failure
  199. *
  200. * @par Dependency
  201. * @li libtsdclient.so: Library to which the interface belongs.
  202. * @li tsd_client.h: Header file where the interface declaration is located.
  203. * @li data_common.h: Header file where 'TDT_StatusT' defined
  204. */
  205. TDT_StatusT Open(const uint32_t phyDeviceId, const uint32_t rankSize = RANK_SIZE_DEFAULT_VALUE);
  206. TDT_StatusT Close();
  207. private:
  208. TsdClient();
  209. TsdClient(const TsdClient &) = delete;
  210. TsdClient(TsdClient &&) = delete;
  211. TsdClient &operator=(const TsdClient &) = delete;
  212. TsdClient &operator=(TsdClient &&) = delete;
  213. uint32_t rankSize_;
  214. };
  215. } // namespace tdt
  216. #ifdef __cplusplus
  217. }
  218. #endif // __cplusplus
  219. #endif // TDT_HOST_INNER_INC_TSD_CLIENT_H_

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