Merged
[CherryPick] adaptor high version gcc g++ #1163
Yuanhao JiAdd on Mar 21
[CherryPick] adaptor high version gcc g++ #1163
Merged
Yuanhao JiAdd on Mar 21
Total: 23 files changed+70-55
@@ -539,9 +539,11 @@ fi
539cd ${BUILD_DIR}539cd ${BUILD_DIR}
540 540 
541if [ "${ENABLE_UT}" == "on" ]; then541if [ "${ENABLE_UT}" == "on" ]; then
542+ bash ${CURRENT_DIR}/build_third_party.sh
542 build_ut543 build_ut
543 # make_ut_gov544 # make_ut_gov
544elif [ -n "${TEST}" ];then545elif [ -n "${TEST}" ];then
546+ bash ${CURRENT_DIR}/build_third_party.sh
545 build_test547 build_test
546elif [ "${KERNEL}" == "true" ]; then548elif [ "${KERNEL}" == "true" ]; then
547 build_kernel549 build_kernel
@@ -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) {
@@ -294,7 +294,7 @@ HcclResult CommConfig::SetConfigDeterministic(const CommConfigHandle &config)
294 294 
295HcclResult CommConfig::SetConfigCommName(const CommConfigHandle &config)295HcclResult CommConfig::SetConfigCommName(const CommConfigHandle &config)
296{296{
297- if (config.commName != nullptr && config.commName[0] != '\0') {297+ if (config.commName[0] != '\0') {
298 auto commNameLength = strlen(config.commName);298 auto commNameLength = strlen(config.commName);
299 commNameLength = commNameLength < COMM_NAME_MAX_LENGTH ? commNameLength : COMM_NAME_MAX_LENGTH;299 commNameLength = commNameLength < COMM_NAME_MAX_LENGTH ? commNameLength : COMM_NAME_MAX_LENGTH;
300 commName_ = std::string(config.commName, commNameLength);300 commName_ = std::string(config.commName, commNameLength);
@@ -304,21 +304,19 @@ HcclResult CommConfig::SetConfigCommName(const CommConfigHandle &config)
304 304 
305HcclResult CommConfig::SetConfigUdi(const CommConfigHandle &config)305HcclResult CommConfig::SetConfigUdi(const CommConfigHandle &config)
306{306{
307- if (config.udi != nullptr) {307+ if (config.udi[0] == '\0') {
308- if (config.udi[0] == '\0') {308+ udi_ = "Unspecified";
309- udi_ = "Unspecified";309+ return HCCL_SUCCESS;
310- return HCCL_SUCCESS;
311- }
312- auto udiLength = strlen(config.udi);
313- udiLength = udiLength < COMM_NAME_MAX_LENGTH ? udiLength : COMM_NAME_MAX_LENGTH;
314- udi_ = std::string(config.udi, udiLength);
315 }310 }
311+ auto udiLength = strlen(config.udi);
312+ udiLength = udiLength < COMM_NAME_MAX_LENGTH ? udiLength : COMM_NAME_MAX_LENGTH;
313+ udi_ = std::string(config.udi, udiLength);
316 return HCCL_SUCCESS;314 return HCCL_SUCCESS;
317}315}
318 316 
319HcclResult CommConfig::SetConfigBufferName(const CommConfigHandle &config)317HcclResult CommConfig::SetConfigBufferName(const CommConfigHandle &config)
320{318{
321- if (config.bufferName != nullptr && config.bufferName[0] != '\0') {319+ if (config.bufferName[0] != '\0') {
322 auto bufferNameLength = strlen(config.bufferName);320 auto bufferNameLength = strlen(config.bufferName);
323 bufferNameLength = bufferNameLength < BUFFER_NAME_MAX_LENGTH ? bufferNameLength : BUFFER_NAME_MAX_LENGTH;321 bufferNameLength = bufferNameLength < BUFFER_NAME_MAX_LENGTH ? bufferNameLength : BUFFER_NAME_MAX_LENGTH;
324 bufferName_ = std::string(config.bufferName, bufferNameLength);322 bufferName_ = std::string(config.bufferName, bufferNameLength);
@@ -400,7 +398,7 @@ HcclResult CommConfig::SetConfigExecTimeout(const CommConfigHandle &config)
400 398
401HcclResult CommConfig::SetConfigHcclAlgo(const CommConfigHandle &config)399HcclResult CommConfig::SetConfigHcclAlgo(const CommConfigHandle &config)
402{400{
403- if (config.hcclAlgo == nullptr || config.hcclAlgo[0] == '\0') {401+ if (config.hcclAlgo[0] == '\0') {
404 return HCCL_SUCCESS;402 return HCCL_SUCCESS;
405 }403 }
406 404
@@ -434,7 +432,7 @@ HcclResult CommConfig::SetConfigHcclAlgo(const CommConfigHandle &config)
434 432
435HcclResult CommConfig::SetConfigHcclRetryEnable(const CommConfigHandle &config)433HcclResult CommConfig::SetConfigHcclRetryEnable(const CommConfigHandle &config)
436{434{
437- if (config.hcclRetryEnable == nullptr || config.hcclRetryEnable[0] == '\0') {435+ if (config.hcclRetryEnable[0] == '\0') {
438 return HCCL_SUCCESS;436 return HCCL_SUCCESS;
439 }437 }
440 auto retryEnableLength = strlen(config.hcclRetryEnable);438 auto retryEnableLength = strlen(config.hcclRetryEnable);
@@ -540,7 +538,7 @@ HcclResult CommConfig::SetConfigRetryEnable(const std::vector<std::string> &retr
540 538
541HcclResult CommConfig::SetConfigHcclRetryParams(const CommConfigHandle &config)539HcclResult CommConfig::SetConfigHcclRetryParams(const CommConfigHandle &config)
542{540{
543- if (config.hcclRetryParams == nullptr || config.hcclRetryParams[0] == '\0') {541+ if (config.hcclRetryParams[0] == '\0') {
544 return HCCL_SUCCESS;542 return HCCL_SUCCESS;
545 }543 }
546 auto retryParamsLength = strlen(config.hcclRetryParams);544 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) {
L

请确认这个修改是否能保障逻辑正常

likedislike
Yuanhao Ji
Yuanhao Ji
Mar 21 Comments:
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"
@@ -792,7 +793,7 @@ DfsConfig CastDfsConfig(const std::string &dfsConfigEnv)
792 }793 }
793 }794 }
794 }795 }
795- DfsConfig config{.taskExceptionEnable = taskExceptionEnable};796+ DfsConfig config{taskExceptionEnable};
796 HCCL_RUN_INFO("[Parse] HCCL_DFS_CONFIG task_exception set by environment to [%d]", config.taskExceptionEnable);797 HCCL_RUN_INFO("[Parse] HCCL_DFS_CONFIG task_exception set by environment to [%d]", config.taskExceptionEnable);
797 return config;798 return config;
798}799}
@@ -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