Skip to content

Commit d615ba0

Browse files
authored
Merge pull request #95 from openpmix/master
Fork Sync: Update from parent repository
2 parents b972f05 + 2ff7d6b commit d615ba0

File tree

10 files changed

+61
-138
lines changed

10 files changed

+61
-138
lines changed

examples/debugger/direct-multi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ static pmix_status_t spawn_app(void)
564564
} else {
565565
PMIX_INFO_LIST_ADD(rc, tinfo, PMIX_DEBUG_STOP_IN_INIT, NULL, PMIX_BOOL); // All procs stop in PMIx_Init
566566
}
567-
sprintf(map_str, "ppr:%d:node", app_npernode);
567+
snprintf(map_str, 30, "ppr:%d:node", app_npernode);
568568
PMIX_INFO_LIST_ADD(rc, tinfo, PMIX_MAPBY, map_str, PMIX_STRING); // app procs/node
569569
PMIX_INFO_LIST_ADD(rc, tinfo, PMIX_RANKBY, "slot", PMIX_STRING); // match baseline
570570
PMIX_INFO_LIST_ADD(rc, tinfo, PMIX_FWD_STDOUT, NULL, PMIX_BOOL); // forward stdout to me

examples/debugger/direct.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static int cospawn_launch(myrel_t *myrel)
338338
/* Process that is spawning processes is a tool process */
339339
PMIX_INFO_LIST_ADD(rc, dirs, PMIX_REQUESTOR_IS_TOOL, NULL, PMIX_BOOL);
340340
/* Map spawned processes by slot */
341-
sprintf(map_str, "ppr:%d:node", app_npernode);
341+
snprintf(map_str, 128, "ppr:%d:node", app_npernode);
342342
PMIX_INFO_LIST_ADD(rc, dirs, PMIX_MAPBY, map_str, PMIX_STRING);
343343
PMIX_INFO_LIST_CONVERT(rc, dirs, &darray);
344344
PMIX_INFO_LIST_RELEASE(dirs);
@@ -824,7 +824,7 @@ int main(int argc, char **argv)
824824
// procs are to pause in PMIx_Init for debugger attach
825825
PMIX_INFO_LIST_ADD(rc, dirs, PMIX_DEBUG_STOP_IN_INIT, NULL, PMIX_BOOL);
826826
}
827-
sprintf(map_str, "ppr:%d:node", app_npernode);
827+
snprintf(map_str, 128, "ppr:%d:node", app_npernode);
828828
PMIX_INFO_LIST_ADD(rc, dirs, PMIX_MAPBY, map_str, PMIX_STRING); // 1 per node
829829
PMIX_INFO_LIST_ADD(rc, dirs, PMIX_FWD_STDOUT, NULL, PMIX_BOOL); // forward stdout to me
830830
PMIX_INFO_LIST_ADD(rc, dirs, PMIX_FWD_STDERR, NULL, PMIX_BOOL); // forward stderr to me

