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

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. /**
  39. * @ingroup Open
  40. * @brief Used for the Framework process to communicate with the TSDDaemon process,
  41. * and notify TSD to complete the initialization of other processes
  42. *
  43. * @par Function
  44. * Used for the Framework process to communicate with the TSDDaemon process,
  45. * and notify TSD to complete the initialization of other processes
  46. *
  47. * @param logicDeviceId [IN] type #unsigned int. Logic device ID
  48. * @param rankSize [IN] type #unsigned int. The rankSize of the training.
  49. * The default value is 1. When rankSize is greater than 1,
  50. * HCCP will be pulled to perform set communication related operations.
  51. * @retval TDT_OK Success
  52. * @retval OtherValues Failure
  53. *
  54. * @par Dependency
  55. * @li libtsdclient.so: Library to which the interface belongs.
  56. * @li tsd_client.h: Header file where the interface declaration is located.
  57. * @li data_common.h: Header file where 'TDT_StatusT' defined
  58. */
  59. TDT_LIB_EXPORT uint32_t TsdOpen(const uint32_t logicDeviceId, const uint32_t rankSize);
  60. /**
  61. * @ingroup Open
  62. * @brief Used for the Framework process to communicate with the TSDDaemon process in 1981,
  63. * and notify TSD to complete the initialization of other processes
  64. *
  65. * @par Function
  66. * Used for the Framework process to communicate with the TSDDaemon process,
  67. * and notify TSD to complete the initialization of other processes
  68. *
  69. * @param logicDeviceId [IN] type #unsigned int. Logic device ID
  70. * @param rankSize [IN] type #unsigned int. The rankSize of the training.
  71. * The default value is 1. When rankSize is greater than 1,
  72. * HCCP will be pulled to perform set communication related operations.
  73. * @param deviceMode [IN] type unsigned int. The device running mode of aicpuSd,
  74. * it include chipMode and DieMode
  75. * @retval TDT_OK Success
  76. * @retval OtherValues Failure
  77. *
  78. * @par Dependency
  79. * @li data_common.h: Header file where 'TDT_StatusT' defined
  80. */
  81. TDT_LIB_EXPORT uint32_t TsdOpenEx(const uint32_t logicDeviceId, const uint32_t rankSize, const uint32_t deviceMode);
  82. /**
  83. * @ingroup InitialQs
  84. * @brief Used for the Framework process to communicate with the TSDDaemon process,
  85. * and notify TSD to complete the initialization of QS processes
  86. *
  87. * @par Function
  88. * Used for the Framework process to communicate with the TSDDaemon process,
  89. * and notify TSD to complete the initialization of other processes
  90. *
  91. * @param logicDeviceId [IN] type #unsigned int. Logic device ID
  92. * @param groupName [IN] type #char pointer. qs group name send by host process
  93. * @retval TDT_OK Success
  94. * @retval OtherValues Failure
  95. *
  96. * @par Dependency
  97. * @li libtsdclient.so: Library to which the interface belongs.
  98. * @li tsd_client.h: Header file where the interface declaration is located.
  99. * @li data_common.h: Header file where 'TDT_StatusT' defined
  100. */
  101. TDT_LIB_EXPORT uint32_t TsdInitQs(const uint32_t logicDeviceId, const char_t * const groupName = nullptr);
  102. /**
  103. * @ingroup InitFlowGw
  104. * @brief Used for the Framework process to communicate with the TSDDaemon process,
  105. * and notify TSD to complete the initialization of FlowGw processes
  106. *
  107. * @par Function
  108. * Used for the Framework process to communicate with the TSDDaemon process,
  109. * and notify TSD to complete the initialization of other processes
  110. *
  111. * @param logicDeviceId [IN] type #unsigned int. Logic device ID
  112. * @param initInfo [IN] type #InitFlowGwInfo pointer. Initialization parameters
  113. * @retval TDT_OK Success
  114. * @retval OtherValues Failure
  115. *
  116. * @par Dependency
  117. * @li libtsdclient.so: Library to which the interface belongs.
  118. * @li tsd_client.h: Header file where the interface declaration is located.
  119. * @li data_common.h: Header file where 'TDT_StatusT' defined
  120. */
  121. TDT_LIB_EXPORT uint32_t TsdInitFlowGw(const uint32_t logicDeviceId, const InitFlowGwInfo * const initInfo);
  122. /**
  123. * @ingroup Close
  124. * @brief notify TSDClient close resource
  125. *
  126. * @par Function
  127. * notify TSDClient close resource
  128. *
  129. * @param NA
  130. * @retval TDT_OK Success
  131. * @retval OtherValues Failure
  132. *
  133. * @par Dependency
  134. * @li libtsdclient.so: Library to which the interface belongs.
  135. * @li tsd_client.h: Header file where the interface declaration is located.
  136. * @li data_common.h: Header file where 'TDT_StatusT' defined
  137. */
  138. TDT_LIB_EXPORT uint32_t TsdClose(const uint32_t logicDeviceId);
  139. /**
  140. * @ingroup UpdateProfilingMode
  141. * @brief notify TSDClient update profiling mode
  142. *
  143. * @par Function
  144. * notify TSDClient update profiling mode
  145. *
  146. * @param NA
  147. * @retval TDT_OK Success
  148. * @retval OtherValues Failure
  149. *
  150. * @par Dependency
  151. * @li libtsdclient.so: Library to which the interface belongs.
  152. * @li tsd_client.h: Header file where the interface declaration is located.
  153. * @li data_common.h: Header file where 'TDT_StatusT' defined
  154. */
  155. TDT_LIB_EXPORT uint32_t UpdateProfilingMode(const uint32_t logicDeviceId, const uint32_t flag);
  156. /**
  157. * @ingroup TsdSetMsprofReporterCallback
  158. * @brief 用于推理场景下设置aicpu的profilng的callback函数
  159. *
  160. * @par Function
  161. * 设置offline模式下aicpu_sd进程的profiling的callback函数
  162. *
  163. * @param callback [IN] type #MsprofReporterCallback. 回调函数
  164. * @retval TDT_OK Success
  165. * @retval OtherValues Failure
  166. *
  167. * @par Dependency
  168. * @li libtsdclient.so: Library to which the interface belongs.
  169. * @li tsd_client.h: Header file where the interface declaration is located.
  170. * @li data_common.h: Header file where 'TDT_StatusT' defined
  171. * @li prof_callback.h: Headerfile where 'MsprofReporterCallback' defined
  172. */
  173. TDT_LIB_EXPORT uint32_t TsdSetMsprofReporterCallback(const MsprofReporterCallback callback);
  174. /**
  175. * @ingroup TsdSetAttr
  176. * @brief used to set tsd attr
  177. *
  178. * @par key
  179. * key set for tsd attr,now only support RunMode
  180. *
  181. * @par value
  182. * value set to run correspond mode, PROCESS_MODE or THREAD_MODE
  183. * @retval TDT_OK Success
  184. * @retval OtherValues Failure
  185. */
  186. TDT_LIB_EXPORT uint32_t TsdSetAttr(const char * const attrKey, const char * const attrValue);
  187. #ifdef __cplusplus
  188. }
  189. #endif // __cplusplus
  190. #endif // TDT_HOST_INNER_INC_TSD_CLIENT_H

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