Skip to content

Commit

Permalink
fix(tree): use decltype instead of typeof for cxx (#565)
Browse files Browse the repository at this point in the history
* fix(tree): use decltype instead of typeof for cxx

Signed-off-by: Nicholas Sielicki <[email protected]>
  • Loading branch information
aws-nslick authored Sep 27, 2024
1 parent 34c8a09 commit 61a29ab
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions include/nccl_ofi_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ extern "C" {
* @param a
* Must be a power of two
*/
#ifndef __cplusplus
#define NCCL_OFI_IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
#else
#define NCCL_OFI_IS_ALIGNED(x, a) (((x) & ((decltype(x))(a) - 1)) == 0)
#endif

/*
* @brief Return true if and only if pointer `p` is `a`-byte aligned
Expand Down
11 changes: 11 additions & 0 deletions src/nccl_ofi_cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,24 @@ void *nccl_net_ofi_cuFlushGPUDirectRDMAWrites = NULL;

#define STRINGIFY(sym) # sym

#ifndef __cplusplus
#define LOAD_SYM(sym) \
nccl_net_ofi_##sym = (typeof(sym) *)dlsym(cudadriver_lib, STRINGIFY(sym)); \
if (nccl_net_ofi_##sym == NULL) { \
NCCL_OFI_WARN("Failed to load symbol " STRINGIFY(sym)); \
ret = -ENOTSUP; \
goto error; \
}
#else
#define LOAD_SYM(sym) \
nccl_net_ofi_##sym = (decltype(sym) *)dlsym(cudadriver_lib, STRINGIFY(sym)); \
if (nccl_net_ofi_##sym == NULL) { \
NCCL_OFI_WARN("Failed to load symbol " STRINGIFY(sym)); \
ret = -ENOTSUP; \
goto error; \
}
#endif


int
nccl_net_ofi_cuda_init(void)
Expand Down
6 changes: 2 additions & 4 deletions src/tuner/nccl_ofi_tuner.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ ncclResult_t nccl_ofi_tuner_get_coll_info(void *context,

if (nccl_ofi_tuner_ctx == NULL || nccl_ofi_tuner_ctx->regions == NULL || collType != ncclFuncAllReduce) {
/* Fall back to NCCL's tuner */
goto exit;
return ncclSuccess;
}

float(*table)[NCCL_NUM_PROTOCOLS] = (float(*)[NCCL_NUM_PROTOCOLS])collCostTable;
Expand Down Expand Up @@ -373,7 +373,6 @@ ncclResult_t nccl_ofi_tuner_get_coll_info(void *context,
NCCL_OFI_INFO(NCCL_TUNING, "Falling back to NCCL's tuner for coll %d size %ld.", collType, nBytes);
}

exit:
return ncclSuccess;
}

Expand Down Expand Up @@ -406,7 +405,7 @@ ncclResult_t nccl_ofi_tuner_get_coll_info_v2(

if (nccl_ofi_tuner_ctx == NULL || nccl_ofi_tuner_ctx->regions == NULL || collType != ncclFuncAllReduce) {
/* Fall back to NCCL's tuner */
goto exit;
return ncclSuccess;
}

int in_out = -1;
Expand Down Expand Up @@ -437,7 +436,6 @@ ncclResult_t nccl_ofi_tuner_get_coll_info_v2(
NCCL_OFI_INFO(NCCL_TUNING, "Falling back to NCCL's tuner for coll %d size %ld.", collType, nBytes);
}

exit:
return ncclSuccess;
}

Expand Down

0 comments on commit 61a29ab

Please sign in to comment.