src/mca/rmaps/base/rmaps_base_map_job.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,13 @@ void prte_rmaps_base_map_job(int fd, short args, void *cbdata)
504504
options.nprocs += app->num_procs;
505505
continue;
506506
}
507+
508+
if (PRTE_MAPPING_SEQ == PRTE_GET_MAPPING_POLICY(jdata->map->mapping) ||
509+
PRTE_MAPPING_BYUSER == PRTE_GET_MAPPING_POLICY(jdata->map->mapping)) {
510+
// these mappers compute their #procs as they go
511+
continue;
512+
}
513+
507514
if (1 < jdata->num_apps && 0 == app->num_procs) {
508515
pmix_show_help("help-prte-rmaps-base.txt",
509516
"multi-apps-and-zero-np", true,
@@ -562,6 +569,7 @@ void prte_rmaps_base_map_job(int fd, short args, void *cbdata)
562569
HWLOC_OBJ_PU);
563570
}
564571
}
572+
565573
} else {
566574
if (NULL != options.cpuset) {
567575
ck = PMIX_ARGV_SPLIT_COMPAT(options.cpuset, ',');

src/mca/rmaps/rank_file/rmaps_rank_file.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ static int prte_rmaps_rank_file_parse(const char *rankfile)
562562
case PRTE_RANKFILE_INT:
563563
case PRTE_RANKFILE_RELATIVE:
564564
if (PRTE_RANKFILE_INT == token) {
565-
sprintf(buff, "%d", prte_rmaps_rank_file_value.ival);
565+
snprintf(buff,RMAPS_RANK_FILE_MAX_SLOTS, "%d", prte_rmaps_rank_file_value.ival);
566566
value = buff;
567567
} else {
568568
value = prte_rmaps_rank_file_value.sval;
@@ -627,7 +627,7 @@ static int prte_rmaps_rank_file_parse(const char *rankfile)
627627
goto unlock;
628628
} else {
629629
/* prepare rank assignment string for the help message in case of a bad-assign */
630-
sprintf(tmp_rank_assignment, "%s slot=%s", node_name, value);
630+
snprintf(tmp_rank_assignment, RMAPS_RANK_FILE_MAX_SLOTS, "%s slot=%s", node_name, value);
631631
pmix_pointer_array_set_item(assigned_ranks_array, 0, tmp_rank_assignment);
632632
}
633633

@@ -671,7 +671,7 @@ static char *prte_rmaps_rank_file_parse_string_or_int(void)
671671
case PRTE_RANKFILE_STRING:
672672
return strdup(prte_rmaps_rank_file_value.sval);
673673
case PRTE_RANKFILE_INT:
674-
sprintf(tmp_str, "%d", prte_rmaps_rank_file_value.ival);
674+
snprintf(tmp_str, RMAPS_RANK_FILE_MAX_SLOTS, "%d", prte_rmaps_rank_file_value.ival);
675675
return strdup(tmp_str);
676676
default:
677677
return NULL;
@@ -787,7 +787,7 @@ static int prte_rmaps_rf_lsf_convert_affinity_to_rankfile(char *affinity_file, c
787787
// session dir + / (1) + lsf_rf. (7) + XXXXXX (6) + \0 (1)
788788
len = strlen(prte_process_info.top_session_dir) + 1 + 7 + 6 + 1;
789789
(*aff_rankfile) = (char*) malloc(sizeof(char) * len);
790-
sprintf(*aff_rankfile, "%s/lsf_rf.XXXXXX", prte_process_info.top_session_dir);
790+
snprintf(*aff_rankfile, len, "%s/lsf_rf.XXXXXX", prte_process_info.top_session_dir);
791791

792792
/* open the file */
793793
fp = fopen(affinity_file, "r");
@@ -882,7 +882,7 @@ static int prte_rmaps_rf_lsf_convert_affinity_to_rankfile(char *affinity_file, c
882882
free(cpus[i]);
883883
// 10 max number of digits in an int
884884
cpus[i] = (char*)malloc(sizeof(char) * 10);
885-
sprintf(cpus[i], "%d", obj->logical_index);
885+
snprintf(cpus[i], 10, "%d", obj->logical_index);
886886
}
887887
sep = PMIX_ARGV_JOIN_COMPAT(cpus, ',');
888888
PMIX_ARGV_FREE_COMPAT(cpus);
@@ -893,7 +893,7 @@ static int prte_rmaps_rf_lsf_convert_affinity_to_rankfile(char *affinity_file, c
893893
// "rank " (5) + id (max 10) + = (1) + host (?) + " slot=" (6) + ids (?) + '\0' (1)
894894
len = 5 + 10 + 1 + strlen(hstname) + 6 + strlen(sep) + 1;
895895
tmp_str = (char *)malloc(sizeof(char) * len);
896-
sprintf(tmp_str, "rank %d=%s slot=%s\n", cur_rank, hstname, sep);
896+
snprintf(tmp_str, len, "rank %d=%s slot=%s\n", cur_rank, hstname, sep);
897897
pmix_fd_write(fp_rank, strlen(tmp_str), tmp_str);
898898
free(tmp_str);
899899
++cur_rank;

src/rml/oob/oob_tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ int prte_oob_open(void)
287287
sizeof(copied_interface->if_mac));
288288
copied_interface->ifmtu = selected_interface->ifmtu;
289289
/* Add the if_mask to the list */
290-
sprintf(string, "%d", selected_interface->if_mask);
290+
snprintf(string, 50, "%d", selected_interface->if_mask);
291291
PMIX_ARGV_APPEND_NOSIZE_COMPAT(&prte_oob_base.if_masks, string);
292292
pmix_list_append(&prte_oob_base.local_ifs, &(copied_interface->super));
293293
}

src/util/dash_host/dash_host.c

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,14 +450,19 @@ int prte_util_add_dash_host_nodes(pmix_list_t *nodes, char *hosts, bool allocati
450450
*/
451451
static int parse_dash_host(char ***mapped_nodes, char *hosts)
452452
{
453-
int32_t j, k;
453+
int32_t j, k, start;
454454
int rc = PRTE_SUCCESS;
455455
char **mini_map = NULL, *cptr;
456-
int nodeidx;
456+
int nodeidx, nnodes, p;
457457
prte_node_t *node;
458458
char **host_argv = NULL;
459459

460460
host_argv = PMIX_ARGV_SPLIT_COMPAT(hosts, ',');
461+
if (prte_hnp_is_allocated) {
462+
start = 0;
463+
} else {
464+
start = 1;
465+
}
461466

462467
/* Accumulate all of the host name mappings */
463468
for (j = 0; j < PMIX_ARGV_COUNT_COMPAT(host_argv); ++j) {
@@ -472,8 +477,35 @@ static int parse_dash_host(char ***mapped_nodes, char *hosts)
472477
*/
473478
if (NULL != (cptr = strchr(mini_map[k], ':'))) {
474479
/* the colon indicates a specific # are requested */
475-
*cptr = '*';
476-
PMIX_ARGV_APPEND_NOSIZE_COMPAT(mapped_nodes, cptr);
480+
++cptr;
481+
if (NULL == cptr) {
482+
// missing number of nodes being requested
483+
pmix_show_help("help-dash-host.txt",
484+
"dash-host:invalid-relative-node-syntax", true,
485+
mini_map[k]);
486+
rc = PRTE_ERR_SILENT;
487+
goto cleanup;
488+
}
489+
nnodes = strtol(cptr, NULL, 10);
490+
for (j=start, p=0; j < (int32_t)prte_node_pool->size && p < nnodes; j++) {
491+
node = (prte_node_t *) pmix_pointer_array_get_item(prte_node_pool, j);
492+
if (NULL == node) {
493+
continue;
494+
}
495+
// if the node is empty, capture it
496+
if (0 == node->num_procs) {
497+
PMIX_ARGV_APPEND_NOSIZE_COMPAT(mapped_nodes, node->name);
498+
++p;
499+
}
500+
}
501+
if (p < nnodes) {
502+
// not enough empty nodes
503+
pmix_show_help("help-dash-host.txt",
504+
"dash-host:not-enough-empty", true,
505+
nnodes-p);
506+
rc = PRTE_ERR_SILENT;
507+
goto cleanup;
508+
}
477509
} else {
478510
/* add a marker to the list */
479511
PMIX_ARGV_APPEND_NOSIZE_COMPAT(mapped_nodes, "*");

src/util/dash_host/help-dash-host.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ A relative host was improperly specified — the value provided was.
4848
--host: %s
4949

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

5355
Re-run this command with "--help hosts" for further information.
5456
#

test/double-get.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ int main(int argc, char *argv[])
154154
PMIX_VALUE_RELEASE(pvalue);
155155

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

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

169-
sprintf(data, "SECOND TIME rank %d", myproc.rank);
169+
snprintf(data, 256, "SECOND TIME rank %d", myproc.rank);
170170
if (0 == myproc.rank) {
171171
pmi_set_string("test-key-2", data, 256);
172172
} else {

test/get-nofence.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ int main(int argc, char *argv[])
163163
PMIX_VALUE_RELEASE(pvalue);
164164

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

169169
if (timeout) {

test/ptrace/ptrace_spawn_stopped.cxx

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)