Fix clang build (#271)
Clang doesn't understand `optimize("O0")`. It has `noopt`, which GCC doesn't understand. Wrap the difference in a macro.
This commit is contained in:
parent
299c554dcc
commit
8c564e9b57
10
src/init.cc
10
src/init.cc
@ -124,10 +124,18 @@ ncclResult_t ncclGetUniqueId(ncclUniqueId* out) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prevent compiler from optimizing out these operations
|
// Prevent compiler from optimizing out these operations
|
||||||
void __attribute__((optimize("O0"))) commPoison(ncclComm_t comm) {
|
#ifdef __clang__
|
||||||
|
#define NCCL_NO_OPTIMIZE __attribute__((noopt)))
|
||||||
|
#else
|
||||||
|
#define NCCL_NO_OPTIMIZE __attribute__((optimize("O0")))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void NCCL_NO_OPTIMIZE commPoison(ncclComm_t comm) {
|
||||||
comm->rank = comm->cudaDev = comm->busId = comm->nRanks = -1;
|
comm->rank = comm->cudaDev = comm->busId = comm->nRanks = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef NCCL_NO_OPTIMIZE
|
||||||
|
|
||||||
static ncclResult_t commFree(ncclComm_t comm) {
|
static ncclResult_t commFree(ncclComm_t comm) {
|
||||||
if (comm == NULL)
|
if (comm == NULL)
|
||||||
return ncclSuccess;
|
return ncclSuccess;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user