Commit a321764e authored by Darius Buntinas's avatar Darius Buntinas
Browse files

[svn-r5647] added error macros for internal errors

parent 6a0eed09
......@@ -565,6 +565,16 @@
MPIU_ERR_CHKANDSTMT4(cond_,err_,class_,goto fn_fail,gmsg_,smsg_,arg1_,arg2_,arg3_,arg4_)
#define MPIU_ERR_CHKFATALANDJUMP4(cond_,err_,class_,gmsg_,smsg_,arg1_,arg2_,arg3_,arg4_) \
MPIU_ERR_CHKFATALANDSTMT4(cond_,err_,class_,goto fn_fail,gmsg_,smsg_,arg1_,arg2_,arg3_,arg4_)
#define MPIU_ERR_INTERNAL(err_, msg_) \
MPIU_ERR_SETFATAL1(err_, MPI_ERR_INTERN, "**intern", "**intern %s", msg_)
#define MPIU_ERR_INTERNALANDSTMT(err_, msg_, stmt_) \
MPIU_ERR_SETANDSTMT1(err_, MPI_ERR_INTERN, stmt_, "**intern", "**intern %s", msg_)
#define MPIU_ERR_INTERNALANDJUMP(err_, msg_) \
MPIU_ERR_INTERNALANDSTMT(err_, msg_, goto fn_fail)
#define MPIU_ERR_CHKINTERNAL(cond_, err_, msg_) \
do {if (cond_) MPIU_ERR_INTERNALANDJUMP(err_, msg_);} while(0)
/* --END ERROR MACROS-- */
/*
......
......@@ -225,7 +225,7 @@ static inline int MPID_nem_lmt_send_COOKIE(MPIDI_VC_t *vc, MPID_Request *req,
cookie_pkt->receiver_req_id = (req)->ch.lmt_req_id;
break;
default:
MPIU_ERR_SETANDJUMP1(mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "unexpected request type");
MPIU_ERR_INTERNALANDJUMP(mpi_errno, "unexpected request type");
break;
}
......
......@@ -89,12 +89,12 @@ MPID_nem_send_from_queue()
if (mpi_errno) MPIU_ERR_POP (mpi_errno);
break;
default:
MPIU_ERR_SETANDJUMP (mpi_errno, MPI_ERR_OTHER, "**intern");
MPIU_ERR_INTERNALANDJUMP(mpi_errno, "unexpected rdma type");
break;
}
break;
default:
MPIU_ERR_SETANDJUMP (mpi_errno, MPI_ERR_OTHER, "**intern");
MPIU_ERR_INTERNALANDJUMP(mpi_errno, "unexpected operation type");
break;
}
MPID_nem_gm_queue_free (send, e);
......
......@@ -346,7 +346,7 @@ MPID_nem_mx_poll(int in_blocking_poll)
else
{
/* Error : unknown REQ type */
MPIU_ERR_CHKANDJUMP1(TRUE, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "unknown REQ type");
MPIU_ERR_CHKINTERNAL(TRUE, mpi_errno, "unknown REQ type");
}
}
......@@ -387,7 +387,7 @@ MPID_nem_mx_poll(int in_blocking_poll)
else
{
/* Error : unknown REQ type */
MPIU_ERR_CHKANDJUMP1(TRUE, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "unknown REQ type");
MPIU_ERR_CHKINTERNAL(TRUE, mpi_errno, "unknown REQ type");
}
}
fn_exit:
......
......@@ -46,8 +46,8 @@ int MPID_nem_tcp_get_vc_from_conninfo (char *pg_id, int pg_rank, struct MPIDI_VC
mpi_errno = MPIDI_PG_Find (pg_id, &pg);
if (mpi_errno) MPIU_ERR_POP (mpi_errno);
MPIU_ERR_CHKANDJUMP1 (pg == NULL, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "invalid PG");
MPIU_ERR_CHKANDJUMP1 (pg_rank < 0 || pg_rank > MPIDI_PG_Get_size (pg), mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "invalid pg_rank");
MPIU_ERR_CHKINTERNAL(pg == NULL, mpi_errno, "invalid PG");
MPIU_ERR_CHKINTERNAL(pg_rank < 0 || pg_rank > MPIDI_PG_Get_size (pg), mpi_errno, "invalid pg_rank");
MPIDI_PG_Get_vc_set_active (pg, pg_rank, vc);
......
......@@ -248,7 +248,7 @@ int MPIDI_CH3I_Seg_commit(MPID_nem_seg_ptr_t memory, int num_local, int local_ra
/* get name of shared file */
mpi_errno = PMI2_Info_GetNodeAttr("sharedFilename", val, PMI2_MAX_VALLEN, &found, TRUE);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_ERR_CHKANDJUMP1(!found, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "nodeattr not found");
MPIU_ERR_CHKINTERNAL(!found, mpi_errno, "nodeattr not found");
mpi_errno = MPIU_SHMW_Hnd_deserialize(memory->hnd, val, strlen(val));
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
......@@ -506,7 +506,7 @@ static int check_alloc(int num_local, int local_rank)
MPID_nem_mem_region.memory.symmetrical = 0;
MPID_nem_asymm_base_addr = MPID_nem_mem_region.memory.base_addr;
#ifdef MPID_NEM_SYMMETRIC_QUEUES
MPIU_ERR_SETFATALANDJUMP1(mpi_errno, MPI_ERR_INTERN, "**intern", "**intern %s", "queues are not symmetrically allocated as expected");
MPIU_ERR_INTERNALANDJUMP(mpi_errno, "queues are not symmetrically allocated as expected");
#endif
}
else
......
......@@ -49,7 +49,7 @@ int MPID_nem_barrier(void)
if (MPID_nem_mem_region.num_local == 1)
goto fn_exit;
MPIU_ERR_CHKANDJUMP1 (!barrier_init, mpi_errno, MPI_ERR_INTERN, "**intern", "**intern %s", "barrier not initialized");
MPIU_ERR_CHKINTERNAL(!barrier_init, mpi_errno, "barrier not initialized");
if (OPA_fetch_and_incr_int(&MPID_nem_mem_region.barrier->val) == MPID_nem_mem_region.num_local - 1)
{
......
......@@ -136,7 +136,7 @@ int MPID_nem_ckpt_maybe_take_checkpoint()
/* we don't send messages to ourselves, so we pretend we sent and received a marker */
--MPID_nem_ckpt_sending_markers;
ret = cli_on_marker_receive (&marker, rank);
MPIU_ERR_CHKANDJUMP (ret != CLI_CP_MARKED, mpi_errno, MPI_ERR_OTHER, "**intern");
MPIU_ERR_CHKINTERNAL(ret != CLI_CP_MARKED, mpi_errno, "expecting CLI_CP_MARKED");
--MPID_nem_ckpt_logging_messages;
log_msg[rank] = 0;
sent_marker[rank] = 1;
......@@ -169,7 +169,7 @@ int MPID_nem_ckpt_maybe_take_checkpoint()
case CLI_NOTHING:
break;
default:
MPIU_ERR_CHKANDJUMP (ret != CLI_CP_MARKED, mpi_errno, MPI_ERR_OTHER, "**intern");
MPIU_ERR_CHKINTERNAL(ret != CLI_CP_MARKED, mpi_errno, "expecting CLI_CP_MARKED");
}
fn_exit:
......@@ -241,7 +241,7 @@ MPID_nem_ckpt_got_marker (MPID_nem_cell_ptr_t *cell, int *in_fbox)
/* we don't send messages to ourselves, so we pretend we sent and received a marker */
--MPID_nem_ckpt_sending_markers;
ret = cli_on_marker_receive (&marker, rank);
MPIU_ERR_CHKANDJUMP (ret != CLI_CP_MARKED, mpi_errno, MPI_ERR_OTHER, "**intern");
MPIU_ERR_CHKINTERNAL(ret != CLI_CP_MARKED, mpi_errno, "Expecting CLI_CP_MARKED");
--MPID_nem_ckpt_logging_messages;
log_msg[rank] = 0;
sent_marker[rank] = 1;
......@@ -283,7 +283,7 @@ MPID_nem_ckpt_got_marker (MPID_nem_cell_ptr_t *cell, int *in_fbox)
break;
}
default:
MPIU_ERR_CHKANDJUMP (ret != CLI_CP_MARKED, mpi_errno, MPI_ERR_OTHER, "**intern");
MPIU_ERR_CHKINTERNAL(ret != CLI_CP_MARKED, mpi_errno, "Expecting CLI_CP_MARKED");
return;
}
......
......@@ -370,7 +370,7 @@ static int pkt_DONE_handler(MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt, MPIDI_msg_sz_t
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
break;
default:
MPIU_ERR_SETANDJUMP1(mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "unexpected request type");
MPIU_ERR_INTERNALANDJUMP(mpi_errno, "unexpected request type");
break;
}
......
......@@ -325,7 +325,7 @@ int MPID_nem_lmt_vmsplice_progress(void)
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
break;
default:
MPIU_ERR_SETANDJUMP1(mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "unexpected request type");
MPIU_ERR_INTERNALANDJUMP(mpi_errno, "unexpected request type");
break;
}
......
......@@ -85,18 +85,19 @@ int MPIDI_CH3_Comm_connect(char *port_name, int root, MPID_Comm
#define FUNCNAME MPIDI_CH3_Get_business_card
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_CH3_Get_business_card (int myRank, char *value, int length)
int MPIDI_CH3_Get_business_card(int myRank, char *value, int length)
{
int mpi_errno = MPI_SUCCESS;
int ret;
MPIDI_STATE_DECL(MPIDI_STATE_MPIDI_CH3_GET_BUSINESS_CARD);
MPIDI_FUNC_ENTER(MPIDI_STATE_MPIDI_CH3_GET_BUSINESS_CARD);
ret = MPID_nem_get_business_card (myRank, value, length);
if (ret != 0)
mpi_errno = MPIR_Err_create_code (MPI_SUCCESS, MPIR_ERR_FATAL, FCNAME, __LINE__, MPI_ERR_INTERN, "**intern", 0);
mpi_errno = MPID_nem_get_business_card(myRank, value, length);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
fn_exit:
MPIDI_FUNC_EXIT(MPIDI_STATE_MPIDI_CH3_GET_BUSINESS_CARD);
return mpi_errno;
fn_fail:
goto fn_exit;
}
......@@ -192,7 +192,7 @@ int MPIDI_CH3_Connect_to_root (const char *port_name, MPIDI_VC_t **new_vc)
MPIDI_VC_Init (vc, NULL, 0);
/* init channel portion of vc */
MPIU_ERR_CHKANDJUMP (!nemesis_initialized, mpi_errno, MPI_ERR_OTHER, "**intern");
MPIU_ERR_CHKINTERNAL(!nemesis_initialized, mpi_errno, "Nemesis not initialized");
((MPIDI_CH3I_VC *)vc->channel_private)->recv_active = NULL;
MPIDI_CHANGE_VC_STATE(vc, ACTIVE);
......
......@@ -38,7 +38,7 @@ int MPID_Get_universe_size(int * universe_size)
*universe_size = MPIR_UNIVERSE_SIZE_NOT_AVAILABLE;
else {
*universe_size = strtol(val, &endptr, 0);
MPIU_ERR_CHKANDJUMP(endptr - val != strlen(val), mpi_errno, MPI_ERR_OTHER, "**intern");
MPIU_ERR_CHKINTERNAL(endptr - val != strlen(val), mpi_errno, "can't parse universe size");
}
#else
......
......@@ -452,6 +452,7 @@ int MPID_GPID_ToLpidArray( int size, int gpid[], int lpid[] )
int MPID_VCR_CommFromLpids( MPID_Comm *newcomm_ptr,
int size, const int lpids[] )
{
int mpi_errno = MPI_SUCCESS;
MPID_Comm *commworld_ptr;
int i;
MPIDI_PG_iterator iter;
......@@ -484,12 +485,7 @@ int MPID_VCR_CommFromLpids( MPID_Comm *newcomm_ptr,
MPIDI_PG_Get_next( &iter, &pg );
do {
MPIDI_PG_Get_next( &iter, &pg );
if (!pg) {
return MPIR_Err_create_code( MPI_SUCCESS,
MPIR_ERR_RECOVERABLE,
"MPID_VCR_CommFromLpids", __LINE__,
MPI_ERR_INTERN, "**intern", 0 );
}
MPIU_ERR_CHKINTERNAL(!pg, mpi_errno, "no pg");
/* FIXME: a quick check on the min/max values of the lpid
for this process group could help speed this search */
for (j=0; j<pg->size; j++) {
......@@ -512,7 +508,10 @@ int MPID_VCR_CommFromLpids( MPID_Comm *newcomm_ptr,
PG if necessary. */
MPID_VCR_Dup( vc, &newcomm_ptr->vcr[i] );
}
return 0;
fn_exit:
return mpi_errno;
fn_fail:
goto fn_exit;
}
/* The following is a temporary hook to ensure that all processes in
......@@ -811,7 +810,7 @@ fn_fail:
#endif
#define parse_error() MPIU_ERR_SETANDJUMP1(mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "parse error")
#define parse_error() MPIU_ERR_INTERNALANDJUMP(mpi_errno, "parse error")
/* advance _c until we find a non whitespace character */
#define skip_space(_c) while (isspace(*(_c))) ++(_c)
/* return true iff _c points to a character valid as an indentifier, i.e., [-_a-zA-Z0-9] */
......@@ -1016,7 +1015,7 @@ static int populate_ids_from_mapping(char *mapping, int *num_nodes, MPIDI_PG_t *
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
if (NULL_MAPPING == mt) goto fn_fail;
MPIU_ERR_CHKANDJUMP1(mt != VECTOR_MAPPING, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "unsupported mapping type");
MPIU_ERR_CHKINTERNAL(mt != VECTOR_MAPPING, mpi_errno, "unsupported mapping type");
rank = 0;
/* for a representation like (block,N,(1,1)) this while loop causes us to
......@@ -1131,8 +1130,8 @@ int MPIDI_Populate_vc_node_ids(MPIDI_PG_t *pg, int our_pg_rank)
mpi_errno = PMI2_Info_GetJobAttrIntArray("nodeIDs", node_ids, pg->size, &outlen, &found);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_ERR_CHKANDJUMP1(!found, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "nodeIDs attribute not found");
MPIU_ERR_CHKANDJUMP1(outlen != pg->size, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "did not receive enough nodeids");
MPIU_ERR_CHKINTERNAL(!found, mpi_errno, "nodeIDs attribute not found");
MPIU_ERR_CHKINTERNAL(outlen != pg->size, mpi_errno, "did not receive enough nodeids");
g_num_nodes = 0;
for (i = 0; i < pg->size; ++i) {
pg->vct[i].node_id = node_ids[i];
......@@ -1159,11 +1158,11 @@ int MPIDI_Populate_vc_node_ids(MPIDI_PG_t *pg, int our_pg_rank)
mpi_errno = PMI2_Info_GetJobAttr("process-mapping", process_mapping, sizeof(process_mapping), &found);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_ERR_CHKANDJUMP1(!found, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "process-mapping attribute not found");
MPIU_ERR_CHKINTERNAL(!found, mpi_errno, "process-mapping attribute not found");
/* this code currently assumes pg is comm_world */
mpi_errno = populate_ids_from_mapping(process_mapping, &num_nodes, pg, &did_map);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_ERR_CHKANDJUMP1(!did_map, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "unable to populate node ids from process-mapping");
MPIU_ERR_CHKINTERNAL(!did_map, mpi_errno, "unable to populate node ids from process-mapping");
g_num_nodes = num_nodes;
}
#endif
......
......@@ -906,15 +906,21 @@ static int getConnInfo( int rank, char *buf, int bufsize, MPIDI_PG_t *pg )
MPIU_Strncpy( buf, connInfo->connStrings[rank], bufsize );
return MPI_SUCCESS;
}
#undef FUNCNAME
#define FUNCNAME connToString
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
static int connToString( char **buf_p, int *slen, MPIDI_PG_t *pg )
{
int mpi_errno = MPI_SUCCESS;
char *str = NULL, *pg_id;
int i, len=0;
MPIU_CHKPMEM_DECL(1);
MPIDI_ConnInfo *connInfo = (MPIDI_ConnInfo *)pg->connData;
/* Create this from the string array */
str = (char *)MPIU_Malloc( connInfo->toStringLen );
MPIU_CHKPMEM_MALLOC(str, char *, connInfo->toStringLen, mpi_errno, "str");
#if defined(MPICH_DEBUG_MEMINIT)
memset(str, 0, connInfo->toStringLen);
......@@ -934,6 +940,7 @@ static int connToString( char **buf_p, int *slen, MPIDI_PG_t *pg )
PMI_Get_id( pg->id, 256 );
#endif
}
while (*pg_id) str[len++] = *pg_id++;
str[len++] = 0;
......@@ -951,14 +958,19 @@ static int connToString( char **buf_p, int *slen, MPIDI_PG_t *pg )
if (len > connInfo->toStringLen) {
*buf_p = 0;
*slen = 0;
return MPIR_Err_create_code(MPI_SUCCESS,MPIR_ERR_FATAL,"connToString",
__LINE__, MPI_ERR_INTERN, "**intern", NULL);
MPIU_ERR_INTERNALANDJUMP(mpi_errno, "len > connInfo->toStringLen");
}
*buf_p = str;
*slen = len;
return MPI_SUCCESS;
fn_exit:
MPIU_CHKPMEM_COMMIT();
return mpi_errno;
fn_fail:
MPIU_CHKPMEM_REAP();
goto fn_exit;
}
static int connFromString( const char *buf, MPIDI_PG_t *pg )
{
......
......@@ -836,12 +836,12 @@ static int MPIU_DBG_Open_temp_file(FILE **dbg_fp)
int ret;
ret = MPIU_Strncpy(temp_filename, filePattern, MAXPATHLEN);
MPIU_ERR_CHKANDJUMP1(ret, mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "logfile path too long");
MPIU_ERR_CHKINTERNAL(ret, mpi_errno, "logfile path too long");
MPIU_Basename(temp_filename, &basename);
/* make sure there's enough room in temp_filename to store temp_pattern */
MPIU_ERR_CHKANDJUMP1(basename - temp_filename > MAXPATHLEN - sizeof(temp_pattern), mpi_errno, MPI_ERR_OTHER, "**intern", "**intern %s", "logfile path too long");
MPIU_ERR_CHKINTERNAL(basename - temp_filename > MAXPATHLEN - sizeof(temp_pattern), mpi_errno, "logfile path too long");
MPIU_Strncpy(basename, temp_pattern, sizeof(temp_pattern));
......
......@@ -341,8 +341,7 @@ static inline int MPIU_SHMW_Hnd_deserialize(
int rc = -1;
MPIU_Assert(MPIU_SHMW_Hnd_is_init(hnd));
MPIU_ERR_CHKANDJUMP1(!str_hnd, mpi_errno, MPI_ERR_OTHER,
"**intern", "**intern %s", "ser hnd is null");
MPIU_ERR_CHKINTERNAL(!str_hnd, mpi_errno, "ser hnd is null");
MPIU_ERR_CHKANDJUMP(str_hnd_len>=MPIU_SHMW_GHND_SZ,
mpi_errno, MPI_ERR_OTHER, "**shmw_deserbufbig");
......@@ -413,8 +412,7 @@ static inline int MPIU_SHMW_Hnd_deserialize_by_ref(
MPIU_Assert(MPIU_SHMW_Hnd_is_init(hnd));
MPIU_Assert(ser_hnd_ptr);
MPIU_ERR_CHKANDJUMP1(!(*ser_hnd_ptr), mpi_errno, MPI_ERR_OTHER,
"**intern", "**intern %s", "ser hnd is null");
MPIU_ERR_CHKINTERNAL(!(*ser_hnd_ptr), mpi_errno, "ser hnd is null");
MPIU_SHMW_Hnd_reset_val(hnd);
MPIU_SHMW_Ghnd_set_by_ref(hnd, *ser_hnd_ptr);
......@@ -566,8 +564,7 @@ static inline int MPIU_SHMW_Seg_detach(
MPIU_ERR_CHKANDJUMP(!MPIU_SHMW_Hnd_is_valid(hnd),
mpi_errno, MPI_ERR_OTHER, "**shmw_badhnd");
MPIU_Assert(shm_addr_ptr);
MPIU_ERR_CHKANDJUMP1(!(*shm_addr_ptr), mpi_errno, MPI_ERR_OTHER,
"**intern", "**intern %s", "shm address is null");
MPIU_ERR_CHKINTERNAL(!(*shm_addr_ptr), mpi_errno, "shm address is null");
rc = shmdt(*shm_addr_ptr);
MPIU_ERR_CHKANDJUMP2((rc != 0), mpi_errno, MPI_ERR_OTHER,
......@@ -715,8 +712,7 @@ static inline int MPIU_SHMW_Seg_detach(
int rc = -1;
MPIU_Assert(shm_addr_ptr);
MPIU_ERR_CHKANDJUMP1(!(*shm_addr_ptr), mpi_errno, MPI_ERR_OTHER,
"**intern", "**intern %s", "shm address is null");
MPIU_ERR_CHKINTERNAL(!(*shm_addr_ptr), mpi_errno, "shm address is null");
rc = munmap(*shm_addr_ptr, seg_sz);
MPIU_ERR_CHKANDJUMP2((rc != 0), mpi_errno, MPI_ERR_OTHER,
......@@ -835,8 +831,7 @@ static inline int MPIU_SHMW_Seg_detach(
MPIU_ERR_CHKANDJUMP(!MPIU_SHMW_Hnd_is_valid(hnd),
mpi_errno, MPI_ERR_OTHER, "**shmw_badhnd");
MPIU_Assert(shm_addr_ptr);
MPIU_ERR_CHKANDJUMP1(!(*shm_addr_ptr), mpi_errno, MPI_ERR_OTHER,
"**intern", "**intern %s", "shm address is null");
MPIU_ERR_CHKINTERNAL(!(*shm_addr_ptr), mpi_errno, "shm address is null");
rc = UnmapViewOfFile(*shm_addr_ptr);
MPIU_ERR_CHKANDJUMP2((rc == 0), mpi_errno, MPI_ERR_OTHER,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment