Skip to content

Commit

Permalink
fix(tuner): avoid gotos
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-nslick committed Sep 4, 2024
1 parent 743e062 commit 92cc920
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 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 All @@ -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 ||
Expand All @@ -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,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;
}
Expand All @@ -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 92cc920

Please sign in to comment.