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.

hccl.h 7.5 kB

3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /**
  2. * Copyright 2019-2022 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. /**
  17. * @file hccl.h
  18. * @brief HCCL API
  19. */
  20. #ifndef HCCL_H_
  21. #define HCCL_H_
  22. #include <hccl/hccl_types.h>
  23. #include <acl/acl.h>
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif // __cplusplus
  27. /**
  28. * @brief Initialize HCCL.
  29. *
  30. * @param clusterInfo A string identifying the cluster info file path, include file name.
  31. * @param rank A integer identifying the identify for the rank.
  32. * @param comm A pointer identifying the initialized communication resource.
  33. * @return HcclResult
  34. * @see HcclCommDestroy()
  35. */
  36. extern HcclResult HcclCommInitClusterInfo(const char *clusterInfo, uint32_t rank, HcclComm *comm);
  37. /**
  38. * @brief Get hccl root info.
  39. *
  40. * @param rootInfo A pointer identifying the hccl root info.
  41. * @return HcclResult
  42. */
  43. extern HcclResult HcclGetRootInfo(HcclRootInfo *rootInfo);
  44. /**
  45. * @brief Initialize HCCL with root info.
  46. *
  47. * @param nRanks A integer identifying the rank size of the cluster.
  48. * @param rootInfo A struct identifying the hccl root info.
  49. * @param rank A integer identifying the identify for the rank.
  50. * @param comm A pointer identifying the initialized communication resource.
  51. * @return HcclResult
  52. * @see HcclCommDestroy()
  53. */
  54. extern HcclResult HcclCommInitRootInfo(uint32_t nRanks, const HcclRootInfo *rootInfo, uint32_t rank, HcclComm *comm);
  55. /**
  56. * @brief AllReduce operator.
  57. *
  58. * @param sendBuf A pointer identifying the input data address of the operator.
  59. * @param recvBuf A pointer identifying the output data address of the operator.
  60. * @param count An integer(u64) identifying the number of the output data.
  61. * @param dataType The data type of the operator, must be one of the following types: int8, int16, int32, float16,
  62. * float32.
  63. * @param op The reduction type of the operator, must be one of the following types: sum, min, max, prod.
  64. * @param comm A pointer identifying the communication resource based on.
  65. * @param stream A pointer identifying the stream information.
  66. * @return HcclResult
  67. */
  68. extern HcclResult HcclAllReduce(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, HcclReduceOp op,
  69. HcclComm comm, aclrtStream stream);
  70. /**
  71. * @brief Broadcast operator.
  72. *
  73. * @param buf A pointer identifying the data address of the operator.
  74. * @param count An integer(u64) identifying the number of the data.
  75. * @param dataType The data type of the operator, must be one of the following types: int8, int32, float16, float32.
  76. * @param root An integer(u32) identifying the the root rank in the operator.
  77. * @param comm A pointer identifying the communication resource based on
  78. * @param stream A pointer identifying the stream information.
  79. * @return HcclResult
  80. */
  81. extern HcclResult HcclBroadcast(void *buf, uint64_t count, HcclDataType dataType, uint32_t root, HcclComm comm,
  82. aclrtStream stream);
  83. /**
  84. * @brief ReduceScatter operator.
  85. *
  86. * @param sendBuf A pointer identifying the input data address of the operator.
  87. * @param recvBuf A pointer identifying the output data address of the operator.
  88. * @param recvCount An integer(u64) identifying the number of the output data.
  89. * @param dataType The data type of the operator, must be one of the following types: int8, int32, float16, float32.
  90. * @param op The reduction type of the operator, must be one of the following types: sum, min, max, prod.
  91. * @param comm A pointer identifying the communication resource based on.
  92. * @param stream A pointer identifying the stream information.
  93. * @return HcclResult
  94. */
  95. extern HcclResult HcclReduceScatter(void *sendBuf, void *recvBuf, uint64_t recvCount, HcclDataType dataType,
  96. HcclReduceOp op, HcclComm comm, aclrtStream stream);
  97. /**
  98. * @brief AllGather operator.
  99. *
  100. * @param sendBuf A pointer identifying the input data address of the operator.
  101. * @param recvBuf A pointer identifying the output data address of the operator.
  102. * @param sendCount An integer(u64) identifying the number of the input data.
  103. * @param dataType The data type of the operator, must be one of the following types: int8, int32, float16, float32.
  104. * @param comm A pointer identifying the communication resource based on.
  105. * @param stream A pointer identifying the stream information.
  106. * @return HcclResult
  107. */
  108. extern HcclResult HcclAllGather(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm,
  109. aclrtStream stream);
  110. /**
  111. * @brief Get the rank size of this comm.
  112. *
  113. * @param comm A pointer identifying the communication resource based on.
  114. * @param rankSize A pointer identifying the rank size.
  115. * @return HcclResult
  116. */
  117. extern HcclResult HcclGetRankSize(HcclComm comm, uint32_t *rankSize);
  118. /**
  119. * @brief Get the rank id of this comm.
  120. *
  121. * @param comm A pointer identifying the communication resource based on.
  122. * @param rankSize A pointer identifying the rank id.
  123. * @return HcclResult
  124. */
  125. extern HcclResult HcclGetRankId(HcclComm comm, uint32_t *rank);
  126. /**
  127. * @brief Barrier operator.
  128. *
  129. * @param comm A pointer identifying the communication resource based on.
  130. * @param stream A pointer identifying the stream information.
  131. * @return HcclResult
  132. */
  133. extern HcclResult HcclBarrier(HcclComm comm, aclrtStream stream);
  134. /**
  135. * @brief AllGather operator.
  136. *
  137. * @param sendBuff A pointer identifying the input data address of the operator.
  138. * @param count An integer(u64) identifying the number of the send data.
  139. * @param dataType The data type of the operator, must be one of the following types: int8, int32, float16, float32.
  140. * @param destRank An integer identifying the destination rank.
  141. * @param comm A pointer identifying the communication resource based on.
  142. * @param stream A pointer identifying the stream information.
  143. * @return HcclResult
  144. */
  145. extern HcclResult HcclSend(void *sendBuf, uint64_t count, HcclDataType dataType, uint32_t destRank, HcclComm comm,
  146. aclrtStream stream);
  147. /**
  148. * @brief AllGather operator.
  149. *
  150. * @param recvBuff A pointer identifying the output data address of the operator.
  151. * @param count An integer(u64) identifying the number of the receive data.
  152. * @param dataType The data type of the operator, must be one of the following types: int8, int32, float16, float32.
  153. * @param srcRank An integer identifying the source rank.
  154. * @param comm A pointer identifying the communication resource based on.
  155. * @param stream A pointer identifying the stream information.
  156. * @return HcclResult
  157. */
  158. extern HcclResult HcclRecv(void *recvBuf, uint64_t count, HcclDataType dataType, uint32_t srcRank, HcclComm comm,
  159. aclrtStream stream);
  160. /**
  161. * @brief Destroy HCCL comm
  162. *
  163. * @param comm A pointer identifying the communication resource targetting
  164. * @return HcclResult
  165. * @see HcclCommInitClusterInfo()
  166. */
  167. extern HcclResult HcclCommDestroy(HcclComm comm);
  168. #ifdef __cplusplus
  169. }
  170. #endif // __cplusplus
  171. #endif // HCCL_H_

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