Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/graph/search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Author

@eleanorTurintech eleanorTurintech Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the for-loop above, if a GPU with the specified rank is found, the function sets *g to the index of the GPU and return ncclSuccess. If the for-loop completes without returning, *g would remain as the initial value of -1, therefore the if-statement for checking *g value is redundant. It also means the final return statement will be unreachable.

The fix removes the redundant if-statement and return ncclInternalError directly.

}

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);
Expand Down
2 changes: 1 addition & 1 deletion src/graph/topo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions src/graph/tuning.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/graph/xml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix allows the quote to be either " or ', and correctly matches the ending quote.

value[o-1] = '\0';
NCCLCHECK(xmlGetChar(file, last));
return ncclSuccess;
Expand Down