Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/debugger/direct-multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ static pmix_status_t spawn_app(void)
} else {
PMIX_INFO_LIST_ADD(rc, tinfo, PMIX_DEBUG_STOP_IN_INIT, NULL, PMIX_BOOL); // All procs stop in PMIx_Init
}
sprintf(map_str, "ppr:%d:node", app_npernode);
snprintf(map_str, 30, "ppr:%d:node", app_npernode);
PMIX_INFO_LIST_ADD(rc, tinfo, PMIX_MAPBY, map_str, PMIX_STRING); // app procs/node
PMIX_INFO_LIST_ADD(rc, tinfo, PMIX_RANKBY, "slot", PMIX_STRING); // match baseline
PMIX_INFO_LIST_ADD(rc, tinfo, PMIX_FWD_STDOUT, NULL, PMIX_BOOL); // forward stdout to me
Expand Down
4 changes: 2 additions & 2 deletions examples/debugger/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ static int cospawn_launch(myrel_t *myrel)
/* Process that is spawning processes is a tool process */
PMIX_INFO_LIST_ADD(rc, dirs, PMIX_REQUESTOR_IS_TOOL, NULL, PMIX_BOOL);
/* Map spawned processes by slot */
sprintf(map_str, "ppr:%d:node", app_npernode);
snprintf(map_str, 128, "ppr:%d:node", app_npernode);
PMIX_INFO_LIST_ADD(rc, dirs, PMIX_MAPBY, map_str, PMIX_STRING);
PMIX_INFO_LIST_CONVERT(rc, dirs, &darray);
PMIX_INFO_LIST_RELEASE(dirs);
Expand Down Expand Up @@ -824,7 +824,7 @@ int main(int argc, char **argv)
// procs are to pause in PMIx_Init for debugger attach
PMIX_INFO_LIST_ADD(rc, dirs, PMIX_DEBUG_STOP_IN_INIT, NULL, PMIX_BOOL);
}
sprintf(map_str, "ppr:%d:node", app_npernode);
snprintf(map_str, 128, "ppr:%d:node", app_npernode);
PMIX_INFO_LIST_ADD(rc, dirs, PMIX_MAPBY, map_str, PMIX_STRING); // 1 per node
PMIX_INFO_LIST_ADD(rc, dirs, PMIX_FWD_STDOUT, NULL, PMIX_BOOL); // forward stdout to me
PMIX_INFO_LIST_ADD(rc, dirs, PMIX_FWD_STDERR, NULL, PMIX_BOOL); // forward stderr to me
Expand Down
8 changes: 8 additions & 0 deletions src/mca/rmaps/base/rmaps_base_map_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,13 @@ void prte_rmaps_base_map_job(int fd, short args, void *cbdata)
options.nprocs += app->num_procs;
continue;
}

if (PRTE_MAPPING_SEQ == PRTE_GET_MAPPING_POLICY(jdata->map->mapping) ||
PRTE_MAPPING_BYUSER == PRTE_GET_MAPPING_POLICY(jdata->map->mapping)) {
// these mappers compute their #procs as they go
continue;
}

