Merged
adaptor high version gcc g++ #478
tianmingLAdd on Feb 11
adaptor high version gcc g++ #478
Merged
tianmingLAdd on Feb 11
Total: 22 files changed+68-55
@@ -7,6 +7,8 @@
7#ifndef CCU_CONTEXT_ASSIST_PUB_H7#ifndef CCU_CONTEXT_ASSIST_PUB_H
8#define CCU_CONTEXT_ASSIST_PUB_H8#define CCU_CONTEXT_ASSIST_PUB_H
9 9 
10+#include <cstdint>
11+ 
10namespace hcomm {12namespace hcomm {
11namespace CcuRep {13namespace CcuRep {
12 14 
@@ -24,6 +24,7 @@ public:
24 HcclResult GetAdjInfo(AlgResourceResponse& algRes, AdjInfo& adjInfo) override;24 HcclResult GetAdjInfo(AlgResourceResponse& algRes, AdjInfo& adjInfo) override;
25 25 
26private:26private:
27+ using CollNativeExecutorBase::CalcCommInfo;
27 /* *************** 资源计算 *************** */28 /* *************** 资源计算 *************** */
28 HcclResult CalcResRequest(const OpParam& param, AlgResourceRequest &resourceRequest) override;29 HcclResult CalcResRequest(const OpParam& param, AlgResourceRequest &resourceRequest) override;
29 HcclResult CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport, u32 srcRank);30 HcclResult CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport, u32 srcRank);
@@ -24,6 +24,7 @@ public:
24 HcclResult GetAdjInfo(AlgResourceResponse& algRes, AdjInfo& adjInfo) override;24 HcclResult GetAdjInfo(AlgResourceResponse& algRes, AdjInfo& adjInfo) override;
25 25 
26private:26private:
27+ using CollNativeExecutorBase::CalcCommInfo;
27 /* *************** 资源计算 *************** */28 /* *************** 资源计算 *************** */
28 HcclResult CalcResRequest(const OpParam& param, AlgResourceRequest &resourceRequest) override;29 HcclResult CalcResRequest(const OpParam& param, AlgResourceRequest &resourceRequest) override;
29 HcclResult CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport, u32 dstRank);30 HcclResult CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport, u32 dstRank);
@@ -279,7 +279,7 @@ HcclResult Heartbeat::RegisterRanks(DevType devType, const RankInfo &locRank, st
279 mapLock.unlock();279 mapLock.unlock();
280 280 
281 std::unique_lock<std::mutex> lock(ProcessLock_);281 std::unique_lock<std::mutex> lock(ProcessLock_);
282- for (const auto remRank : rankInfos) {282+ for (const auto& remRank : rankInfos) {
283 UIDType rem = GetUId(remRank);283 UIDType rem = GetUId(remRank);
284 rankId2StatusMap_.insert(rem, Status());284 rankId2StatusMap_.insert(rem, Status());
285 groupMap_[group].insert(std::make_pair(rem, NO_CONN));285 groupMap_[group].insert(std::make_pair(rem, NO_CONN));
@@ -549,7 +549,7 @@ HcclResult Heartbeat::UnRegisterRanks(const std::string &group)
549 return HCCL_SUCCESS;549 return HCCL_SUCCESS;
550 }550 }
551 551 
552- for (const auto remRank : groupMap_[group]) {552+ for (const auto& remRank : groupMap_[group]) {
553 UIDType rem = remRank.first;553 UIDType rem = remRank.first;
554 rankId2StatusMap_.erase(rem);554 rankId2StatusMap_.erase(rem);
555 if (remRank.second == HAS_CONN) {555 if (remRank.second == HAS_CONN) {
@@ -306,7 +306,7 @@ HcclResult CommConfig::SetConfigDeterministic(const CommConfigHandle &config)
306 306 
307HcclResult CommConfig::SetConfigCommName(const CommConfigHandle &config)307HcclResult CommConfig::SetConfigCommName(const CommConfigHandle &config)
308{308{
309- if (config.commName != nullptr && config.commName[0] != '\0') {309+ if (config.commName[0] != '\0') {
310 auto commNameLength = strlen(config.commName);310 auto commNameLength = strlen(config.commName);
311 commNameLength = commNameLength < COMM_NAME_MAX_LENGTH ? commNameLength : COMM_NAME_MAX_LENGTH;311 commNameLength = commNameLength < COMM_NAME_MAX_LENGTH ? commNameLength : COMM_NAME_MAX_LENGTH;
312 commName_ = std::string(config.commName, commNameLength);312 commName_ = std::string(config.commName, commNameLength);
@@ -316,21 +316,19 @@ HcclResult CommConfig::SetConfigCommName(const CommConfigHandle &config)
316 316 
317HcclResult CommConfig::SetConfigUdi(const CommConfigHandle &config)317HcclResult CommConfig::SetConfigUdi(const CommConfigHandle &config)
318{318{
319- if (config.udi != nullptr) {319+ if (config.udi[0] == '\0') {
320- if (config.udi[0] == '\0') {320+ udi_ = "Unspecified";
321- udi_ = "Unspecified";321+ return HCCL_SUCCESS;
322- return HCCL_SUCCESS;
323- }
324- auto udiLength = strlen(config.udi);
325- udiLength = udiLength < COMM_NAME_MAX_LENGTH ? udiLength : COMM_NAME_MAX_LENGTH;
326- udi_ = std::string(config.udi, udiLength);
327 }322 }
323+ auto udiLength = strlen(config.udi);
324+ udiLength = udiLength < COMM_NAME_MAX_LENGTH ? udiLength : COMM_NAME_MAX_LENGTH;
325+ udi_ = std::string(config.udi, udiLength);
328 return HCCL_SUCCESS;326 return HCCL_SUCCESS;
329}327}
330 328 
331HcclResult CommConfig::SetConfigBufferName(const CommConfigHandle &config)329HcclResult CommConfig::SetConfigBufferName(const CommConfigHandle &config)
332{330{
333- if (config.bufferName != nullptr && config.bufferName[0] != '\0') {331+ if (config.bufferName[0] != '\0') {
334 auto bufferNameLength = strlen(config.bufferName);332 auto bufferNameLength = strlen(config.bufferName);
335 bufferNameLength = bufferNameLength < BUFFER_NAME_MAX_LENGTH ? bufferNameLength : BUFFER_NAME_MAX_LENGTH;333 bufferNameLength = bufferNameLength < BUFFER_NAME_MAX_LENGTH ? bufferNameLength : BUFFER_NAME_MAX_LENGTH;
336 bufferName_ = std::string(config.bufferName, bufferNameLength);334 bufferName_ = std::string(config.bufferName, bufferNameLength);
@@ -420,7 +418,7 @@ HcclResult CommConfig::SetConfigExecTimeout(const CommConfigHandle &config)
420 418
421HcclResult CommConfig::SetConfigHcclAlgo(const CommConfigHandle &config)419HcclResult CommConfig::SetConfigHcclAlgo(const CommConfigHandle &config)
422{420{
423- if (config.hcclAlgo == nullptr || config.hcclAlgo[0] == '\0') {421+ if (config.hcclAlgo[0] == '\0') {
424 return HCCL_SUCCESS;422 return HCCL_SUCCESS;
425 }423 }
426 424
@@ -454,7 +452,7 @@ HcclResult CommConfig::SetConfigHcclAlgo(const CommConfigHandle &config)
454 452
455HcclResult CommConfig::SetConfigHcclRetryEnable(const CommConfigHandle &config)453HcclResult CommConfig::SetConfigHcclRetryEnable(const CommConfigHandle &config)
456{454{
457- if (config.hcclRetryEnable == nullptr || config.hcclRetryEnable[0] == '\0') {455+ if (config.hcclRetryEnable[0] == '\0') {
458 return HCCL_SUCCESS;456 return HCCL_SUCCESS;
459 }457 }
460 auto retryEnableLength = strlen(config.hcclRetryEnable);458 auto retryEnableLength = strlen(config.hcclRetryEnable);
@@ -560,7 +558,7 @@ HcclResult CommConfig::SetConfigRetryEnable(const std::vector<std::string> &retr
560 558
561HcclResult CommConfig::SetConfigHcclRetryParams(const CommConfigHandle &config)559HcclResult CommConfig::SetConfigHcclRetryParams(const CommConfigHandle &config)
562{560{
563- if (config.hcclRetryParams == nullptr || config.hcclRetryParams[0] == '\0') {561+ if (config.hcclRetryParams[0] == '\0') {
564 return HCCL_SUCCESS;562 return HCCL_SUCCESS;
565 }563 }
566 auto retryParamsLength = strlen(config.hcclRetryParams);564 auto retryParamsLength = strlen(config.hcclRetryParams);
@@ -109,7 +109,7 @@ std::unique_ptr<CcuContext> CcuInsPreprocessor::CreateCcuCtx(const CcuInstructio
109 __func__, transports.size(), createStatus, linkGroup.GetLinks().size(), cntCkeNum, createStatus,109 __func__, transports.size(), createStatus, linkGroup.GetLinks().size(), cntCkeNum, createStatus,
110 ccuInst.GetInstType().Describe().c_str());110 ccuInst.GetInstType().Describe().c_str());
111 111 
112- std::unique_ptr<CcuCtxArg> ctxArg = std::move(ccuInst.GetCtxArg());112+ std::unique_ptr<CcuCtxArg> ctxArg = ccuInst.GetCtxArg();
113 CHECK_NULLPTR(ctxArg, "[CcuInsPreprocessor::CreateCcuCtx] ctxArg is nullptr!");113 CHECK_NULLPTR(ctxArg, "[CcuInsPreprocessor::CreateCcuCtx] ctxArg is nullptr!");
114 return CcuCtxCreatorRegistry::GetInstance().GetCreateFunc(ccuInst.GetInstType())(*ctxArg, transports,114 return CcuCtxCreatorRegistry::GetInstance().GetCreateFunc(ccuInst.GetInstType())(*ctxArg, transports,
115 *transportGrp);115 *transportGrp);
@@ -353,7 +353,7 @@ void CommunicatorImpl::TraceOpInfo(const CollOpParams &opParams) const
353 HcclSendRecvItem *sendRecvItems353 HcclSendRecvItem *sendRecvItems
354 = static_cast<HcclSendRecvItem *>(opParams.batchSendRecvDataDes.sendRecvItemsPtr);354 = static_cast<HcclSendRecvItem *>(opParams.batchSendRecvDataDes.sendRecvItemsPtr);
355 for (u32 i = 0; i < itemNum; ++i) {355 for (u32 i = 0; i < itemNum; ++i) {
356- if ((sendRecvItems + i) == nullptr || (sendRecvItems + i)->buf == nullptr) {356+ if ((sendRecvItems + i)->buf == nullptr) {
357 continue;357 continue;
358 }358 }
359 auto info359 auto info
@@ -12,6 +12,7 @@
12 12 
13#include <map>13#include <map>
14#include <memory>14#include <memory>
15+#include <array>
15#include "dfx_common.h"16#include "dfx_common.h"
16#include "queue.h"17#include "queue.h"
17#include "task_info.h"18#include "task_info.h"
@@ -55,7 +55,7 @@ static OpType GetOpTypeV2(std::string opTypeName) {
55 55 
56static void LoadConfigCommName(string &commId, const HcclCommConfig &config)56static void LoadConfigCommName(string &commId, const HcclCommConfig &config)
57{57{
58- if (config.hcclCommName == nullptr || config.hcclCommName[0] == '\0') {58+ if (config.hcclCommName[0] == '\0') {
59 HCCL_WARNING("[LoadConfigCommName] config.hcclCommName is empty, use default commId[%s]", commId.c_str());59 HCCL_WARNING("[LoadConfigCommName] config.hcclCommName is empty, use default commId[%s]", commId.c_str());
60 return;60 return;
61 }61 }
@@ -17,6 +17,7 @@
17#include <sstream>17#include <sstream>
18#include <set>18#include <set>
19#include <unordered_map>19#include <unordered_map>
20+#include <array>
20 21 
21#include "sal.h"22#include "sal.h"
22#include "string_util.h"23#include "string_util.h"
@@ -771,7 +772,7 @@ DfsConfig CastDfsConfig(const std::string &dfsConfigEnv)
771 }772 }
772 }773 }
773 }774 }
774- DfsConfig config{.taskExceptionEnable = taskExceptionEnable};775+ DfsConfig config{taskExceptionEnable};
775 HCCL_RUN_INFO("[Parse] HCCL_DFS_CONFIG task_exception set by environment to [%d]", config.taskExceptionEnable);776 HCCL_RUN_INFO("[Parse] HCCL_DFS_CONFIG task_exception set by environment to [%d]", config.taskExceptionEnable);
776 return config;777 return config;
777}778}
@@ -11,6 +11,11 @@
11#ifndef TOPO_COMMON_TYPES_H11#ifndef TOPO_COMMON_TYPES_H
12#define TOPO_COMMON_TYPES_H12#define TOPO_COMMON_TYPES_H
13 13 
14+#include <cstdint>
15+#include <cstring>
16+#include <netinet/in.h>
17+ 
18+#include "hccl_res.h"
14#include "enum_factory.h"19#include "enum_factory.h"
15#include "hccl/base.h"20#include "hccl/base.h"
16#include "hccl_rank_graph.h"21#include "hccl_rank_graph.h"
@@ -33,6 +38,34 @@ MAKE_ENUM(TopoType, CLOS, MESH_1D, MESH_2D, A3_SERVER, A2_AX_SERVER)
33constexpr LocalId BACKUP_LOCAL_ID = 64;38constexpr LocalId BACKUP_LOCAL_ID = 64;
34} // namespace Hccl39} // namespace Hccl
35 40 
41+inline bool operator==(const CommAddr& lhs, const CommAddr& rhs) {
42+ // 类型不同,直接不等
43+ if (lhs.type != rhs.type) {
44+ return false;
45+ }
46+ 
47+ // 类型相同,根据类型比较具体数据
48+ switch (lhs.type) {
49+ case COMM_ADDR_TYPE_IP_V4:
50+ return lhs.addr.s_addr == rhs.addr.s_addr;
51+ 
52+ case COMM_ADDR_TYPE_IP_V6:
53+ // 比较 IPv6 地址的 16 字节
54+ return memcmp(lhs.addr6.s6_addr, rhs.addr6.s6_addr, sizeof(lhs.addr6.s6_addr)) == 0;
55+ 
56+ case COMM_ADDR_TYPE_ID:
57+ return lhs.id == rhs.id;
58+ 
59+ case COMM_ADDR_TYPE_EID:
60+ // 假设 COMM_ADDR_EID_LEN 是一个常量,比如 16
61+ return memcmp(lhs.eid, rhs.eid, COMM_ADDR_EID_LEN) == 0;
62+ 
63+ case COMM_ADDR_TYPE_RESERVED:
64+ default:
65+ return true;
66+ }
67+}
68+ 
36namespace std {69namespace std {
37template <>70template <>
38struct hash<Hccl::LinkProtocol> {71struct hash<Hccl::LinkProtocol> {
@@ -101,35 +134,6 @@ struct hash<CommAddr> {
101 }134 }
102};135};
103 136 
104-inline bool operator==(const CommAddr& lhs, const CommAddr& rhs) {
105- // 类型不同,直接不等
106- if (lhs.type != rhs.type) {
107- return false;
108- }
109- 
110- // 类型相同,根据类型比较具体数据
111- switch (lhs.type) {
112- case COMM_ADDR_TYPE_IP_V4:
113- return lhs.addr.s_addr == rhs.addr.s_addr;
114- 
115- case COMM_ADDR_TYPE_IP_V6:
116- // 比较 IPv6 地址的 16 字节
117- return memcmp(lhs.addr6.s6_addr, rhs.addr6.s6_addr, sizeof(lhs.addr6.s6_addr)) == 0;
118- 
119- case COMM_ADDR_TYPE_ID:
120- return lhs.id == rhs.id;
121- 
122- case COMM_ADDR_TYPE_EID:
123- // 假设 COMM_ADDR_EID_LEN 是一个常量,比如 16
124- return memcmp(lhs.eid, rhs.eid, COMM_ADDR_EID_LEN) == 0;
125- 
126- case COMM_ADDR_TYPE_RESERVED:
127- default:
128- return true;
129- }
130-}
131- 
132- 
133template <>137template <>
134struct hash<std::pair<CommAddr, CommProtocol>> {138struct hash<std::pair<CommAddr, CommProtocol>> {
135 size_t operator()(const std::pair<CommAddr, CommProtocol>& key) const139 size_t operator()(const std::pair<CommAddr, CommProtocol>& key) const
@@ -16,6 +16,8 @@
16#include <string>16#include <string>
17#include <memory>17#include <memory>
18#include <unordered_map>18#include <unordered_map>
19+#include <utility>
20+ 
19#include "graph.h"21#include "graph.h"
20#include "ip_address.h"22#include "ip_address.h"
21#include "iterator.h"23#include "iterator.h"
@@ -8,6 +8,7 @@
8 * See LICENSE in the root of the software repository for the full text of the License.8 * See LICENSE in the root of the software repository for the full text of the License.
9 */9 */
10 10 
11+#include <unordered_map>
11#include "virtual_topo.h"12#include "virtual_topo.h"
12#include "string_util.h"13#include "string_util.h"
13#include "binary_stream.h"14#include "binary_stream.h"
@@ -8,6 +8,7 @@
8 * See LICENSE in the root of the software repository for the full text of the License.8 * See LICENSE in the root of the software repository for the full text of the License.
9 */9 */
10 10 
11+#include <array>
11#include "rank_graph_builder.h"12#include "rank_graph_builder.h"
12#include "detour_service.h"13#include "detour_service.h"
13#include "env_func.h"14#include "env_func.h"
@@ -334,7 +335,7 @@ void RankGraphBuilder::BuildFromRankTable()
334 335 
335std::shared_ptr<NetInstance> RankGraphBuilder::GetNetInstance(const RankLevelInfo &levelInfo){336std::shared_ptr<NetInstance> RankGraphBuilder::GetNetInstance(const RankLevelInfo &levelInfo){
336 auto it = tempNetInsts_[levelInfo.netLayer].find(levelInfo.netInstId);337 auto it = tempNetInsts_[levelInfo.netLayer].find(levelInfo.netInstId);
337- if (it != tempNetInsts_[levelInfo.netLayer].end()) {338+ if (it == tempNetInsts_[levelInfo.netLayer].end()) {
338 return nullptr;339 return nullptr;
339 }340 }
340 // 若NetInstance存在, type不一致则报错341 // 若NetInstance存在, type不一致则报错
@@ -11,6 +11,7 @@
11#ifndef CCU_DEVICE_MANAGER_H11#ifndef CCU_DEVICE_MANAGER_H
12#define CCU_DEVICE_MANAGER_H12#define CCU_DEVICE_MANAGER_H
13 13 
14+#include <array>
14#include "hccl/hccl_types.h"15#include "hccl/hccl_types.h"
15 16 
16#include "ip_address.h"17#include "ip_address.h"
@@ -12,6 +12,7 @@
12#define HCCL_CCU_REPRESENTATION_BASE12#define HCCL_CCU_REPRESENTATION_BASE
13 13 
14#include <string>14#include <string>
15+#include <cstdint>
15 16 
16#include "ccu_microcode.h"17#include "ccu_microcode.h"
17#include "ccu_rep_type.h"18#include "ccu_rep_type.h"
@@ -73,10 +73,6 @@ HcclResult SqeMgr::Add(u32 sqId, HcclSqe *sqe)
73 }73 }
74 74 
75 void *nextBufferAddr = static_cast<u8 *>(sqInfo->sqeBuffer) + sqInfo->sqeCnt * AC_SQE_SIZE;75 void *nextBufferAddr = static_cast<u8 *>(sqInfo->sqeBuffer) + sqInfo->sqeCnt * AC_SQE_SIZE;
76- if (sqInfo->sqeBuffer == nullptr) {
77- HCCL_ERROR("SqeMgr::Add sqInfo->sqeBuffer is nullptr");
78- return HcclResult::HCCL_E_PTR;
79- }
80 76 
81 HCCL_INFO("SqeMgr::%s sqe->GetSqe() %llu", __func__, sqe->GetSqe());77 HCCL_INFO("SqeMgr::%s sqe->GetSqe() %llu", __func__, sqe->GetSqe());
82 78 
@@ -8,6 +8,7 @@
8 * See LICENSE in the root of the software repository for the full text of the License.8 * See LICENSE in the root of the software repository for the full text of the License.
9 */9 */
10 10 
11+#include <cstdint>
11#include <iostream>12#include <iostream>
12#include <fstream>13#include <fstream>
13#include <string>14#include <string>
@@ -111,8 +111,8 @@ HcclResult HcclNetDevCloseV1(HcclNetDev netDev)
111 break;111 break;
112 }112 }
113 default:113 default:
114- delete pNetDevCtx;
115 HCCL_ERROR("[HcclNetDevClose]No Such HcclNetDevDeployment: %d", pNetDevCtx->GetNetDevDeployment());114 HCCL_ERROR("[HcclNetDevClose]No Such HcclNetDevDeployment: %d", pNetDevCtx->GetNetDevDeployment());
115+ delete pNetDevCtx;
116 return HCCL_E_NOT_SUPPORT;116 return HCCL_E_NOT_SUPPORT;
117 }117 }
118 118 
@@ -13,6 +13,7 @@
13 13 
14#include <mutex>14#include <mutex>
15#include <map>15#include <map>
16+#include <array>
16#include "hccl/base.h"17#include "hccl/base.h"
17#include "mem_name_repository_pub.h"18#include "mem_name_repository_pub.h"
18#include "local_ipc_notify.h"19#include "local_ipc_notify.h"
@@ -96,7 +96,7 @@ HcclResult TransportDirectNpu::GetLocalNotifyValueAddrKey(std::vector<AddrKey> &
96 96 
97HcclResult TransportDirectNpu::GetLocalRdmaNotify(std::vector<HcclSignalInfo> &rdmaNotify)97HcclResult TransportDirectNpu::GetLocalRdmaNotify(std::vector<HcclSignalInfo> &rdmaNotify)
98{98{
99- HcclSignalInfo signalInfo;99+ HcclSignalInfo signalInfo = {};
100 rdmaNotify.push_back(signalInfo);100 rdmaNotify.push_back(signalInfo);
101 rdmaNotify.push_back(signalInfo);101 rdmaNotify.push_back(signalInfo);
102 rdmaNotify.push_back(signalInfo);102 rdmaNotify.push_back(signalInfo);
@@ -113,6 +113,7 @@ public:
113 HcclRtContext rtCtx);113 HcclRtContext rtCtx);
114 ~TransportShmEvent() override;114 ~TransportShmEvent() override;
115 115 
116+ using TransportHeterog::Init;
116 HcclResult Init() override;117 HcclResult Init() override;
117 HcclResult Init(TransportShmEventMember transport);118 HcclResult Init(TransportShmEventMember transport);
118 119