From 494bb9039406c935fac32adcee6a72704345afd9 Mon Sep 17 00:00:00 2001 From: Eleanor Green Date: Mon, 10 Mar 2025 10:25:43 +0000 Subject: [PATCH] fixed a few bugs in the graph/ module --- src/graph/search.cc | 3 +-- src/graph/topo.cc | 2 +- src/graph/tuning.cc | 7 +++++++ src/graph/xml.cc | 3 ++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/graph/search.cc b/src/graph/search.cc index 0185b3f7b..49a47a509 100644 --- a/src/graph/search.cc +++ b/src/graph/search.cc @@ -328,8 +328,7 @@ ncclResult_t ncclTopoReplayGetGpu(struct ncclTopoSystem* system, struct ncclTopo *g = i; return ncclSuccess; } - if (*g == -1) return ncclInternalError; - return ncclSuccess; + return ncclInternalError; } ncclResult_t ncclTopoSearchRecGpu(struct ncclTopoSystem* system, struct ncclTopoGraph* graph, struct ncclTopoGraph* saveGraph, struct ncclTopoNode* gpu, int step, int backToNet, int backToFirstRank, int forcedOrder, int *time); diff --git a/src/graph/topo.cc b/src/graph/topo.cc index ba82cafb7..f5c36687e 100644 --- a/src/graph/topo.cc +++ b/src/graph/topo.cc @@ -246,7 +246,7 @@ ncclResult_t ncclTopoFlattenBcmSwitches(struct ncclTopoSystem* system) { pciSwitch->pci.device |= 0xffff; free(subSwIds); // Restart, as system->nodes[PCI].nodes has changed. - s = 0; + s = -1; // Will be incremented to 0 in the next loop iteration continue; fail: free(subSwIds); diff --git a/src/graph/tuning.cc b/src/graph/tuning.cc index 8da4aeb9e..1b164ef9f 100644 --- a/src/graph/tuning.cc +++ b/src/graph/tuning.cc @@ -65,6 +65,8 @@ ncclResult_t parseList(const char* str, const char* prefixElems[], int nprefixes // because then all the prefixes before the prefix-less entry would be // overwritten. WARN("All entries except the first must have a prefix: \"%s\"", str); + free(subToken); + free(fullStr); return ncclInvalidUsage; } elemList = prefix; @@ -97,6 +99,9 @@ ncclResult_t parseList(const char* str, const char* prefixElems[], int nprefixes } if (e==nelems) { WARN("Unrecognized element token \"%s\" when parsing \"%s\"", elem, str); + free(tokStr); + free(subToken); + free(fullStr); return ncclInvalidUsage; } elem = strtok_r(NULL, ",", &tmpStr); @@ -105,6 +110,8 @@ ncclResult_t parseList(const char* str, const char* prefixElems[], int nprefixes } if (!foundPrefix) { WARN("Unrecognized prefix token \"%s\" when parsing \"%s\"", prefix, str); + free(subToken); + free(fullStr); return ncclInvalidUsage; } free(subToken); diff --git a/src/graph/xml.cc b/src/graph/xml.cc index a41289389..bfa136919 100644 --- a/src/graph/xml.cc +++ b/src/graph/xml.cc @@ -51,10 +51,11 @@ ncclResult_t xmlGetValue(FILE* file, char* value, char* last) { #endif } int o = 0; + char quote = c; // Remember which quote type we started with do { NCCLCHECK(xmlGetChar(file, &c)); value[o++] = c; - } while (c != '"'); + } while (c != quote); value[o-1] = '\0'; NCCLCHECK(xmlGetChar(file, last)); return ncclSuccess;