Add pthread_detach()'s for threads we never pthread_join(). Helps

reduce diagnostic noise for ThreadSanitizer.

Fixes https://github.com/NVIDIA/nccl/issues/649
This commit is contained in:
John Bachan 2022-03-14 17:09:08 -07:00
parent 3c223c105a
commit 44eb40da0e
3 changed files with 3 additions and 0 deletions

View File

@ -165,6 +165,7 @@ ncclResult_t bootstrapCreateRoot(ncclUniqueId* id, bool idFromEnv) {
memcpy(id, &listenSock->addr, sizeof(union ncclSocketAddress)); memcpy(id, &listenSock->addr, sizeof(union ncclSocketAddress));
pthread_t thread; pthread_t thread;
pthread_create(&thread, NULL, bootstrapRoot, (void*)listenSock); pthread_create(&thread, NULL, bootstrapRoot, (void*)listenSock);
pthread_detach(thread); // will not be pthread_join()'d
ncclSetThreadName(thread, "NCCL BootstrapR"); ncclSetThreadName(thread, "NCCL BootstrapR");
return ncclSuccess; return ncclSuccess;
} }

View File

@ -1073,6 +1073,7 @@ ncclResult_t ncclProxyInit(struct ncclComm* comm, struct ncclSocket* sock, union
} }
ncclResult_t ncclProxyCreate(struct ncclComm* comm) { ncclResult_t ncclProxyCreate(struct ncclComm* comm) {
// comm->proxyState.thread is pthread_join()'d by commFree() in init.cc
pthread_create(&comm->proxyState.thread, NULL, ncclProxyService, comm); pthread_create(&comm->proxyState.thread, NULL, ncclProxyService, comm);
return ncclSuccess; return ncclSuccess;
} }

View File

@ -223,6 +223,7 @@ ncclResult_t ncclIbInit(ncclDebugLogger_t logFunction) {
ncclIbDevs[ncclNIbDevs].mrCache.slots = NULL; ncclIbDevs[ncclNIbDevs].mrCache.slots = NULL;
pthread_create(&ncclIbAsyncThread, NULL, ncclIbAsyncThreadMain, context); pthread_create(&ncclIbAsyncThread, NULL, ncclIbAsyncThreadMain, context);
pthread_detach(ncclIbAsyncThread); // will not be pthread_join()'d
ncclSetThreadName(ncclIbAsyncThread, "NCCL IbAsync %2d", ncclNIbDevs); ncclSetThreadName(ncclIbAsyncThread, "NCCL IbAsync %2d", ncclNIbDevs);
ncclNIbDevs++; ncclNIbDevs++;
nPorts++; nPorts++;