[mpich2-commits] r5529 - mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp
buntinas at mcs.anl.gov
buntinas at mcs.anl.gov
Thu Oct 22 09:55:56 CDT 2009
Author: buntinas
Date: 2009-10-22 09:55:56 -0500 (Thu, 22 Oct 2009)
New Revision: 5529
Modified:
mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/socksm.c
mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/socksm.h
mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_impl.h
mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_init.c
mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_send.c
mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_utility.c
Log:
squashed warnings about type-punning
Modified: mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/socksm.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/socksm.c 2009-10-22 14:42:47 UTC (rev 5528)
+++ mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/socksm.c 2009-10-22 14:55:56 UTC (rev 5529)
@@ -196,7 +196,7 @@
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static int expand_sc_plfd_tbls (void)
{
- int mpi_errno = MPI_SUCCESS;
+ int mpi_errno = MPI_SUCCESS;
sockconn_t *new_sc_tbl = NULL;
struct pollfd *new_plfd_tbl = NULL;
int new_capacity = g_tbl_capacity + CONN_PLFD_TBL_GROW_SIZE, i;
@@ -216,14 +216,17 @@
are updated here after the expand. */
for (i = 1; i < g_tbl_capacity; i++) /* i=0 = listening socket fd won't have a VC pointer */
{
+ sockconn_t *new_sc = &new_sc_tbl[i];
+ sockconn_t *sc = &g_sc_tbl[i];
+ MPIDI_VC_t *vc = sc->vc;
+ MPID_nem_tcp_vc_area *vc_tcp = VC_TCP(vc);
+
/* It's important to only make the assignment if the sc address in the
vc matches the old sc address, otherwise we can corrupt the vc's
state in certain head-to-head situations. */
- if (g_sc_tbl[i].vc &&
- VC_FIELD(g_sc_tbl[i].vc, sc) &&
- VC_FIELD(g_sc_tbl[i].vc, sc) == &g_sc_tbl[i])
+ if (vc && vc_tcp->sc && vc_tcp->sc == sc)
{
- ASSIGN_SC_TO_VC(g_sc_tbl[i].vc, &new_sc_tbl[i]);
+ ASSIGN_SC_TO_VC(vc_tcp, new_sc);
}
}
@@ -240,17 +243,20 @@
MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "expand_sc_plfd_tbls af g_sc_tbl[0].fd=%d", g_sc_tbl[0].fd));
for (i = 0; i < g_tbl_capacity; ++i)
{
- /* sockconn_t *dbg_sc = g_sc_tbl[i].vc ? VC_FIELD(g_sc_tbl[i].vc, sc) : (sockconn_t*)(-1); */
+ sockconn_t *sc = &g_sc_tbl[i];
+ MPIDI_VC_t *vc = sc->vc;
+ MPID_nem_tcp_vc_area *vc_tcp = VC_TCP(vc);
+ /* sockconn_t *dbg_sc = g_sc_tbl[i].vc ? VC_FIELD(g_sc_tbl[i].vc, sc) : (sockconn_t*)(-1); */
/* The state is only valid if the FD is valid. The VC field is only
valid if the state is valid and COMMRDY. */
MPIU_Assert(MPID_nem_tcp_plfd_tbl[i].fd == CONN_INVALID_FD ||
- g_sc_tbl[i].state.cstate != CONN_STATE_TS_COMMRDY ||
- VC_FIELD(g_sc_tbl[i].vc, sc) == &g_sc_tbl[i]);
+ sc->state.cstate != CONN_STATE_TS_COMMRDY ||
+ vc_tcp->sc == sc);
}
- MPIU_CHKPMEM_COMMIT();
+ MPIU_CHKPMEM_COMMIT();
fn_exit:
MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "expand_sc_plfd_tbls Exit"));
return mpi_errno;
@@ -583,7 +589,7 @@
"**read", "**read %s", strerror (errno)); /* FIXME-Z1 */
if (pg_id_len == 0) {
sc->is_same_pg = TRUE;
- mpi_errno = MPID_nem_tcp_get_vc_from_conninfo (MPIDI_Process.my_pg->id,
+ mpi_errno = MPID_nem_tcp_get_vc_from_conninfo (MPIDI_Process.my_pg->id,
sc->pg_rank, &sc->vc);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
sc->pg_id = NULL;
@@ -595,10 +601,15 @@
sc->pg_id = sc->vc->pg->id;
}
- MPIU_Assert(sc->vc != NULL);
- MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "about to incr sc_ref_count sc=%p sc->vc=%p sc_ref_count=%d", sc, sc->vc, VC_FIELD(sc->vc, sc_ref_count)));
- ++VC_FIELD(sc->vc, sc_ref_count);
+ { /* Added this block sp we can declare pointers to tcp private area of vc */
+ MPIDI_VC_t *sc_vc = sc->vc;
+ MPID_nem_tcp_vc_area *sc_vc_tcp = VC_TCP(sc_vc);
+ MPIU_Assert(sc_vc != NULL);
+ MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "about to incr sc_ref_count sc=%p sc->vc=%p sc_ref_count=%d", sc, sc_vc, sc_vc_tcp->sc_ref_count));
+ ++sc_vc_tcp->sc_ref_count;
+ }
+
/* very important, without this IS_SAME_CONNECTION will always fail */
sc->pg_is_set = TRUE;
@@ -606,6 +617,7 @@
}
else if (hdr.pkt_type == MPIDI_NEM_TCP_PKT_TMPVC_INFO) {
MPIDI_VC_t *vc;
+ MPID_nem_tcp_vc_area *vc_tcp;
MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "PKT_TMPVC_INFO: sc->fd=%d", sc->fd));
/* create a new VC */
@@ -617,13 +629,15 @@
}
/* --END ERROR HANDLING-- */
- MPIDI_VC_Init(vc, NULL, 0);
+ vc_tcp = VC_TCP(vc);
+
+ MPIDI_VC_Init(vc, NULL, 0);
((MPIDI_CH3I_VC *)vc->channel_private)->state = MPID_NEM_TCP_VC_STATE_CONNECTED; /* FIXME: is it needed ? */
- sc->vc = vc;
- MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "about to incr sc_ref_count sc=%p sc->vc=%p sc_ref_count=%d", sc, sc->vc, VC_FIELD(sc->vc, sc_ref_count)));
- ++VC_FIELD(vc, sc_ref_count);
+ sc->vc = vc;
+ MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "about to incr sc_ref_count sc=%p sc->vc=%p sc_ref_count=%d", sc, sc->vc, vc_tcp->sc_ref_count));
+ ++vc_tcp->sc_ref_count;
- ASSIGN_SC_TO_VC(vc, sc);
+ ASSIGN_SC_TO_VC(vc_tcp, sc);
/* get the port's tag from the packet and stash it in the VC */
iov[0].iov_base = (void *) &(sc->vc->port_name_tag);
@@ -744,6 +758,7 @@
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPID_nem_tcp_connect(struct MPIDI_VC *const vc)
{
+ MPID_nem_tcp_vc_area *const vc_tcp = VC_TCP(vc);
sockconn_t *sc = NULL;
struct pollfd *plfd = NULL;
int index = -1;
@@ -766,7 +781,7 @@
struct in_addr addr;
int rc = 0;
- MPIU_Assert(VC_FIELD(vc, sc) == NULL);
+ MPIU_Assert(vc_tcp->sc == NULL);
mpi_errno = find_free_entry(&index);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP (mpi_errno);
@@ -797,15 +812,15 @@
mpi_errno = vc->pg->getConnInfo(vc->pg_rank, bc, val_max_sz, vc->pg);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
- mpi_errno = MPID_nem_tcp_get_addr_port_from_bc(bc, &addr, &(VC_FIELD(vc, sock_id).sin_port));
- VC_FIELD(vc, sock_id).sin_addr.s_addr = addr.s_addr;
+ mpi_errno = MPID_nem_tcp_get_addr_port_from_bc(bc, &addr, &(vc_tcp->sock_id.sin_port));
+ vc_tcp->sock_id.sin_addr.s_addr = addr.s_addr;
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
else {
sc->is_tmpvc = TRUE;
}
- sock_addr = &(VC_FIELD(vc, sock_id));
+ sock_addr = &(vc_tcp->sock_id);
CHECK_EINTR(sc->fd, socket(AF_INET, SOCK_STREAM, 0));
MPIU_ERR_CHKANDJUMP2(sc->fd == -1, mpi_errno, MPI_ERR_OTHER, "**sock_create",
@@ -850,13 +865,13 @@
/* very important, without this IS_SAME_CONNECTION will always fail */
sc->pg_is_set = TRUE;
- ASSIGN_SC_TO_VC(vc, sc);
+ ASSIGN_SC_TO_VC(vc_tcp, sc);
sc->vc = vc;
- MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "about to incr sc_ref_count sc=%p sc->vc=%p sc_ref_count=%d", sc, sc->vc, VC_FIELD(sc->vc, sc_ref_count)));
- ++VC_FIELD(vc, sc_ref_count);
+ MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "about to incr sc_ref_count sc=%p sc->vc=%p sc_ref_count=%d", sc, sc->vc, vc_tcp->sc_ref_count));
+ ++vc_tcp->sc_ref_count;
}
else if (((MPIDI_CH3I_VC *)vc->channel_private)->state == MPID_NEM_TCP_VC_STATE_CONNECTED) {
- sc = VC_FIELD(vc, sc);
+ sc = vc_tcp->sc;
MPIU_Assert(sc != NULL);
/* Do nothing here, the caller just needs to wait for the connection
state machine to work its way through the states. Doing something at
@@ -893,8 +908,10 @@
/* Called to transition an sc to CLOSED. This might be done as part of a ch3
close protocol or it might be done because the sc is in a quiescent state. */
-static int cleanup_sc(sockconn_t *sc)
+static int cleanup_sc(sockconn_t *const sc)
{
+ MPIDI_VC_t *const sc_vc = sc->vc;
+ MPID_nem_tcp_vc_area *const sc_vc_tcp = VC_TCP(sc_vc);
int mpi_errno = MPI_SUCCESS;
int rc;
struct pollfd *plfd = NULL;
@@ -907,14 +924,14 @@
if (sc == NULL)
goto fn_exit;
- if (sc->vc) {
- MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "about to decr sc_ref_count sc=%p sc->vc=%p sc_ref_count=%d", sc, sc->vc, VC_FIELD(sc->vc, sc_ref_count)));
- MPIU_Assert(VC_FIELD(sc->vc, sc_ref_count) > 0);
- --VC_FIELD(sc->vc, sc_ref_count);
+ if (sc_vc) {
+ MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "about to decr sc_ref_count sc=%p sc->vc=%p sc_ref_count=%d", sc, sc_vc, sc_vc_tcp->sc_ref_count));
+ MPIU_Assert(sc_vc_tcp->sc_ref_count > 0);
+ --sc_vc_tcp->sc_ref_count;
}
plfd = &MPID_nem_tcp_plfd_tbl[sc->index];
- MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "vc=%p, sc=%p, closing fd=%d", sc->vc, sc, sc->fd));
+ MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "vc=%p, sc=%p, closing fd=%d", sc_vc, sc, sc->fd));
CHECK_EINTR(rc, close(sc->fd));
@@ -922,10 +939,10 @@
"**close", "**close %s", strerror (errno));
sc->fd = plfd->fd = CONN_INVALID_FD;
- if (sc->vc && VC_FIELD(sc->vc, sc) == sc) /* this vc may be connecting/accepting with another sc e.g., this sc lost the tie-breaker */
+ if (sc_vc && sc_vc_tcp->sc == sc) /* this vc may be connecting/accepting with another sc e.g., this sc lost the tie-breaker */
{
- ((MPIDI_CH3I_VC *)sc->vc->channel_private)->state = MPID_NEM_TCP_VC_STATE_DISCONNECTED;
- ASSIGN_SC_TO_VC(sc->vc, NULL);
+ ((MPIDI_CH3I_VC *)sc_vc->channel_private)->state = MPID_NEM_TCP_VC_STATE_DISCONNECTED;
+ ASSIGN_SC_TO_VC(sc_vc_tcp, NULL);
}
CHANGE_STATE(sc, CONN_STATE_TS_CLOSED);
@@ -957,19 +974,20 @@
int MPID_nem_tcp_cleanup (struct MPIDI_VC *const vc)
{
int mpi_errno = MPI_SUCCESS, i;
+ MPID_nem_tcp_vc_area *const vc_tcp = VC_TCP(vc);
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TCP_CLEANUP);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TCP_CLEANUP);
MPIU_Assert(vc->state == MPIDI_VC_STATE_CLOSE_ACKED);
- if (VC_FIELD(vc, sc) != NULL) {
- mpi_errno = cleanup_sc(VC_FIELD(vc, sc));
+ if (vc_tcp->sc != NULL) {
+ mpi_errno = cleanup_sc(vc_tcp->sc);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
i = 0;
- while (VC_FIELD(vc, sc_ref_count) > 0 && i < g_tbl_size) {
+ while (vc_tcp->sc_ref_count > 0 && i < g_tbl_size) {
if (g_sc_tbl[i].vc == vc) {
/* We've found a proto-connection that doesn't yet have enough
information to resolve the head-to-head situation. If we don't
@@ -984,7 +1002,7 @@
/* cleanup_sc can technically cause a reconnect on a per-sc basis, but I
don't think that it can happen when cleanup is called. Let's
assert this for now and remove it if we prove that it can happen. */
- MPIU_Assert(VC_FIELD(vc, sc_ref_count) == 0);
+ MPIU_Assert(vc_tcp->sc_ref_count == 0);
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_TCP_CLEANUP);
@@ -1096,6 +1114,8 @@
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static int state_c_ranksent_handler(struct pollfd *const plfd, sockconn_t *const sc)
{
+ MPIDI_VC_t *const sc_vc = sc->vc;
+ MPID_nem_tcp_vc_area *const sc_vc_tcp = VC_TCP(sc_vc);
int mpi_errno = MPI_SUCCESS;
MPIDI_nem_tcp_pkt_type_t pkt_type;
MPIDI_STATE_DECL(MPID_STATE_STATE_C_RANKSENT_HANDLER);
@@ -1108,7 +1128,7 @@
MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "state_c_ranksent_handler() 1: changing to "
"quiescent.. "));
CHANGE_STATE(sc, CONN_STATE_TS_D_QUIESCENT);
- if (vc_is_in_shutdown(sc->vc)) {
+ if (vc_is_in_shutdown(sc_vc)) {
mpi_errno = MPI_SUCCESS;
}
}
@@ -1118,15 +1138,15 @@
if (pkt_type == MPIDI_NEM_TCP_PKT_ID_ACK) {
CHANGE_STATE(sc, CONN_STATE_TS_COMMRDY);
- ASSIGN_SC_TO_VC(sc->vc, sc);
+ ASSIGN_SC_TO_VC(sc_vc_tcp, sc);
- MPID_nem_tcp_conn_est (sc->vc);
+ MPID_nem_tcp_conn_est (sc_vc);
MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "c_ranksent_handler(): connection established (sc=%p, sc->vc=%p, fd=%d)", sc, sc->vc, sc->fd));
}
else { /* pkt_type must be MPIDI_NEM_TCP_PKT_ID_NAK */
CHANGE_STATE(sc, CONN_STATE_TS_D_QUIESCENT);
}
- }
+ }
}
MPIDI_FUNC_EXIT(MPID_STATE_STATE_C_RANKSENT_HANDLER);
@@ -1139,6 +1159,8 @@
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static int state_c_tmpvcsent_handler(struct pollfd *const plfd, sockconn_t *const sc)
{
+ MPIDI_VC_t *const sc_vc = sc->vc;
+ MPID_nem_tcp_vc_area *const sc_vc_tcp = VC_TCP(sc_vc);
int mpi_errno = MPI_SUCCESS;
MPIDI_nem_tcp_pkt_type_t pkt_type;
MPIDI_STATE_DECL(MPID_STATE_STATE_C_TMPVCSENT_HANDLER);
@@ -1159,9 +1181,9 @@
if (pkt_type == MPIDI_NEM_TCP_PKT_TMPVC_ACK) {
CHANGE_STATE(sc, CONN_STATE_TS_COMMRDY);
- ASSIGN_SC_TO_VC(sc->vc, sc);
- MPID_nem_tcp_conn_est (sc->vc);
- MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "c_tmpvcsent_handler(): connection established (fd=%d, sc=%p, sc->vc=%p)", sc->fd, sc, sc->vc));
+ ASSIGN_SC_TO_VC(sc_vc_tcp, sc);
+ MPID_nem_tcp_conn_est (sc_vc);
+ MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "c_tmpvcsent_handler(): connection established (fd=%d, sc=%p, sc->vc=%p)", sc->fd, sc, sc_vc));
}
else { /* pkt_type must be MPIDI_NEM_TCP_PKT_ID_NAK */
MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "state_c_tmpvcsent_handler() 2: changing to quiescent"));
@@ -1276,6 +1298,8 @@
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static int state_l_rankrcvd_handler(struct pollfd *const plfd, sockconn_t *const sc)
{
+ MPIDI_VC_t *const sc_vc = sc->vc;
+ MPID_nem_tcp_vc_area *const sc_vc_tcp = VC_TCP(sc_vc);
int mpi_errno = MPI_SUCCESS;
MPID_NEM_TCP_SOCK_STATUS_t status;
sockconn_t *fnd_sc = NULL;
@@ -1311,13 +1335,13 @@
* chance to finish the connect protocol. That can lead to all
* kinds of badness, including zombie connections, segfaults, and
* accessing PG/VC info that is no longer present. */
- if (VC_FIELD(sc->vc, sc_ref_count) > 1) goto fn_exit;
+ if (sc_vc_tcp->sc_ref_count > 1) goto fn_exit;
if (send_cmd_pkt(sc->fd, MPIDI_NEM_TCP_PKT_ID_ACK) == MPI_SUCCESS) {
CHANGE_STATE(sc, CONN_STATE_TS_COMMRDY);
- ASSIGN_SC_TO_VC(sc->vc, sc);
- MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "connection established: sc=%p, sc->vc=%p, sc->fd=%d, is_same_pg=%s, pg_rank=%d", sc, sc->vc, sc->fd, (sc->is_same_pg ? "TRUE" : "FALSE"), sc->pg_rank));
- MPID_nem_tcp_conn_est (sc->vc);
+ ASSIGN_SC_TO_VC(sc_vc_tcp, sc);
+ MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "connection established: sc=%p, sc->vc=%p, sc->fd=%d, is_same_pg=%s, pg_rank=%d", sc, sc_vc, sc->fd, (sc->is_same_pg ? "TRUE" : "FALSE"), sc->pg_rank));
+ MPID_nem_tcp_conn_est (sc_vc);
}
}
}
@@ -1333,6 +1357,8 @@
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static int state_l_tmpvcrcvd_handler(struct pollfd *const plfd, sockconn_t *const sc)
{
+ MPIDI_VC_t *const sc_vc = sc->vc;
+ MPID_nem_tcp_vc_area *const sc_vc_tcp = VC_TCP(sc_vc);
int mpi_errno = MPI_SUCCESS;
MPID_NEM_TCP_SOCK_STATUS_t status;
int snd_nak = FALSE;
@@ -1355,8 +1381,8 @@
else {
if (send_cmd_pkt(sc->fd, MPIDI_NEM_TCP_PKT_TMPVC_ACK) == MPI_SUCCESS) {
CHANGE_STATE(sc, CONN_STATE_TS_COMMRDY);
- ASSIGN_SC_TO_VC(sc->vc, sc);
- MPID_nem_tcp_conn_est (sc->vc);
+ ASSIGN_SC_TO_VC(sc_vc_tcp, sc);
+ MPID_nem_tcp_conn_est(sc_vc);
MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "fd=%d: TMPVC_ACK sent, connection established!", sc->fd));
}
}
@@ -1371,15 +1397,17 @@
#define FUNCNAME MPID_nem_tcp_recv_handler
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
-static int MPID_nem_tcp_recv_handler (struct pollfd *pfd, sockconn_t *sc)
+static int MPID_nem_tcp_recv_handler (struct pollfd *pfd, sockconn_t *const sc)
{
+ MPIDI_VC_t *const sc_vc = sc->vc;
+ MPID_nem_tcp_vc_area *const sc_vc_tcp = VC_TCP(sc_vc);
int mpi_errno = MPI_SUCCESS;
ssize_t bytes_recvd;
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TCP_RECV_HANDLER);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TCP_RECV_HANDLER);
- if (((MPIDI_CH3I_VC *)sc->vc->channel_private)->recv_active == NULL)
+ if (((MPIDI_CH3I_VC *)sc_vc->channel_private)->recv_active == NULL)
{
/* receive a new message */
CHECK_EINTR(bytes_recvd, recv(sc->fd, recv_buf, MPID_NEM_TCP_RECV_MAX_PKT_LEN, 0));
@@ -1391,11 +1419,11 @@
if (bytes_recvd == 0)
{
MPIU_Assert(sc != NULL);
- MPIU_Assert(sc->vc != NULL);
+ MPIU_Assert(sc_vc != NULL);
/* sc->vc->sc will be NULL if sc->vc->state == _INACTIVE */
- MPIU_Assert(VC_FIELD(sc->vc, sc) == NULL || VC_FIELD(sc->vc, sc) == sc);
+ MPIU_Assert(sc_vc_tcp->sc == NULL || sc_vc_tcp->sc == sc);
- if (vc_is_in_shutdown(sc->vc))
+ if (vc_is_in_shutdown(sc_vc))
{
/* there's currently no hook for CH3 to tell nemesis/tcp
that we are in the middle of a disconnection dance. So
@@ -1418,15 +1446,16 @@
}
}
- MPIU_DBG_MSG_FMT(CH3_CHANNEL, VERBOSE, (MPIU_DBG_FDEST, "New recv " MPIDI_MSG_SZ_FMT " (fd=%d, vc=%p, sc=%p)", bytes_recvd, sc->fd, sc->vc, sc));
+ MPIU_DBG_MSG_FMT(CH3_CHANNEL, VERBOSE, (MPIU_DBG_FDEST, "New recv " MPIDI_MSG_SZ_FMT " (fd=%d, vc=%p, sc=%p)", bytes_recvd, sc->fd, sc_vc, sc));
- mpi_errno = MPID_nem_handle_pkt(sc->vc, recv_buf, bytes_recvd);
+ mpi_errno = MPID_nem_handle_pkt(sc_vc, recv_buf, bytes_recvd);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
else
{
/* there is a pending receive, receive it directly into the user buffer */
- MPID_Request *rreq = ((MPIDI_CH3I_VC *)sc->vc->channel_private)->recv_active;
+ MPIDI_CH3I_VC *const sc_vc_ch = (MPIDI_CH3I_VC *)sc_vc->channel_private;
+ MPID_Request *const rreq = sc_vc_ch->recv_active;
MPID_IOV *iov = &rreq->dev.iov[rreq->dev.iov_offset];
int (*reqFn)(MPIDI_VC_t *, MPID_Request *, int *);
@@ -1475,25 +1504,25 @@
MPIU_Assert(MPIDI_Request_get_type(rreq) != MPIDI_REQUEST_TYPE_GET_RESP);
MPIDI_CH3U_Request_complete(rreq);
MPIU_DBG_MSG(CH3_CHANNEL, VERBOSE, "...complete");
- ((MPIDI_CH3I_VC *)sc->vc->channel_private)->recv_active = NULL;
+ sc_vc_ch->recv_active = NULL;
}
else
{
int complete = 0;
- mpi_errno = reqFn(sc->vc, rreq, &complete);
+ mpi_errno = reqFn(sc_vc, rreq, &complete);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
if (complete)
{
MPIU_DBG_MSG(CH3_CHANNEL, VERBOSE, "...complete");
- ((MPIDI_CH3I_VC *)sc->vc->channel_private)->recv_active = NULL;
+ sc_vc_ch->recv_active = NULL;
}
else
{
MPIU_DBG_MSG(CH3_CHANNEL, VERBOSE, "...not complete");
}
- }
+ }
}
fn_exit:
Modified: mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/socksm.h
===================================================================
--- mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/socksm.h 2009-10-22 14:42:47 UTC (rev 5528)
+++ mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/socksm.h 2009-10-22 14:55:56 UTC (rev 5529)
@@ -185,6 +185,6 @@
} MPIDI_nem_tcp_portinfo_t;
-#define MPID_nem_tcp_vc_is_connected(vc) (VC_FIELD(vc, sc) && VC_FIELD(vc, sc)->state.cstate == CONN_STATE_TS_COMMRDY)
+#define MPID_nem_tcp_vc_is_connected(vc_tcp) (vc_tcp->sc && vc_tcp->sc->state.cstate == CONN_STATE_TS_COMMRDY)
#endif
Modified: mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_impl.h
===================================================================
--- mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_impl.h 2009-10-22 14:42:47 UTC (rev 5528)
+++ mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_impl.h 2009-10-22 14:55:56 UTC (rev 5529)
@@ -41,12 +41,11 @@
int sc_ref_count;
} MPID_nem_tcp_vc_area;
-/* accessor macro to private fields in VC */
-#define VC_FIELD(vc, field) (((MPID_nem_tcp_vc_area *)((MPIDI_CH3I_VC *)(vc)->channel_private)->netmod_area.padding)->field)
+/* macro for tcp private in VC */
+#define VC_TCP(vc) ((MPID_nem_tcp_vc_area *)((MPIDI_CH3I_VC *)(vc)->channel_private)->netmod_area.padding)
-#define ASSIGN_SC_TO_VC(vc_, sc_) \
- do { \
- VC_FIELD((vc_), sc) = (sc_); \
+#define ASSIGN_SC_TO_VC(vc_tcp_, sc_) do { \
+ (vc_tcp_)->sc = (sc_); \
} while (0)
/* functions */
@@ -134,8 +133,8 @@
/* VC list macros */
#define VC_L_EMPTY(q) GENERIC_L_EMPTY (q)
#define VC_L_HEAD(q) GENERIC_L_HEAD (q)
-#define SET_PLFD(ep) MPID_nem_tcp_plfd_tbl[VC_FIELD(ep, sc)->index].events |= POLLOUT
-#define UNSET_PLFD(ep) MPID_nem_tcp_plfd_tbl[VC_FIELD(ep, sc)->index].events &= ~POLLOUT
+#define SET_PLFD(vc_tcp) MPID_nem_tcp_plfd_tbl[(vc_tcp)->sc->index].events |= POLLOUT
+#define UNSET_PLFD(vc_tcp) MPID_nem_tcp_plfd_tbl[(vc_tcp)->sc->index].events &= ~POLLOUT
/* stack macros */
#define S_EMPTY(s) GENERIC_S_EMPTY (s)
Modified: mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_init.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_init.c 2009-10-22 14:42:47 UTC (rev 5528)
+++ mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_init.c 2009-10-22 14:55:56 UTC (rev 5529)
@@ -292,19 +292,20 @@
{
int mpi_errno = MPI_SUCCESS;
struct in_addr addr;
+ MPID_nem_tcp_vc_area *vc_tcp = VC_TCP(new_vc);
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TCP_CONNECT_TO_ROOT);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TCP_CONNECT_TO_ROOT);
/* vc is already allocated before reaching this point */
- mpi_errno = MPID_nem_tcp_get_addr_port_from_bc(business_card, &addr, &(VC_FIELD(new_vc, sock_id).sin_port));
- VC_FIELD(new_vc, sock_id).sin_addr.s_addr = addr.s_addr;
+ mpi_errno = MPID_nem_tcp_get_addr_port_from_bc(business_card, &addr, &vc_tcp->sock_id.sin_port);
+ vc_tcp->sock_id.sin_addr.s_addr = addr.s_addr;
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIDI_GetTagFromPort(business_card, &new_vc->port_name_tag);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
- MPID_nem_tcp_connect(new_vc);
+ MPID_nem_tcp_connect(new_vc);
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_TCP_CONNECT_TO_ROOT);
@@ -322,6 +323,7 @@
{
int mpi_errno = MPI_SUCCESS;
MPIDI_CH3I_VC *vc_ch = (MPIDI_CH3I_VC *)vc->channel_private;
+ MPID_nem_tcp_vc_area *vc_tcp = VC_TCP(vc);
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TCP_VC_INIT);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TCP_VC_INIT);
@@ -331,16 +333,16 @@
vc->sendNoncontig_fn = MPID_nem_tcp_SendNoncontig;
vc_ch->iStartContigMsg = MPID_nem_tcp_iStartContigMsg;
vc_ch->iSendContig = MPID_nem_tcp_iSendContig;
- memset(&VC_FIELD(vc, sock_id), 0, sizeof(VC_FIELD(vc, sock_id)));
- VC_FIELD(vc, sock_id).sin_family = AF_INET;
+ memset(&vc_tcp->sock_id, 0, sizeof(vc_tcp->sock_id));
+ vc_tcp->sock_id.sin_family = AF_INET;
vc_ch->next = NULL;
vc_ch->prev = NULL;
- ASSIGN_SC_TO_VC(vc, NULL);
- VC_FIELD(vc, send_queue).head = VC_FIELD(vc, send_queue).tail = NULL;
+ ASSIGN_SC_TO_VC(vc_tcp, NULL);
+ vc_tcp->send_queue.head = vc_tcp->send_queue.tail = NULL;
- VC_FIELD(vc, sc_ref_count) = 0;
+ vc_tcp->sc_ref_count = 0;
MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_TCP_VC_INIT);
return mpi_errno;
Modified: mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_send.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_send.c 2009-10-22 14:42:47 UTC (rev 5528)
+++ mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_send.c 2009-10-22 14:55:56 UTC (rev 5529)
@@ -94,22 +94,23 @@
MPIDI_msg_sz_t offset;
MPID_IOV *iov;
int complete;
+ MPID_nem_tcp_vc_area *vc_tcp = VC_TCP(vc);
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TCP_SEND_QUEUED);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TCP_SEND_QUEUED);
MPIU_Assert(vc != NULL);
- if (SENDQ_EMPTY(VC_FIELD(vc, send_queue)))
+ if (SENDQ_EMPTY(vc_tcp->send_queue))
goto fn_exit;
- while (!SENDQ_EMPTY(VC_FIELD(vc, send_queue)))
+ while (!SENDQ_EMPTY(vc_tcp->send_queue))
{
- sreq = SENDQ_HEAD(VC_FIELD(vc, send_queue));
+ sreq = SENDQ_HEAD(vc_tcp->send_queue);
iov = &sreq->dev.iov[sreq->dev.iov_offset];
- CHECK_EINTR(offset, writev(VC_FIELD(vc, sc)->fd, iov, sreq->dev.iov_count));
+ CHECK_EINTR(offset, writev(vc_tcp->sc->fd, iov, sreq->dev.iov_count));
MPIU_ERR_CHKANDJUMP(offset == 0, mpi_errno, MPI_ERR_OTHER, "**sock_closed");
if (offset == -1)
{
@@ -155,7 +156,7 @@
MPIU_Assert(MPIDI_Request_get_type(sreq) != MPIDI_REQUEST_TYPE_GET_RESP);
MPIDI_CH3U_Request_complete(sreq);
MPIU_DBG_MSG(CH3_CHANNEL, VERBOSE, ".... complete");
- SENDQ_DEQUEUE(&VC_FIELD(vc, send_queue), &sreq);
+ SENDQ_DEQUEUE(&vc_tcp->send_queue, &sreq);
continue;
}
@@ -166,15 +167,15 @@
if (complete)
{
MPIU_DBG_MSG(CH3_CHANNEL, VERBOSE, ".... complete");
- SENDQ_DEQUEUE(&VC_FIELD(vc, send_queue), &sreq);
+ SENDQ_DEQUEUE(&vc_tcp->send_queue, &sreq);
continue;
}
sreq->dev.iov_offset = 0;
}
}
- if (SENDQ_EMPTY(VC_FIELD(vc, send_queue)))
- UNSET_PLFD(vc);
+ if (SENDQ_EMPTY(vc_tcp->send_queue))
+ UNSET_PLFD(vc_tcp);
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_TCP_SEND_QUEUED);
@@ -209,20 +210,21 @@
int MPID_nem_tcp_conn_est (MPIDI_VC_t *vc)
{
int mpi_errno = MPI_SUCCESS;
+ MPID_nem_tcp_vc_area *vc_tcp = VC_TCP(vc);
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TCP_CONN_EST);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TCP_CONN_EST);
MPIDI_CHANGE_VC_STATE(vc, ACTIVE);
- if (!SENDQ_EMPTY (VC_FIELD(vc, send_queue)))
+ if (!SENDQ_EMPTY (vc_tcp->send_queue))
{
- SET_PLFD(vc);
+ SET_PLFD(vc_tcp);
mpi_errno = MPID_nem_tcp_send_queued (vc);
if (mpi_errno) MPIU_ERR_POP (mpi_errno);
}
- fn_fail:
+ fn_fail:
MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_TCP_CONN_EST);
return mpi_errno;
}
@@ -238,7 +240,8 @@
int mpi_errno = MPI_SUCCESS;
MPID_Request * sreq = NULL;
MPIDI_msg_sz_t offset = 0;
- sockconn_t *sc = VC_FIELD(vc, sc);
+ MPID_nem_tcp_vc_area *vc_tcp = VC_TCP(vc);
+ sockconn_t *sc = vc_tcp->sc;
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TCP_ISTARTCONTIGMSG);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TCP_ISTARTCONTIGMSG);
@@ -247,9 +250,9 @@
MPIU_DBG_MSG(CH3_CHANNEL, VERBOSE, "tcp_iStartContigMsg");
MPIDI_DBG_Print_packet((MPIDI_CH3_Pkt_t *)hdr);
- if (MPID_nem_tcp_vc_is_connected(vc))
+ if (MPID_nem_tcp_vc_is_connected(vc_tcp))
{
- if (SENDQ_EMPTY(VC_FIELD(vc, send_queue)))
+ if (SENDQ_EMPTY(vc_tcp->send_queue))
{
MPID_IOV iov[2];
@@ -319,19 +322,19 @@
MPIU_Assert(sreq->dev.iov_count >= 1 && sreq->dev.iov[0].MPID_IOV_LEN > 0);
- if (MPID_nem_tcp_vc_is_connected(vc)) {
- if (SENDQ_EMPTY(VC_FIELD(vc, send_queue))) {
+ if (MPID_nem_tcp_vc_is_connected(vc_tcp)) {
+ if (SENDQ_EMPTY(vc_tcp->send_queue)) {
/* this will be the first send on the queue: queue it and set the write flag on the pollfd */
- SENDQ_ENQUEUE(&VC_FIELD(vc, send_queue), sreq);
- SET_PLFD(vc);
+ SENDQ_ENQUEUE(&vc_tcp->send_queue, sreq);
+ SET_PLFD(vc_tcp);
} else {
/* there are other sends in the queue before this one: try to send from the queue */
- SENDQ_ENQUEUE(&VC_FIELD(vc, send_queue), sreq);
+ SENDQ_ENQUEUE(&vc_tcp->send_queue, sreq);
mpi_errno = MPID_nem_tcp_send_queued(vc);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
} else {
- SENDQ_ENQUEUE(&VC_FIELD(vc, send_queue), sreq);
+ SENDQ_ENQUEUE(&vc_tcp->send_queue, sreq);
}
*sreq_ptr = sreq;
@@ -352,7 +355,8 @@
{
int mpi_errno = MPI_SUCCESS;
MPIDI_msg_sz_t offset = 0;
- sockconn_t *sc = VC_FIELD(vc, sc);
+ MPID_nem_tcp_vc_area *vc_tcp = VC_TCP(vc);
+ sockconn_t *sc = vc_tcp->sc;
MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TCP_ISENDCONTIGMSG);
MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TCP_ISENDCONTIGMSG);
@@ -362,9 +366,9 @@
MPIU_DBG_MSG(CH3_CHANNEL, VERBOSE, "tcp_iSendContig");
MPIDI_DBG_Print_packet((MPIDI_CH3_Pkt_t *)hdr);
- if (MPID_nem_tcp_vc_is_connected(vc))
+ if (MPID_nem_tcp_vc_is_connected(vc_tcp))
{
- if (SENDQ_EMPTY(VC_FIELD(vc, send_queue)))
+ if (SENDQ_EMPTY(vc_tcp->send_queue))
{
MPID_IOV iov[2];
@@ -453,19 +457,19 @@
sreq->ch.vc = vc;
sreq->dev.iov_offset = 0;
- if (MPID_nem_tcp_vc_is_connected(vc)) {
- if (SENDQ_EMPTY(VC_FIELD(vc, send_queue))) {
+ if (MPID_nem_tcp_vc_is_connected(vc_tcp)) {
+ if (SENDQ_EMPTY(vc_tcp->send_queue)) {
/* this will be the first send on the queue: queue it and set the write flag on the pollfd */
- SENDQ_ENQUEUE(&VC_FIELD(vc, send_queue), sreq);
- SET_PLFD(vc);
+ SENDQ_ENQUEUE(&vc_tcp->send_queue, sreq);
+ SET_PLFD(vc_tcp);
} else {
/* there are other sends in the queue before this one: try to send from the queue */
- SENDQ_ENQUEUE(&VC_FIELD(vc, send_queue), sreq);
+ SENDQ_ENQUEUE(&vc_tcp->send_queue, sreq);
mpi_errno = MPID_nem_tcp_send_queued(vc);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
} else {
- SENDQ_ENQUEUE(&VC_FIELD(vc, send_queue), sreq);
+ SENDQ_ENQUEUE(&vc_tcp->send_queue, sreq);
}
fn_exit:
@@ -488,6 +492,7 @@
MPID_IOV *iov_p;
MPIDI_msg_sz_t offset;
int complete;
+ MPID_nem_tcp_vc_area *vc_tcp = VC_TCP(vc);
MPIU_DBG_MSG(CH3_CHANNEL, VERBOSE, "tcp_SendNoncontig");
MPIU_Assert(hdr_sz <= sizeof(MPIDI_CH3_PktGeneric_t));
@@ -503,11 +508,11 @@
iov_n += 1;
offset = 0;
- if (MPID_nem_tcp_vc_is_connected(vc))
+ if (MPID_nem_tcp_vc_is_connected(vc_tcp))
{
- if (SENDQ_EMPTY(VC_FIELD(vc, send_queue)))
+ if (SENDQ_EMPTY(vc_tcp->send_queue))
{
- CHECK_EINTR(offset, writev(VC_FIELD(vc, sc)->fd, iov, iov_n));
+ CHECK_EINTR(offset, writev(vc_tcp->sc->fd, iov, iov_n));
MPIU_ERR_CHKANDJUMP(offset == 0, mpi_errno, MPI_ERR_OTHER, "**sock_closed");
if (offset == -1)
{
@@ -581,19 +586,19 @@
sreq->ch.vc = vc;
sreq->dev.iov_offset = 0;
- if (MPID_nem_tcp_vc_is_connected(vc)) {
- if (SENDQ_EMPTY(VC_FIELD(vc, send_queue))) {
+ if (MPID_nem_tcp_vc_is_connected(vc_tcp)) {
+ if (SENDQ_EMPTY(vc_tcp->send_queue)) {
/* this will be the first send on the queue: queue it and set the write flag on the pollfd */
- SENDQ_ENQUEUE(&VC_FIELD(vc, send_queue), sreq);
- SET_PLFD(vc);
+ SENDQ_ENQUEUE(&vc_tcp->send_queue, sreq);
+ SET_PLFD(vc_tcp);
} else {
/* there are other sends in the queue before this one: try to send from the queue */
- SENDQ_ENQUEUE(&VC_FIELD(vc, send_queue), sreq);
+ SENDQ_ENQUEUE(&vc_tcp->send_queue, sreq);
mpi_errno = MPID_nem_tcp_send_queued(vc);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
} else {
- SENDQ_ENQUEUE(&VC_FIELD(vc, send_queue), sreq);
+ SENDQ_ENQUEUE(&vc_tcp->send_queue, sreq);
}
fn_exit:
Modified: mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_utility.c
===================================================================
--- mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_utility.c 2009-10-22 14:42:47 UTC (rev 5528)
+++ mpich2/trunk/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_utility.c 2009-10-22 14:55:56 UTC (rev 5529)
@@ -18,8 +18,9 @@
int MPID_nem_tcp_get_conninfo (struct MPIDI_VC *vc, struct sockaddr_in *addr, char **pg_id, int *pg_rank)
{
int mpi_errno = MPI_SUCCESS;
+ MPID_nem_tcp_vc_area *vc_tcp = VC_TCP(vc);
- *addr = VC_FIELD(vc, sock_id);
+ *addr = vc_tcp->sock_id;
*pg_id = (char *)vc->pg->id;
*pg_rank = vc->pg_rank;
@@ -209,12 +210,13 @@
int i;
MPID_Request *sreq;
MPIDI_CH3I_VC *vc_ch = (MPIDI_CH3I_VC *)vc->channel_private;
+ MPID_nem_tcp_vc_area *vc_tcp = VC_TCP(vc);
- fprintf(stream, ".. sc=%p fd=%d vc_ch->state=%d\n", VC_FIELD(vc, sc), (VC_FIELD(vc, sc) ? VC_FIELD(vc,sc)->fd : -1), vc_ch->state);
+ fprintf(stream, ".. sc=%p fd=%d vc_ch->state=%d\n", vc_tcp->sc, (vc_tcp->sc ? vc_tcp->sc->fd : -1), vc_ch->state);
/* This function violates any abstraction in the queues, since there's no
good way to print them without inspecting the internals. */
- sreq = VC_FIELD(vc, send_queue).head;
+ sreq = vc_tcp->send_queue.head;
i = 0;
while (sreq)
{
More information about the mpich2-commits
mailing list