if (1 < jdata->num_apps && 0 == app->num_procs) {
pmix_show_help("help-prte-rmaps-base.txt",
"multi-apps-and-zero-np", true,
Expand Down Expand Up @@ -562,6 +569,7 @@ void prte_rmaps_base_map_job(int fd, short args, void *cbdata)
HWLOC_OBJ_PU);
}
}

} else {
if (NULL != options.cpuset) {
ck = PMIX_ARGV_SPLIT_COMPAT(options.cpuset, ',');
Expand Down
12 changes: 6 additions & 6 deletions src/mca/rmaps/rank_file/rmaps_rank_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ static int prte_rmaps_rank_file_parse(const char *rankfile)
case PRTE_RANKFILE_INT:
case PRTE_RANKFILE_RELATIVE:
if (PRTE_RANKFILE_INT == token) {
sprintf(buff, "%d", prte_rmaps_rank_file_value.ival);
snprintf(buff,RMAPS_RANK_FILE_MAX_SLOTS, "%d", prte_rmaps_rank_file_value.ival);
value = buff;
} else {
value = prte_rmaps_rank_file_value.sval;
Expand Down Expand Up @@ -627,7 +627,7 @@ static int prte_rmaps_rank_file_parse(const char *rankfile)
goto unlock;
} else {
/* prepare rank assignment string for the help message in case of a bad-assign */
sprintf(tmp_rank_assignment, "%s slot=%s", node_name, value);
snprintf(tmp_rank_assignment, RMAPS_RANK_FILE_MAX_SLOTS, "%s slot=%s", node_name, value);
pmix_pointer_array_set_item(assigned_ranks_array, 0, tmp_rank_assignment);
}

Expand Down Expand Up @@ -671,7 +671,7 @@ static char *prte_rmaps_rank_file_parse_string_or_int(void)
case PRTE_RANKFILE_STRING:
return strdup(prte_rmaps_rank_file_value.sval);
case PRTE_RANKFILE_INT:
sprintf(tmp_str, "%d", prte_rmaps_rank_file_value.ival);
snprintf(tmp_str, RMAPS_RANK_FILE_MAX_SLOTS, "%d", prte_rmaps_rank_file_value.ival);
return strdup(tmp_str);
default:
return NULL;
Expand Down Expand Up @@ -787,7 +787,7 @@ static int prte_rmaps_rf_lsf_convert_affinity_to_rankfile(char *affinity_file, c
// session dir + / (1) + lsf_rf. (7) + XXXXXX (6) + \0 (1)
len = strlen(prte_process_info.top_session_dir) + 1 + 7 + 6 + 1;
(*aff_rankfile) = (char*) malloc(sizeof(char) * len);
sprintf(*aff_rankfile, "%s/lsf_rf.XXXXXX", prte_process_info.top_session_dir);
snprintf(*aff_rankfile, len, "%s/lsf_rf.XXXXXX", prte_process_info.top_session_dir);

/* open the file */
fp = fopen(affinity_file, "r");
Expand Down Expand Up @@ -882,7 +882,7 @@ static int prte_rmaps_rf_lsf_convert_affinity_to_rankfile(char *affinity_file, c
free(cpus[i]);
// 10 max number of digits in an int
cpus[i] = (char*)malloc(sizeof(char) * 10);
sprintf(cpus[i], "%d", obj->logical_index);
snprintf(cpus[i], 10, "%d", obj->logical_index);
}
sep = PMIX_ARGV_JOIN_COMPAT(cpus, ',');
PMIX_ARGV_FREE_COMPAT(cpus);
Expand All @@ -893,7 +893,7 @@ static int prte_rmaps_rf_lsf_convert_affinity_to_rankfile(char *affinity_file, c
// "rank " (5) + id (max 10) + = (1) + host (?) + " slot=" (6) + ids (?) + '\0' (1)
len = 5 + 10 + 1 + strlen(hstname) + 6 + strlen(sep) + 1;
tmp_str = (char *)malloc(sizeof(char) * len);
sprintf(tmp_str, "rank %d=%s slot=%s\n", cur_rank, hstname, sep);
snprintf(tmp_str, len, "rank %d=%s slot=%s\n", cur_rank, hstname, sep);
pmix_fd_write(fp_rank, strlen(tmp_str), tmp_str);
free(tmp_str);
++cur_rank;
Expand Down
2 changes: 1 addition & 1 deletion src/rml/oob/oob_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ int prte_oob_open(void)
sizeof(copied_interface->if_mac));
copied_interface->ifmtu = selected_interface->ifmtu;
/* Add the if_mask to the list */
sprintf(string, "%d", selected_interface->if_mask);
snprintf(string, 50, "%d", selected_interface->if_mask);
PMIX_ARGV_APPEND_NOSIZE_COMPAT(&prte_oob_base.if_masks, string);
pmix_list_append(&prte_oob_base.local_ifs, &(copied_interface->super));
}
Expand Down
40 changes: 36 additions & 4 deletions src/util/dash_host/dash_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,19 @@ int prte_util_add_dash_host_nodes(pmix_list_t *nodes, char *hosts, bool allocati
*/
static int parse_dash_host(char ***mapped_nodes, char *hosts)
{
int32_t j, k;
int32_t j, k, start;
int rc = PRTE_SUCCESS;
char **mini_map = NULL, *cptr;
int nodeidx;
int nodeidx, nnodes, p;
prte_node_t *node;
char **host_argv = NULL;

host_argv = PMIX_ARGV_SPLIT_COMPAT(hosts, ',');
if (prte_hnp_is_allocated) {
start = 0;
} else {
start = 1;
}

/* Accumulate all of the host name mappings */
for (j = 0; j < PMIX_ARGV_COUNT_COMPAT(host_argv); ++j) {
Expand All @@ -472,8 +477,35 @@ static int parse_dash_host(char ***mapped_nodes, char *hosts)
*/
if (NULL != (cptr = strchr(mini_map[k], ':'))) {
/* the colon indicates a specific # are requested */
*cptr = '*';
PMIX_ARGV_APPEND_NOSIZE_COMPAT(mapped_nodes, cptr);
++cptr;
if (NULL == cptr) {
// missing number of nodes being requested
pmix_show_help("help-dash-host.txt",
"dash-host:invalid-relative-node-syntax", true,
mini_map[k]);
rc = PRTE_ERR_SILENT;
goto cleanup;
}
nnodes = strtol(cptr, NULL, 10);
for (j=start, p=0; j < (int32_t)prte_node_pool->size && p < nnodes; j++) {
node = (prte_node_t *) pmix_pointer_array_get_item(prte_node_pool, j);
if (NULL == node) {
continue;
}
// if the node is empty, capture it
if (0 == node->num_procs) {
PMIX_ARGV_APPEND_NOSIZE_COMPAT(mapped_nodes, node->name);
++p;
}
}
if (p < nnodes) {
// not enough empty nodes
pmix_show_help("help-dash-host.txt",
"dash-host:not-enough-empty", true,
nnodes-p);
rc = PRTE_ERR_SILENT;
goto cleanup;
}
} else {
/* add a marker to the list */
PMIX_ARGV_APPEND_NOSIZE_COMPAT(mapped_nodes, "*");
Expand Down
4 changes: 3 additions & 1 deletion src/util/dash_host/help-dash-host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ A relative host was improperly specified — the value provided was.
--host: %s

You may have forgotten to preface a node with "N" or "n", or used the
"e" or "E" to indicate empty nodes.
"e" or "E" to indicate empty nodes, or you ended the value with a
colon but forgot to include the number of empty nodes you were
requesting.

Re-run this command with "--help hosts" for further information.
#
Expand Down
6 changes: 3 additions & 3 deletions test/double-get.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ int main(int argc, char *argv[])
PMIX_VALUE_RELEASE(pvalue);

/* the below two lines break the subsequent PMIx_Get query on a key set later */
sprintf(data, "FIRST TIME rank %d", myproc.rank);
pmi_set_string("test-key-1", data, 256);
snprintf(data, 256, "FIRST TIME rank %d", myproc.rank);
pnmi_set_string("test-key-1", data, 256);
pmix_exchange(true);

if (1 == myproc.rank) {
Expand All @@ -166,7 +166,7 @@ int main(int argc, char *argv[])
}
}

sprintf(data, "SECOND TIME rank %d", myproc.rank);
snprintf(data, 256, "SECOND TIME rank %d", myproc.rank);
if (0 == myproc.rank) {
pmi_set_string("test-key-2", data, 256);
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/get-nofence.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ int main(int argc, char *argv[])
PMIX_VALUE_RELEASE(pvalue);

/* the below two lines break the subsequent PMIx_Get query on a key set later */
sprintf(data, "FIRST TIME rank %d", myproc.rank);
snprintf(data, 256, "FIRST TIME rank %d", myproc.rank);
pmi_set_string("test-key-1", data, 256);

if (timeout) {
Expand Down
119 changes: 0 additions & 119 deletions test/ptrace/ptrace_spawn_stopped.cxx

This file was deleted.

Loading