Skip to content

Commit

Permalink
fix(tree): add fallthrough switch markers (aws#585)
Browse files Browse the repository at this point in the history
Signed-off-by: Nicholas Sielicki <[email protected]>
  • Loading branch information
aws-nslick committed Sep 30, 2024
1 parent 105142c commit bf748d6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
6 changes: 6 additions & 0 deletions include/nccl_ofi_config_bottom.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
#define PATH_MAX 4096
#endif

#if __has_attribute(__fallthrough__)
# define fallthrough __attribute__((__fallthrough__))
#else
# define fallthrough do {} while (0) /* fallthrough */
#endif

/* Copied from libfabric:rdma/fabric.h@30ec628: "libfabric: Initial commit" */
#ifndef container_of
#define container_of(ptr, type, field) \
Expand Down
12 changes: 8 additions & 4 deletions src/nccl_ofi_rdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -4530,10 +4530,12 @@ static int accept(nccl_net_ofi_listen_comm_t *listen_comm,

l_comm->stage = COMM_RECV_CONN;

fallthrough;
case COMM_RECV_CONN:

l_comm->stage = COMM_CONN_REQ_PENDING;

fallthrough;
case COMM_CONN_REQ_PENDING:
/* COMM_CONN_REQ_PENDING: Wait until connect message has been
* received. Then, prepare for sending connect accept message,
Expand Down Expand Up @@ -4608,6 +4610,7 @@ static int accept(nccl_net_ofi_listen_comm_t *listen_comm,

l_comm->stage = COMM_SEND_CONN;

fallthrough;
case COMM_SEND_CONN:

/* COMM_SEND_CONN: Send connect response message to remote */
Expand All @@ -4621,6 +4624,7 @@ static int accept(nccl_net_ofi_listen_comm_t *listen_comm,

l_comm->stage = COMM_CONN_RESP_REQ_PENDING;

fallthrough;
case COMM_CONN_RESP_REQ_PENDING:
/* COMM_CONN_RESP_REQ_PENDING: Wait until connect
* response message has been delivered. Afterwards,
Expand Down Expand Up @@ -6200,7 +6204,7 @@ static int connect(nccl_net_ofi_ep_t *base_ep,
}

comm_state->stage = COMM_SEND_CONN;

fallthrough;
case COMM_SEND_CONN:

/* COMM_SEND_CONN: Post a connect message to send peer connections */
Expand All @@ -6215,7 +6219,7 @@ static int connect(nccl_net_ofi_ep_t *base_ep,
}

comm_state->stage = COMM_CONN_REQ_PENDING;

fallthrough;
case COMM_CONN_REQ_PENDING:
/* COMM_CONN_REQ_PENDING: Wait until connect message
* has been sent. Afterwards, reset previously used
Expand Down Expand Up @@ -6246,14 +6250,14 @@ static int connect(nccl_net_ofi_ep_t *base_ep,
req = NULL;

comm_state->stage = COMM_RECV_CONN;

fallthrough;
case COMM_RECV_CONN:
/* COMM_RECV_CONN: Receive connect response message from remote */

assert(s_comm && s_comm->num_rails > 0);

comm_state->stage = COMM_CONN_RESP_REQ_PENDING;

fallthrough;
case COMM_CONN_RESP_REQ_PENDING:

/* Progress our engine to get completions. If the
Expand Down
6 changes: 4 additions & 2 deletions src/nccl_ofi_sendrecv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ static int accept(nccl_net_ofi_listen_comm_t *listen_comm,
}

comm_state->stage = COMM_RECV_CONN;

fallthrough;
case COMM_RECV_CONN:

/* Allocate memory for peer address for the first time ONLY */
Expand All @@ -1437,6 +1437,7 @@ static int accept(nccl_net_ofi_listen_comm_t *listen_comm,

comm_state->stage = COMM_CONN_REQ_PENDING;

fallthrough;
case COMM_CONN_REQ_PENDING:

/* Progress NCCL OFI engine so that connection is accepted */
Expand Down Expand Up @@ -2047,6 +2048,7 @@ static int connect(nccl_net_ofi_ep_t *base_ep,

comm_state->stage = COMM_SEND_CONN;

fallthrough;
case COMM_SEND_CONN:
/* Send "connect" message to remote EP */
rc = send_connect_message(s_comm, device, ep, req);
Expand All @@ -2063,7 +2065,7 @@ static int connect(nccl_net_ofi_ep_t *base_ep,
}

comm_state->stage = COMM_CONN_REQ_PENDING;

fallthrough;
case COMM_CONN_REQ_PENDING:
if (s_comm->conn_info->connect_to_self == 1) {
NCCL_OFI_TRACE(NCCL_NET, "Connect to self; short circuit cleanup");
Expand Down

0 comments on commit bf748d6

Please sign in to comment.