Skip to content

Commit dae71d3

Browse files
Ralph Castainhppritcha
authored andcommitted
Correct parsing of ppr directives
Needed to apply commit from PR open-mpi#5778 to get this commit from PR open-mpi#6238 to apply cleanly. Signed-off-by: Ralph Castain <rhc@open-mpi.org> (cherry picked from commit b19e5ed)
1 parent 18afb8e commit dae71d3

File tree

1 file changed

+115
-115
lines changed

1 file changed

+115
-115
lines changed

orte/mca/rmaps/base/rmaps_base_frame.c

Lines changed: 115 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2011-2013 Los Alamos National Security, LLC.
1414
* All rights reserved.
15-
* Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
15+
* Copyright (c) 2014-2019 Intel, Inc. All rights reserved.
1616
* Copyright (c) 2014-2015 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* $COPYRIGHT$
@@ -619,137 +619,137 @@ int orte_rmaps_base_set_mapping_policy(orte_job_t *jdata,
619619

620620
if (NULL == inspec) {
621621
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYSOCKET);
622-
} else {
623-
spec = strdup(inspec); // protect the input string
624-
/* see if a colon was included - if so, then we have a policy + modifier */
625-
ck = strchr(spec, ':');
626-
if (NULL != ck) {
627-
/* if the colon is the first character of the string, then we
628-
* just have modifiers on the default mapping policy */
629-
if (ck == spec) {
630-
ck++;
631-
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
632-
"%s rmaps:base only modifiers %s provided - assuming bysocket mapping",
633-
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), ck);
634-
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYSOCKET);
635-
if (ORTE_ERR_SILENT == (rc = check_modifiers(ck, &tmp)) &&
636-
ORTE_ERR_BAD_PARAM != rc) {
637-
free(spec);
638-
return ORTE_ERR_SILENT;
639-
}
622+
goto setpolicy;
623+
}
624+
625+
spec = strdup(inspec); // protect the input string
626+
/* see if a colon was included - if so, then we have a policy + modifier */
627+
ck = strchr(spec, ':');
628+
if (NULL != ck) {
629+
/* if the colon is the first character of the string, then we
630+
* just have modifiers on the default mapping policy */
631+
if (ck == spec) {
632+
ck++; // step over the colon
633+
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
634+
"%s rmaps:base only modifiers %s provided - assuming bysocket mapping",
635+
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), ck);
636+
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYSOCKET);
637+
if (ORTE_ERR_SILENT == (rc = check_modifiers(ck, &tmp)) &&
638+
ORTE_ERR_BAD_PARAM != rc) {
640639
free(spec);
641-
goto setpolicy;
640+
return ORTE_ERR_SILENT;
642641
}
643-
/* split the string */
644-
*ck = '\0';
645-
ck++;
646-
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
647-
"%s rmaps:base policy %s modifiers %s provided",
648-
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), spec, ck);
649-
/* if the policy is "dist", then we set the policy to that value
650-
* and save the second argument as the device
642+
free(spec);
643+
goto setpolicy;
644+
}
645+
*ck = '\0'; // terminate spec where the colon was
646+
ck++; // step past the colon
647+
opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
648+
"%s rmaps:base policy %s modifiers %s provided",
649+
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), spec, ck);
650+
651+
if (0 == strncasecmp(spec, "ppr", strlen(spec))) {
652+
/* at this point, ck points to a string that contains at least
653+
* two fields (specifying the #procs/obj and the object we are
654+
* to map by). we have to allow additional modifiers here - e.g.,
655+
* specifying #pe's/proc or oversubscribe - so check for modifiers. if
656+
* they are present, ck will look like "N:obj:mod1,mod2,mod3"
651657
*/
652-
if (0 == strncasecmp(spec, "ppr", strlen(spec))) {
653-
/* we have to allow additional modifiers here - e.g., specifying
654-
* #pe's/proc or oversubscribe - so check for modifiers
658+
if (NULL == (ptr = strchr(ck, ':'))) {
659+
/* this is an error - there had to be at least one
660+
* colon to delimit the number from the object type
655661
*/
656-
if (NULL == (ptr = strrchr(ck, ':'))) {
657-
/* this is an error - there had to be at least one
658-
* colon to delimit the number from the object type
659-
*/
660-
orte_show_help("help-orte-rmaps-base.txt", "invalid-pattern", true, inspec);
662+
orte_show_help("help-orte-rmaps-base.txt", "invalid-pattern", true, inspec);
663+
free(spec);
664+
return ORTE_ERR_SILENT;
665+
}
666+
ptr++; // move past the colon
667+
/* at this point, ptr is pointing to the beginning of the string that describes
668+
* the object plus any modifiers (i.e., "obj:mod1,mod2". We first check to see if there
669+
* is another colon indicating that there are modifiers to the request */
670+
if (NULL != (cptr = strchr(ptr, ':'))) {
671+
/* there are modifiers, so we terminate the object string
672+
* at the location of the colon */
673+
*cptr = '\0';
674+
/* step over that colon */
675+
cptr++;
676+
/* now check for modifiers - may be none, so
677+
* don't emit an error message if the modifier
678+
* isn't recognized */
679+
if (ORTE_ERR_SILENT == (rc = check_modifiers(cptr, &tmp)) &&
680+
ORTE_ERR_BAD_PARAM != rc) {
661681
free(spec);
662682
return ORTE_ERR_SILENT;
663683
}
664-
ptr++; // move past the colon
665-
/* at this point, ck is pointing to the number of procs/object
666-
* and ptr is pointing to the beginning of the string that describes
667-
* the object plus any modifiers. We first check to see if there
668-
* is a comma indicating that there are modifiers to the request */
669-
if (NULL != (cptr = strchr(ptr, ','))) {
670-
/* there are modifiers, so we terminate the object string
671-
* at the location of the first comma */
672-
*cptr = '\0';
673-
/* step over that comma */
674-
cptr++;
675-
/* now check for modifiers - may be none, so
676-
* don't emit an error message if the modifier
677-
* isn't recognized */
678-
if (ORTE_ERR_SILENT == (rc = check_modifiers(cptr, &tmp)) &&
679-
ORTE_ERR_BAD_PARAM != rc) {
680-
free(spec);
681-
return ORTE_ERR_SILENT;
682-
}
683-
}
684-
/* now save the pattern */
685-
if (NULL == jdata || NULL == jdata->map) {
686-
orte_rmaps_base.ppr = strdup(ck);
687-
} else {
688-
jdata->map->ppr = strdup(ck);
689-
}
690-
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_PPR);
691-
ORTE_SET_MAPPING_DIRECTIVE(tmp, ORTE_MAPPING_GIVEN);
692-
free(spec);
693-
goto setpolicy;
694684
}
695-
if (ORTE_SUCCESS != (rc = check_modifiers(ck, &tmp)) &&
696-
ORTE_ERR_TAKE_NEXT_OPTION != rc) {
697-
if (ORTE_ERR_BAD_PARAM == rc) {
698-
orte_show_help("help-orte-rmaps-base.txt", "unrecognized-modifier", true, inspec);
699-
}
700-
free(spec);
701-
return rc;
685+
/* now save the pattern */
686+
if (NULL == jdata || NULL == jdata->map) {
687+
orte_rmaps_base.ppr = strdup(ck);
688+
} else {
689+
jdata->map->ppr = strdup(ck);
702690
}
691+
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_PPR);
692+
ORTE_SET_MAPPING_DIRECTIVE(tmp, ORTE_MAPPING_GIVEN);
693+
free(spec);
694+
goto setpolicy;
703695
}
704-
len = strlen(spec);
705-
if (0 == strncasecmp(spec, "slot", len)) {
706-
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYSLOT);
707-
} else if (0 == strncasecmp(spec, "node", len)) {
708-
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYNODE);
709-
} else if (0 == strncasecmp(spec, "seq", len)) {
710-
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_SEQ);
711-
} else if (0 == strncasecmp(spec, "core", len)) {
712-
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYCORE);
713-
} else if (0 == strncasecmp(spec, "l1cache", len)) {
714-
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYL1CACHE);
715-
} else if (0 == strncasecmp(spec, "l2cache", len)) {
716-
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYL2CACHE);
717-
} else if (0 == strncasecmp(spec, "l3cache", len)) {
718-
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYL3CACHE);
719-
} else if (0 == strncasecmp(spec, "socket", len)) {
720-
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYSOCKET);
721-
} else if (0 == strncasecmp(spec, "numa", len)) {
722-
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYNUMA);
723-
} else if (0 == strncasecmp(spec, "board", len)) {
724-
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYBOARD);
725-
} else if (0 == strncasecmp(spec, "hwthread", len)) {
726-
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYHWTHREAD);
727-
/* if we are mapping processes to individual hwthreads, then
728-
* we need to treat those hwthreads as separate cpus
729-
*/
730-
opal_hwloc_use_hwthreads_as_cpus = true;
731-
} else if (0 == strncasecmp(spec, "dist", len)) {
732-
if (NULL != rmaps_dist_device) {
733-
if (NULL != (pch = strchr(rmaps_dist_device, ':'))) {
734-
*pch = '\0';
735-
}
736-
if (NULL != device) {
737-
*device = strdup(rmaps_dist_device);
738-
}
739-
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYDIST);
740-
} else {
741-
orte_show_help("help-orte-rmaps-base.txt", "device-not-specified", true);
742-
free(spec);
743-
return ORTE_ERR_SILENT;
696+
if (ORTE_SUCCESS != (rc = check_modifiers(ck, &tmp)) &&
697+
ORTE_ERR_TAKE_NEXT_OPTION != rc) {
698+
if (ORTE_ERR_BAD_PARAM == rc) {
699+
orte_show_help("help-orte-rmaps-base.txt", "unrecognized-modifier", true, inspec);
700+
}
701+
free(spec);
702+
return rc;
703+
}
704+
}
705+
len = strlen(spec);
706+
if (0 == strncasecmp(spec, "slot", len)) {
707+
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYSLOT);
708+
} else if (0 == strncasecmp(spec, "node", len)) {
709+
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYNODE);
710+
} else if (0 == strncasecmp(spec, "seq", len)) {
711+
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_SEQ);
712+
} else if (0 == strncasecmp(spec, "core", len)) {
713+
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYCORE);
714+
} else if (0 == strncasecmp(spec, "l1cache", len)) {
715+
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYL1CACHE);
716+
} else if (0 == strncasecmp(spec, "l2cache", len)) {
717+
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYL2CACHE);
718+
} else if (0 == strncasecmp(spec, "l3cache", len)) {
719+
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYL3CACHE);
720+
} else if (0 == strncasecmp(spec, "socket", len)) {
721+
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYSOCKET);
722+
} else if (0 == strncasecmp(spec, "numa", len)) {
723+
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYNUMA);
724+
} else if (0 == strncasecmp(spec, "board", len)) {
725+
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYBOARD);
726+
} else if (0 == strncasecmp(spec, "hwthread", len)) {
727+
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYHWTHREAD);
728+
/* if we are mapping processes to individual hwthreads, then
729+
* we need to treat those hwthreads as separate cpus
730+
*/
731+
opal_hwloc_use_hwthreads_as_cpus = true;
732+
} else if (0 == strncasecmp(spec, "dist", len)) {
733+
if (NULL != rmaps_dist_device) {
734+
if (NULL != (pch = strchr(rmaps_dist_device, ':'))) {
735+
*pch = '\0';
736+
}
737+
if (NULL != device) {
738+
*device = strdup(rmaps_dist_device);
744739
}
740+
ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYDIST);
745741
} else {
746-
orte_show_help("help-orte-rmaps-base.txt", "unrecognized-policy", true, "mapping", spec);
742+
orte_show_help("help-orte-rmaps-base.txt", "device-not-specified", true);
747743
free(spec);
748744
return ORTE_ERR_SILENT;
749745
}
746+
} else {
747+
orte_show_help("help-orte-rmaps-base.txt", "unrecognized-policy", true, "mapping", spec);
750748
free(spec);
751-
ORTE_SET_MAPPING_DIRECTIVE(tmp, ORTE_MAPPING_GIVEN);
749+
return ORTE_ERR_SILENT;
752750
}
751+
free(spec);
752+
ORTE_SET_MAPPING_DIRECTIVE(tmp, ORTE_MAPPING_GIVEN);
753753

754754
setpolicy:
755755
if (NULL == jdata || NULL == jdata->map) {

0 commit comments

Comments
 (0)