int orte_rmaps_base_set_mapping_policy(orte_mapping_policy_t *policy, char **device, char *inspec) { char *ck; #if OPAL_HAVE_HWLOC char *ptr; #endif orte_mapping_policy_t tmp; int rc; size_t len; char *spec; /* set defaults */ tmp = 0; *device = NULL; if (NULL == inspec) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYSOCKET); } else { spec = strdup(inspec); // protect the input string /* see if a colon was included - if so, then we have a policy + modifier */ ck = strchr(spec, ':'); if (NULL != ck) { /* split the string */ *ck = '\0'; ck++; /* if the policy is "dist", then we set the policy to that value * and save the second argument as the device */ #if OPAL_HAVE_HWLOC if (0 == strncasecmp(spec, "dist", strlen(spec))) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYDIST); /* the first argument after the colon *must* be the * device we are mapping near - however, other modifiers * could have been provided, so check for them, okay if * none found */ if (NULL != (ptr = strchr(ck, ','))) { *ptr = '\0'; ptr++; // move past the comma /* check the remaining string for modifiers - may be none, so * don't emit an error message if the modifier isn't recognized */ if (ORTE_ERR_SILENT == (rc = check_modifiers(ptr, &tmp)) && ORTE_ERR_BAD_PARAM != rc) { free(spec); return ORTE_ERR_SILENT; } } *device = strdup(ck); ORTE_SET_MAPPING_DIRECTIVE(tmp, ORTE_MAPPING_GIVEN); free(spec); goto setpolicy; } else if (0 == strncasecmp(spec, "ppr", strlen(spec))) { /* we have to allow additional modifiers here - e.g., specifying * #pe's/proc or oversubscribe - so check for modifiers */ if (NULL == (ptr = strrchr(ck, ':'))) { /* this is an error - there had to be at least one * colon to delimit the number from the object type */ orte_show_help("help-orte-rmaps-base.txt", "invalid-pattern", true, inspec); free(spec); return ORTE_ERR_SILENT; } ptr++; // move past the colon /* check the remaining string for modifiers - may be none, so * don't emit an error message if the modifier isn't recognized */ if (ORTE_ERR_SILENT == (rc = check_modifiers(ptr, &tmp)) && ORTE_ERR_BAD_PARAM != rc) { free(spec); return ORTE_ERR_SILENT; } /* if we found something, then we need to adjust the string */ if (ORTE_SUCCESS == rc) { ptr--; *ptr = '\0'; } /* now get the pattern */ orte_rmaps_base.ppr = strdup(ck); ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_PPR); ORTE_SET_MAPPING_DIRECTIVE(tmp, ORTE_MAPPING_GIVEN); free(spec); goto setpolicy; } #endif if (ORTE_SUCCESS != (rc = check_modifiers(ck, &tmp)) && ORTE_ERR_TAKE_NEXT_OPTION != rc) { if (ORTE_ERR_BAD_PARAM == rc) { orte_show_help("help-orte-rmaps-base.txt", "unrecognized-modifier", true, inspec); } free(spec); return rc; } } len = strlen(spec); if (0 == strncasecmp(spec, "slot", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYSLOT); } else if (0 == strncasecmp(spec, "node", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYNODE); } else if (0 == strncasecmp(spec, "seq", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_SEQ); #if OPAL_HAVE_HWLOC } else if (0 == strncasecmp(spec, "core", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYCORE); } else if (0 == strncasecmp(spec, "l1cache", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYL1CACHE); } else if (0 == strncasecmp(spec, "l2cache", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYL2CACHE); } else if (0 == strncasecmp(spec, "l3cache", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYL3CACHE); } else if (0 == strncasecmp(spec, "socket", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYSOCKET); } else if (0 == strncasecmp(spec, "numa", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYNUMA); } else if (0 == strncasecmp(spec, "board", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYBOARD); } else if (0 == strncasecmp(spec, "hwthread", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYHWTHREAD); /* if we are mapping processes to individual hwthreads, then * we need to treat those hwthreads as separate cpus */ opal_hwloc_use_hwthreads_as_cpus = true; #endif } else { orte_show_help("help-orte-rmaps-base.txt", "unrecognized-policy", true, "mapping", spec); free(spec); return ORTE_ERR_SILENT; } free(spec); ORTE_SET_MAPPING_DIRECTIVE(tmp, ORTE_MAPPING_GIVEN); } #if OPAL_HAVE_HWLOC setpolicy: #endif *policy = tmp; return ORTE_SUCCESS; }
int orte_rmaps_base_set_mapping_policy(orte_mapping_policy_t *policy, char **device, char *inspec) { char *ck; char *ptr; orte_mapping_policy_t tmp; int rc; size_t len; char *spec; char *pch; /* set defaults */ tmp = 0; if (NULL != device) { *device = NULL; } opal_output_verbose(5, orte_rmaps_base_framework.framework_output, "%s rmaps:base set policy with %s device %s", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), (NULL == inspec) ? "NULL" : inspec, (NULL == device) ? "NULL" : "NONNULL"); if (NULL == inspec) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYSOCKET); } else { spec = strdup(inspec); // protect the input string /* see if a colon was included - if so, then we have a policy + modifier */ ck = strchr(spec, ':'); if (NULL != ck) { /* if the colon is the first character of the string, then we * just have modifiers on the default mapping policy */ if (ck == spec) { ck++; opal_output_verbose(5, orte_rmaps_base_framework.framework_output, "%s rmaps:base only modifiers %s provided - assuming bysocket mapping", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), ck); ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYSOCKET); if (ORTE_ERR_SILENT == (rc = check_modifiers(ck, &tmp)) && ORTE_ERR_BAD_PARAM != rc) { free(spec); return ORTE_ERR_SILENT; } free(spec); goto setpolicy; } /* split the string */ *ck = '\0'; ck++; opal_output_verbose(5, orte_rmaps_base_framework.framework_output, "%s rmaps:base policy %s modifiers %s provided", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), spec, ck); /* if the policy is "dist", then we set the policy to that value * and save the second argument as the device */ if (0 == strncasecmp(spec, "ppr", strlen(spec))) { /* we have to allow additional modifiers here - e.g., specifying * #pe's/proc or oversubscribe - so check for modifiers */ if (NULL == (ptr = strrchr(ck, ':'))) { /* this is an error - there had to be at least one * colon to delimit the number from the object type */ orte_show_help("help-orte-rmaps-base.txt", "invalid-pattern", true, inspec); free(spec); return ORTE_ERR_SILENT; } ptr++; // move past the colon /* check the remaining string for modifiers - may be none, so * don't emit an error message if the modifier isn't recognized */ if (ORTE_ERR_SILENT == (rc = check_modifiers(ptr, &tmp)) && ORTE_ERR_BAD_PARAM != rc) { free(spec); return ORTE_ERR_SILENT; } /* if we found something, then we need to adjust the string */ if (ORTE_SUCCESS == rc) { ptr--; *ptr = '\0'; } /* now get the pattern */ orte_rmaps_base.ppr = strdup(ck); ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_PPR); ORTE_SET_MAPPING_DIRECTIVE(tmp, ORTE_MAPPING_GIVEN); free(spec); goto setpolicy; } if (ORTE_SUCCESS != (rc = check_modifiers(ck, &tmp)) && ORTE_ERR_TAKE_NEXT_OPTION != rc) { if (ORTE_ERR_BAD_PARAM == rc) { orte_show_help("help-orte-rmaps-base.txt", "unrecognized-modifier", true, inspec); } free(spec); return rc; } } len = strlen(spec); if (0 == strncasecmp(spec, "slot", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYSLOT); } else if (0 == strncasecmp(spec, "node", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYNODE); } else if (0 == strncasecmp(spec, "seq", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_SEQ); } else if (0 == strncasecmp(spec, "core", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYCORE); } else if (0 == strncasecmp(spec, "l1cache", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYL1CACHE); } else if (0 == strncasecmp(spec, "l2cache", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYL2CACHE); } else if (0 == strncasecmp(spec, "l3cache", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYL3CACHE); } else if (0 == strncasecmp(spec, "socket", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYSOCKET); } else if (0 == strncasecmp(spec, "numa", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYNUMA); } else if (0 == strncasecmp(spec, "board", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYBOARD); } else if (0 == strncasecmp(spec, "hwthread", len)) { ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYHWTHREAD); /* if we are mapping processes to individual hwthreads, then * we need to treat those hwthreads as separate cpus */ opal_hwloc_use_hwthreads_as_cpus = true; } else if (0 == strncasecmp(spec, "dist", len)) { if (NULL != rmaps_dist_device) { if (NULL != (pch = strchr(rmaps_dist_device, ':'))) { *pch = '\0'; } if (NULL != device) { *device = strdup(rmaps_dist_device); } ORTE_SET_MAPPING_POLICY(tmp, ORTE_MAPPING_BYDIST); } else { orte_show_help("help-orte-rmaps-base.txt", "device-not-specified", true); free(spec); return ORTE_ERR_SILENT; } } else { orte_show_help("help-orte-rmaps-base.txt", "unrecognized-policy", true, "mapping", spec); free(spec); return ORTE_ERR_SILENT; } free(spec); ORTE_SET_MAPPING_DIRECTIVE(tmp, ORTE_MAPPING_GIVEN); } setpolicy: *policy = tmp; return ORTE_SUCCESS; }
int main() { check_modifiers(); check_fonts(); check_colors(); }