From bf748d6880d7b581afc27ccfd68a7c13c0d11258 Mon Sep 17 00:00:00 2001 From: Nicholas Sielicki Date: Wed, 11 Sep 2024 13:19:05 -0700 Subject: [PATCH] fix(tree): add fallthrough switch markers (#585) Signed-off-by: Nicholas Sielicki --- include/nccl_ofi_config_bottom.h | 6 ++++++ src/nccl_ofi_rdma.c | 12 ++++++++---- src/nccl_ofi_sendrecv.c | 6 ++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/nccl_ofi_config_bottom.h b/include/nccl_ofi_config_bottom.h index eb065ae51..901f10c2b 100644 --- a/include/nccl_ofi_config_bottom.h +++ b/include/nccl_ofi_config_bottom.h @@ -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) \ diff --git a/src/nccl_ofi_rdma.c b/src/nccl_ofi_rdma.c index a79a0d38d..1728c646b 100644 --- a/src/nccl_ofi_rdma.c +++ b/src/nccl_ofi_rdma.c @@ -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, @@ -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 */ @@ -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, @@ -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 */ @@ -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 @@ -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 diff --git a/src/nccl_ofi_sendrecv.c b/src/nccl_ofi_sendrecv.c index 32f1269fa..257baf0b7 100644 --- a/src/nccl_ofi_sendrecv.c +++ b/src/nccl_ofi_sendrecv.c @@ -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 */ @@ -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 */ @@ -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); @@ -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");