Adding pthread_join / pthread_detach to clean up pthreads to avoid leaks (#322)
This commit is contained in:
gecommit door
GitHub
bovenliggende
7191d0959b
commit
f4a9b9acba
@@ -194,6 +194,7 @@ ncclResult_t bootstrapCreateRoot(ncclUniqueId* id, bool idFromEnv) {
|
|||||||
rootStruct->hash = djb2Hash(id->internal);
|
rootStruct->hash = djb2Hash(id->internal);
|
||||||
rootStruct->listenFd = listenFd;
|
rootStruct->listenFd = listenFd;
|
||||||
pthread_create(&thread, NULL, bootstrapRoot, (void *)rootStruct);
|
pthread_create(&thread, NULL, bootstrapRoot, (void *)rootStruct);
|
||||||
|
pthread_detach(thread); // [RCCL] Adding detach to properly clean up bootstrapRoot thread
|
||||||
// [/RCCL]
|
// [/RCCL]
|
||||||
|
|
||||||
return ncclSuccess;
|
return ncclSuccess;
|
||||||
@@ -533,7 +534,9 @@ ncclResult_t bootstrapClose(void* commState) {
|
|||||||
state->allocState->stop = 1;
|
state->allocState->stop = 1;
|
||||||
|
|
||||||
// Join the allocThread so we catch resource leaks as being hung here
|
// Join the allocThread so we catch resource leaks as being hung here
|
||||||
// pthread_join(state->allocThread, nullptr);
|
// [RCCL] Uncommenting this join to clean up the allocThread
|
||||||
|
pthread_join(state->allocThread, nullptr);
|
||||||
|
// [/RCCL]
|
||||||
|
|
||||||
free(state->peerCommAddresses);
|
free(state->peerCommAddresses);
|
||||||
free(state->peerAllocAddresses);
|
free(state->peerAllocAddresses);
|
||||||
|
|||||||
@@ -186,6 +186,9 @@ ncclResult_t ncclIbInit(ncclDebugLogger_t logFunction) {
|
|||||||
ncclNIbDevs++;
|
ncclNIbDevs++;
|
||||||
nPorts++;
|
nPorts++;
|
||||||
pthread_create(&ncclIbAsyncThread, NULL, ncclIbAsyncThreadMain, context);
|
pthread_create(&ncclIbAsyncThread, NULL, ncclIbAsyncThreadMain, context);
|
||||||
|
// [RCCL]
|
||||||
|
pthread_detach(ncclIbAsyncThread);
|
||||||
|
// [/RCCL]
|
||||||
}
|
}
|
||||||
if (nPorts == 0 && ncclSuccess != wrap_ibv_close_device(context)) { return ncclInternalError; }
|
if (nPorts == 0 && ncclSuccess != wrap_ibv_close_device(context)) { return ncclInternalError; }
|
||||||
}
|
}
|
||||||
@@ -915,4 +918,3 @@ ncclNet_t ncclNetIb = {
|
|||||||
ncclIbCloseRecv,
|
ncclIbCloseRecv,
|
||||||
ncclIbCloseListen
|
ncclIbCloseListen
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Verwijs in nieuw issue
Block a user