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

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

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