1 /*
2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2005 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
13 * Copyright (c) 2011-2012 Los Alamos National Security, LLC.
14 * All rights reserved.
15 * Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
16 * Copyright (c) 2016 Research Organization for Information Science
17 * and Technology (RIST). All rights reserved.
18 * $COPYRIGHT$
19 *
20 * Additional copyrights may follow
21 *
22 * $HEADER$
23 */
24
25 #include "orte_config.h"
26 #include "orte/constants.h"
27
28 #include <string.h>
29
30 #include "orte/mca/mca.h"
31 #include "opal/util/output.h"
32 #include "opal/mca/base/base.h"
33
34 #include "orte/runtime/orte_globals.h"
35 #include "orte/util/show_help.h"
36 #include "orte/mca/errmgr/errmgr.h"
37
38 #include "orte/mca/rmaps/base/base.h"
39 #include "orte/mca/rmaps/base/rmaps_private.h"
40
41
42 int orte_rmaps_base_assign_locations(orte_job_t *jdata)
43 {
44 int rc;
45 orte_rmaps_base_selected_module_t *mod;
46
47 opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
48 "mca:rmaps: assigning locations for job %s",
49 ORTE_JOBID_PRINT(jdata->jobid));
50
51 /* cycle thru the available mappers until one agrees to assign
52 * locations for the job
53 */
54 if (1 == opal_list_get_size(&orte_rmaps_base.selected_modules)) {
55 /* forced selection */
56 mod = (orte_rmaps_base_selected_module_t*)opal_list_get_first(&orte_rmaps_base.selected_modules);
57 jdata->map->req_mapper = strdup(mod->component->mca_component_name);
58 }
59 OPAL_LIST_FOREACH(mod, &orte_rmaps_base.selected_modules, orte_rmaps_base_selected_module_t) {
60 if (NULL == mod->module->assign_locations) {
61 continue;
62 }
63 if (ORTE_SUCCESS == (rc = mod->module->assign_locations(jdata))) {
64 return rc;
65 }
66 /* mappers return "next option" if they didn't attempt to
67 * process the job. anything else is a true error.
68 */
69 if (ORTE_ERR_TAKE_NEXT_OPTION != rc) {
70 ORTE_ERROR_LOG(rc);
71 return rc;
72 }
73 }
74
75 /* if we get here without doing the assignments, then that's an error */
76 orte_show_help("help-orte-rmaps-base.txt", "failed-assignments", true,
77 orte_process_info.nodename,
78 orte_rmaps_base_print_mapping(jdata->map->mapping));
79 return ORTE_ERROR;
80 }