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