1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2004-2010 The Trustees of Indiana University.
4  *                         All rights reserved.
5  * Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
6  *                         All rights reserved.
7  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
8  *                         University of Stuttgart.  All rights reserved.
9  * Copyright (c) 2004-2005 The Regents of the University of California.
10  *                         All rights reserved.
11  * Copyright (c) 2007      Evergrid, Inc. All rights reserved.
12  * Copyright (c) 2015      Los Alamos National Security, LLC. All rights
13  *                         reserved.
14  *
15  * $COPYRIGHT$
16  *
17  * Additional copyrights may follow
18  *
19  * $HEADER$
20  */
21 
22 #include "opal_config.h"
23 
24 #ifdef HAVE_UNISTD_H
25 #include "unistd.h"
26 #endif
27 
28 #include "opal/constants.h"
29 #include "opal/util/output.h"
30 #include "opal/mca/mca.h"
31 #include "opal/mca/base/base.h"
32 #include "opal/mca/crs/crs.h"
33 #include "opal/mca/crs/base/base.h"
34 
35 bool opal_crs_base_do_not_select = false;
36 
opal_crs_base_select(void)37 int opal_crs_base_select(void)
38 {
39     opal_crs_base_component_t *best_component = NULL;
40     opal_crs_base_module_t *best_module = NULL;
41     int ret;
42 
43     if( !opal_cr_is_enabled ) {
44         opal_output_verbose(10, opal_crs_base_framework.framework_output,
45                             "crs:select: FT is not enabled, skipping!");
46         return OPAL_SUCCESS;
47     }
48 
49     if( opal_crs_base_do_not_select ) {
50 	opal_output_verbose(10, opal_crs_base_framework.framework_output,
51                             "crs:select: Not selecting at this time!");
52         return OPAL_SUCCESS;
53     }
54 
55     /*
56      * Select the best component
57      */
58     if( OPAL_SUCCESS != mca_base_select("crs", opal_crs_base_framework.framework_output,
59                                         &opal_crs_base_framework.framework_components,
60                                         (mca_base_module_t **) &best_module,
61                                         (mca_base_component_t **) &best_component, NULL) ) {
62         /* This will only happen if no component was selected */
63         return OPAL_ERROR;
64     }
65 
66     /* best_module and best_component should not be NULL here */
67 
68     /* Save the winner */
69     opal_crs_base_selected_component = *best_component;
70     opal_crs = *best_module;
71 
72     /* Initialize the winner */
73     if (OPAL_SUCCESS != (ret = opal_crs.crs_init()) ) {
74         return ret;
75     }
76 
77     return OPAL_SUCCESS;
78 }
79