From 92cc920b722c0c6938e61e0bc087f68b35dbf48f Mon Sep 17 00:00:00 2001 From: Nicholas Sielicki Date: Wed, 4 Sep 2024 13:12:00 -0700 Subject: [PATCH] fix(tuner): avoid gotos --- src/tuner/nccl_ofi_tuner.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/tuner/nccl_ofi_tuner.c b/src/tuner/nccl_ofi_tuner.c index 5f7d26414..1b19d7707 100644 --- a/src/tuner/nccl_ofi_tuner.c +++ b/src/tuner/nccl_ofi_tuner.c @@ -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; @@ -347,7 +347,7 @@ ncclResult_t nccl_ofi_tuner_get_coll_info(void *context, nccl_ofi_tuner_point_t p = {.x = nBytes, .y = nccl_ofi_tuner_ctx->dims.num_ranks}; /* Check all regions */ - for (int i = 0; i < nccl_ofi_tuner_ctx->num_regions && in_out < 0; i++) { + for (size_t i = 0; i < nccl_ofi_tuner_ctx->num_regions && in_out < 0; i++) { algorithm = nccl_ofi_tuner_ctx->regions[i].algorithm; protocol = nccl_ofi_tuner_ctx->regions[i].protocol; if (table[algorithm][protocol] == NCCL_ALGO_PROTO_IGNORE || algorithm >= numAlgo || @@ -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; } @@ -406,14 +405,14 @@ 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; nccl_ofi_tuner_point_t p = {.x = nBytes, .y = nccl_ofi_tuner_ctx->dims.num_ranks}; /* Check all regions */ - for (int i = 0; i < nccl_ofi_tuner_ctx->num_regions && in_out < 0; i++) { + for (size_t i = 0; i < nccl_ofi_tuner_ctx->num_regions && in_out < 0; i++) { if (nccl_ofi_tuner_ctx->regions[i].algorithm == NCCL_ALGO_NVLS_TREE && nvlsSupport == 0) { continue; } @@ -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; }