Memory leak fixes in hostside functions (#1388)

memory leak fixes for parseRome4P2H and ncclTopoAddGPU
Этот коммит содержится в:
Avinash
2024-10-30 14:25:56 -05:00
коммит произвёл GitHub
родитель fd9924cfe7
Коммит d6006f0425
3 изменённых файлов: 10 добавлений и 3 удалений
+5 -1
Просмотреть файл
@@ -1391,12 +1391,16 @@ static bool checkOption(const char *options, const char *name) {
numTokens++;
while (tokens[numTokens-1] != NULL && numTokens < MAX_OPT_TOKENS)
tokens[numTokens++] = strtok_r(NULL, "=, ", &state);
bool result = false;
for (int i = 0; i < numTokens/2; i++) {
if (strcmp(tokens[i*2], name) == 0) {
return (bool)atol(tokens[i*2+1]);
result = (bool)atol(tokens[i*2+1]);
break;
}
}
free(str_temp);
return result;
}
return false;
}
+2 -1
Просмотреть файл
@@ -400,7 +400,8 @@ ncclResult_t ncclTopoAddGpu(struct ncclXmlNode* xmlGpu, struct ncclTopoSystem* s
const char* gcnArchName;
NCCLCHECK(xmlGetAttr(xmlGpu, "gcn", &gcnArch));
convertGcnArchToGcnArchName(gcnArch, &gcnArchName);
gpu->gpu.gcn = strdup(gcnArchName);
strncpy(gpu->gpu.gcn, gcnArchName, GCN_ARCH_NAME_LEN-1);
gpu->gpu.gcn[GCN_ARCH_NAME_LEN-1] = '\0';
rcclHipDeviceArch_t arch;
NCCLCHECK(xmlGetAttrInt(xmlGpu, "arch", &arch.value));
memcpy(&gpu->gpu.arch, &arch.arch, sizeof(hipDeviceArch_t));
+3 -1
Просмотреть файл
@@ -121,6 +121,8 @@ struct ncclTopoLinkList {
#define RCCL_TOPO_FORCE_INTRA 16
#define RCCL_TOPO_XGMI_ALL 32
#define GCN_ARCH_NAME_LEN 16
struct ncclTopoNode {
int type;
int64_t id;
@@ -131,7 +133,7 @@ struct ncclTopoNode {
int rank;
int cudaCompCap;
int gdrSupport;
const char* gcn;
char gcn[GCN_ARCH_NAME_LEN];
hipDeviceArch_t arch;
int cu;
}gpu;