1
1

Correct a misplaced bracket - daemons shouldn't be doing app-related operations

This may need a patch for 1.8.2, but we can try to directly apply it

cmr=v1.8.2:reviewer=hjelmn

This commit was SVN r31754.
Этот коммит содержится в:
Ralph Castain 2014-05-14 15:23:30 +00:00
родитель f27123a20d
Коммит 3a1c2fff3e

Просмотреть файл

@ -133,7 +133,6 @@ static int rte_init(void)
goto error;
}
ORTE_PROC_MY_NAME->jobid = jobid;
opal_output(0, "GETTING RANK");
/* get our rank from PMI */
if (!mca_common_pmi_rank(&i)) {
error = "could not get PMI rank";
@ -154,220 +153,224 @@ static int rte_init(void)
error = "orte_ess_base_orted_setup";
goto error;
}
} else { /* we are a direct-launched MPI process */
#if WANT_PMI2_SUPPORT
/* Get domain id */
pmi_id = (char*)malloc(PMI2_MAX_VALLEN);
if (PMI_SUCCESS != (ret = PMI2_Job_GetId(pmi_id, PMI2_MAX_VALLEN))) {
error = "PMI2_Job_GetId failed";
goto error;
}
#else
{
int pmi_maxlen;
return ORTE_SUCCESS;
/* get our PMI id length */
if (PMI_SUCCESS != (ret = PMI_Get_id_length_max(&pmi_maxlen))) {
error = "PMI_Get_id_length_max";
goto error;
}
pmi_id = (char*)malloc(pmi_maxlen);
if (PMI_SUCCESS != (ret = PMI_Get_kvs_domain_id(pmi_id, pmi_maxlen))) {
free(pmi_id);
error = "PMI_Get_kvs_domain_id";
goto error;
}
}
#endif
/* PMI is very nice to us - the domain id is an integer followed
* by a '.', followed by essentially a stepid. The first integer
* defines an overall job number. The second integer is the number of
* individual jobs we have run within that allocation. So we translate
* this as the overall job number equating to our job family, and
* the individual number equating to our local jobid
*/
jobfam = strtol(pmi_id, &localj, 10);
if (NULL == localj) {
/* hmmm - no '.', so let's just use zero */
stepid = 0;
} else {
localj++; /* step over the '.' */
stepid = strtol(localj, NULL, 10) + 1; /* add one to avoid looking like a daemon */
}
free(pmi_id);
/* now build the jobid */
ORTE_PROC_MY_NAME->jobid = ORTE_CONSTRUCT_LOCAL_JOBID(jobfam << 16, stepid);
/* get our rank */
if (!mca_common_pmi_rank(&i)) {
error = "could not get PMI rank";
goto error;
}
ORTE_PROC_MY_NAME->vpid = i;
/* get the number of procs from PMI */
if (!mca_common_pmi_size(&i)) {
error = "could not get PMI universe size";
goto error;
}
orte_process_info.num_procs = i;
/* push into the environ for pickup in MPI layer for
* MPI-3 required info key
*/
asprintf(&ev1, "OMPI_MCA_orte_ess_num_procs=%d", i);
putenv(ev1);
asprintf(&ev2, "OMPI_APP_CTX_NUM_PROCS=%d", i);
putenv(ev2);
/* setup transport keys in case the MPI layer needs them -
* we can use the jobfam and stepid as unique keys
* because they are unique values assigned by the RM
*/
unique_key[0] = (uint64_t)jobfam;
unique_key[1] = (uint64_t)stepid;
if (NULL == (string_key = orte_pre_condition_transports_print(unique_key))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (OPAL_SUCCESS != mca_base_var_env_name ("orte_precondition_transports", &cs_env)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
asprintf(&envar, "%s=%s", cs_env, string_key);
putenv(envar);
/* cannot free the envar as that messes up our environ */
free(cs_env);
free(string_key);
/* our app_context number can only be 0 as we don't support
* dynamic spawns
*/
orte_process_info.app_num = 0;
/* setup my daemon's name - arbitrary, since we don't route
* messages
*/
ORTE_PROC_MY_DAEMON->jobid = 0;
ORTE_PROC_MY_DAEMON->vpid = 0;
/* ensure we pick the correct critical components */
putenv("OMPI_MCA_grpcomm=pmi");
putenv("OMPI_MCA_db_pmi_store_priority=100");
putenv("OMPI_MCA_routed=direct");
/* now use the default procedure to finish my setup */
if (ORTE_SUCCESS != (ret = orte_ess_base_app_setup(false))) {
ORTE_ERROR_LOG(ret);
error = "orte_ess_base_app_setup";
goto error;
}
#if WANT_PMI2_SUPPORT
{
/* get our local proc info to find our local rank */
char *pmapping = (char*)malloc(PMI2_MAX_VALLEN);
int found, sid, nodes, k;
orte_vpid_t n;
char *p;
ret = PMI2_Info_GetJobAttr("PMI_process_mapping", pmapping, PMI2_MAX_VALLEN, &found);
if (!found || PMI_SUCCESS != ret) { /* can't check PMI2_SUCCESS as some folks (i.e., Cray) don't define it */
error = "could not get PMI_process_mapping (PMI2_Info_GetJobAttr() failed)";
goto error;
}
i = 0; n = 0; procs = 0;
if (NULL != (p = strstr(pmapping, "(vector"))) {
while (NULL != (p = strstr(p+1, ",("))) {
if (3 == sscanf(p, ",(%d,%d,%d)", &sid, &nodes, &procs)) {
for (k = 0; k < nodes; k++) {
if ((ORTE_PROC_MY_NAME->vpid >= n) &&
(ORTE_PROC_MY_NAME->vpid < (n + procs))) {
break;
}
n += procs;
}
} else {
procs = 0;
}
}
}
free(pmapping);
if (0 < procs) {
ranks = (int*)malloc(procs * sizeof(int));
for (i=0; i < procs; i++) {
ranks[i] = n + i;
}
}
if (NULL == ranks) {
error = "could not get PMI_process_mapping";
goto error;
}
}
#else
/* get our local proc info to find our local rank */
if (PMI_SUCCESS != (ret = PMI_Get_clique_size(&procs))) {
OPAL_PMI_ERROR(ret, "PMI_Get_clique_size");
error = "could not get PMI clique size";
goto error;
}
/* now get the specific ranks */
ranks = (int*)calloc(procs, sizeof(int));
if (NULL == ranks) {
error = "could not get memory for local ranks";
ret = ORTE_ERR_OUT_OF_RESOURCE;
goto error;
}
if (PMI_SUCCESS != (ret = PMI_Get_clique_ranks(ranks, procs))) {
OPAL_PMI_ERROR(ret, "PMI_Get_clique_ranks");
error = "could not get clique ranks";
goto error;
}
#endif
/* store the number of local peers - remember, we want the number
* of peers that share the node WITH ME, so we have to subtract
* ourselves from that number
*/
orte_process_info.num_local_peers = procs - 1;
/* The clique ranks are returned in rank order, so
* cycle thru the array and update the local/node
* rank info
*/
for (j=0; j < procs; j++) {
if (ranks[j] == (int)ORTE_PROC_MY_NAME->vpid) {
orte_process_info.my_local_rank = (orte_local_rank_t)j;
orte_process_info.my_node_rank = (orte_node_rank_t)j;
break;
}
}
/* store the name of the local leader */
ldr.jobid = ORTE_PROC_MY_NAME->jobid;
ldr.vpid = ranks[0];
OBJ_CONSTRUCT(&kv, opal_value_t);
kv.key = strdup(OPAL_DSTORE_LOCALLDR);
kv.type = OPAL_ID_T;
kv.data.uint64 = *(opal_identifier_t*)&ldr;
if (ORTE_SUCCESS != (ret = opal_dstore.store(opal_dstore_internal,
(opal_identifier_t*)ORTE_PROC_MY_NAME, &kv))) {
error = "storing local leader";
OBJ_DESTRUCT(&kv);
goto error;
}
OBJ_DESTRUCT(&kv);
free(ranks);
/* setup process binding */
if (ORTE_SUCCESS != (ret = orte_ess_base_proc_binding())) {
error = "proc_binding";
goto error;
}
/* this needs to be set to enable debugger use when direct launched */
orte_standalone_operation = true;
}
/* we are a direct-launched MPI process */
#if WANT_PMI2_SUPPORT
/* Get domain id */
pmi_id = (char*)malloc(PMI2_MAX_VALLEN);
if (PMI_SUCCESS != (ret = PMI2_Job_GetId(pmi_id, PMI2_MAX_VALLEN))) {
error = "PMI2_Job_GetId failed";
goto error;
}
#else
{
int pmi_maxlen;
/* get our PMI id length */
if (PMI_SUCCESS != (ret = PMI_Get_id_length_max(&pmi_maxlen))) {
error = "PMI_Get_id_length_max";
goto error;
}
pmi_id = (char*)malloc(pmi_maxlen);
if (PMI_SUCCESS != (ret = PMI_Get_kvs_domain_id(pmi_id, pmi_maxlen))) {
free(pmi_id);
error = "PMI_Get_kvs_domain_id";
goto error;
}
}
#endif
/* PMI is very nice to us - the domain id is an integer followed
* by a '.', followed by essentially a stepid. The first integer
* defines an overall job number. The second integer is the number of
* individual jobs we have run within that allocation. So we translate
* this as the overall job number equating to our job family, and
* the individual number equating to our local jobid
*/
jobfam = strtol(pmi_id, &localj, 10);
if (NULL == localj) {
/* hmmm - no '.', so let's just use zero */
stepid = 0;
} else {
localj++; /* step over the '.' */
stepid = strtol(localj, NULL, 10) + 1; /* add one to avoid looking like a daemon */
}
free(pmi_id);
/* now build the jobid */
ORTE_PROC_MY_NAME->jobid = ORTE_CONSTRUCT_LOCAL_JOBID(jobfam << 16, stepid);
/* get our rank */
if (!mca_common_pmi_rank(&i)) {
error = "could not get PMI rank";
goto error;
}
ORTE_PROC_MY_NAME->vpid = i;
/* get the number of procs from PMI */
if (!mca_common_pmi_size(&i)) {
error = "could not get PMI universe size";
goto error;
}
orte_process_info.num_procs = i;
/* push into the environ for pickup in MPI layer for
* MPI-3 required info key
*/
asprintf(&ev1, "OMPI_MCA_orte_ess_num_procs=%d", i);
putenv(ev1);
asprintf(&ev2, "OMPI_APP_CTX_NUM_PROCS=%d", i);
putenv(ev2);
/* setup transport keys in case the MPI layer needs them -
* we can use the jobfam and stepid as unique keys
* because they are unique values assigned by the RM
*/
unique_key[0] = (uint64_t)jobfam;
unique_key[1] = (uint64_t)stepid;
if (NULL == (string_key = orte_pre_condition_transports_print(unique_key))) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
if (OPAL_SUCCESS != mca_base_var_env_name ("orte_precondition_transports", &cs_env)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE;
}
asprintf(&envar, "%s=%s", cs_env, string_key);
putenv(envar);
/* cannot free the envar as that messes up our environ */
free(cs_env);
free(string_key);
/* our app_context number can only be 0 as we don't support
* dynamic spawns
*/
orte_process_info.app_num = 0;
/* setup my daemon's name - arbitrary, since we don't route
* messages
*/
ORTE_PROC_MY_DAEMON->jobid = 0;
ORTE_PROC_MY_DAEMON->vpid = 0;
/* ensure we pick the correct critical components */
putenv("OMPI_MCA_grpcomm=pmi");
putenv("OMPI_MCA_db_pmi_store_priority=100");
putenv("OMPI_MCA_routed=direct");
/* now use the default procedure to finish my setup */
if (ORTE_SUCCESS != (ret = orte_ess_base_app_setup(false))) {
ORTE_ERROR_LOG(ret);
error = "orte_ess_base_app_setup";
goto error;
}
#if WANT_PMI2_SUPPORT
{
/* get our local proc info to find our local rank */
char *pmapping = (char*)malloc(PMI2_MAX_VALLEN);
int found, sid, nodes, k;
orte_vpid_t n;
char *p;
ret = PMI2_Info_GetJobAttr("PMI_process_mapping", pmapping, PMI2_MAX_VALLEN, &found);
if (!found || PMI_SUCCESS != ret) { /* can't check PMI2_SUCCESS as some folks (i.e., Cray) don't define it */
error = "could not get PMI_process_mapping (PMI2_Info_GetJobAttr() failed)";
goto error;
}
i = 0; n = 0; procs = 0;
if (NULL != (p = strstr(pmapping, "(vector"))) {
while (NULL != (p = strstr(p+1, ",("))) {
if (3 == sscanf(p, ",(%d,%d,%d)", &sid, &nodes, &procs)) {
for (k = 0; k < nodes; k++) {
if ((ORTE_PROC_MY_NAME->vpid >= n) &&
(ORTE_PROC_MY_NAME->vpid < (n + procs))) {
break;
}
n += procs;
}
} else {
procs = 0;
}
}
}
free(pmapping);
if (0 < procs) {
ranks = (int*)malloc(procs * sizeof(int));
for (i=0; i < procs; i++) {
ranks[i] = n + i;
}
}
if (NULL == ranks) {
error = "could not get PMI_process_mapping";
goto error;
}
}
#else
/* get our local proc info to find our local rank */
if (PMI_SUCCESS != (ret = PMI_Get_clique_size(&procs))) {
OPAL_PMI_ERROR(ret, "PMI_Get_clique_size");
error = "could not get PMI clique size";
goto error;
}
/* now get the specific ranks */
ranks = (int*)calloc(procs, sizeof(int));
if (NULL == ranks) {
error = "could not get memory for local ranks";
ret = ORTE_ERR_OUT_OF_RESOURCE;
goto error;
}
if (PMI_SUCCESS != (ret = PMI_Get_clique_ranks(ranks, procs))) {
OPAL_PMI_ERROR(ret, "PMI_Get_clique_ranks");
error = "could not get clique ranks";
goto error;
}
#endif
/* store the number of local peers - remember, we want the number
* of peers that share the node WITH ME, so we have to subtract
* ourselves from that number
*/
orte_process_info.num_local_peers = procs - 1;
/* The clique ranks are returned in rank order, so
* cycle thru the array and update the local/node
* rank info
*/
for (j=0; j < procs; j++) {
if (ranks[j] == (int)ORTE_PROC_MY_NAME->vpid) {
orte_process_info.my_local_rank = (orte_local_rank_t)j;
orte_process_info.my_node_rank = (orte_node_rank_t)j;
break;
}
}
/* store the name of the local leader */
ldr.jobid = ORTE_PROC_MY_NAME->jobid;
ldr.vpid = ranks[0];
OBJ_CONSTRUCT(&kv, opal_value_t);
kv.key = strdup(OPAL_DSTORE_LOCALLDR);
kv.type = OPAL_ID_T;
kv.data.uint64 = *(opal_identifier_t*)&ldr;
if (ORTE_SUCCESS != (ret = opal_dstore.store(opal_dstore_internal,
(opal_identifier_t*)ORTE_PROC_MY_NAME, &kv))) {
error = "storing local leader";
OBJ_DESTRUCT(&kv);
goto error;
}
OBJ_DESTRUCT(&kv);
free(ranks);
/* setup process binding */
if (ORTE_SUCCESS != (ret = orte_ess_base_proc_binding())) {
error = "proc_binding";
goto error;
}
/* this needs to be set to enable debugger use when direct launched */
orte_standalone_operation = true;
/* set max procs */
if (orte_process_info.max_procs < orte_process_info.num_procs) {
orte_process_info.max_procs = orte_process_info.num_procs;
@ -376,7 +379,7 @@ static int rte_init(void)
/* construct the PMI RTE string */
rmluri = orte_rml.get_contact_info();
OBJ_CONSTRUCT(&kv, opal_value_t);
OBJ_CONSTRUCT(&kv, opal_value_t);
kv.key = strdup(ORTE_DB_RMLURI);
kv.type = OPAL_STRING;
kv.data.string = strdup(rmluri);