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