Updated PR#196 to use a common hash function
This commit is contained in:
parent
01d1836668
commit
fad079a8ae
@ -11,7 +11,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
ncclResult_t getHostName(char* hostname, int maxlen, const char delim);
|
ncclResult_t getHostName(char* hostname, int maxlen, const char delim);
|
||||||
uint64_t getnHash(const char* string, int n);
|
uint64_t getHash(const char* string, int n);
|
||||||
uint64_t getHostHash();
|
uint64_t getHostHash();
|
||||||
uint64_t getPidHash();
|
uint64_t getPidHash();
|
||||||
|
|
||||||
|
@ -691,8 +691,8 @@ static ncclResult_t initTransportsRank(struct ncclComm* comm, ncclUniqueId* comm
|
|||||||
|
|
||||||
int rank = comm->rank;
|
int rank = comm->rank;
|
||||||
int nranks = comm->nRanks;
|
int nranks = comm->nRanks;
|
||||||
uint64_t commHash = getnHash(commId->internal, NCCL_UNIQUE_ID_BYTES);
|
uint64_t commHash = getHash(commId->internal, NCCL_UNIQUE_ID_BYTES);
|
||||||
TRACE(NCCL_INIT, "comm %p, commHash %lu, rank %d nranks %d - BEGIN", comm, commHash, rank, nranks);
|
TRACE(NCCL_INIT, "comm %p, commHash %lx, rank %d nranks %d - BEGIN", comm, commHash, rank, nranks);
|
||||||
NCCLCHECK(bootstrapInit(commId, rank, nranks, &comm->bootstrap));
|
NCCLCHECK(bootstrapInit(commId, rank, nranks, &comm->bootstrap));
|
||||||
|
|
||||||
// AllGather1 - begin
|
// AllGather1 - begin
|
||||||
|
@ -87,18 +87,9 @@ void ncclDebugLog(ncclDebugLogLevel level, unsigned long flags, const char *file
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t getHash(const char* string) {
|
uint64_t getHash(const char* string, int n) {
|
||||||
// Based on DJB2, result = result * 33 + char
|
// Based on DJB2, result = result * 33 + char
|
||||||
uint64_t result = 5381;
|
uint64_t result = 5381;
|
||||||
for (int c = 0; string[c] != '\0'; c++) {
|
|
||||||
result = ((result << 5) + result) + string[c];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t getnHash(const char* string, int n) {
|
|
||||||
// Based on DJB2, result = result * 33 + char
|
|
||||||
uint64_t result = 9527;
|
|
||||||
for (int c = 0; c < n; c++) {
|
for (int c = 0; c < n; c++) {
|
||||||
result = ((result << 5) + result) + string[c];
|
result = ((result << 5) + result) + string[c];
|
||||||
}
|
}
|
||||||
@ -129,7 +120,7 @@ uint64_t getHostHash(void) {
|
|||||||
uname[offset]='\0';
|
uname[offset]='\0';
|
||||||
TRACE(NCCL_INIT,"unique hostname '%s'", uname);
|
TRACE(NCCL_INIT,"unique hostname '%s'", uname);
|
||||||
|
|
||||||
return getHash(uname);
|
return getHash(uname, strlen(uname));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generate a hash of the unique identifying string for this process
|
/* Generate a hash of the unique identifying string for this process
|
||||||
@ -149,7 +140,7 @@ uint64_t getPidHash(void) {
|
|||||||
pname[plen+len]='\0';
|
pname[plen+len]='\0';
|
||||||
TRACE(NCCL_INIT,"unique PID '%s'", pname);
|
TRACE(NCCL_INIT,"unique PID '%s'", pname);
|
||||||
|
|
||||||
return getHash(pname);
|
return getHash(pname, strlen(pname));
|
||||||
}
|
}
|
||||||
|
|
||||||
int parseStringList(const char* string, struct netIf* ifList, int maxList) {
|
int parseStringList(const char* string, struct netIf* ifList, int maxList) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user