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) 2008 Sun Microsystems, Inc. All rights reserved.
13 * $COPYRIGHT$
14 *
15 * Additional copyrights may follow
16 *
17 * $HEADER$
18 */
19
20 #include "ompi_config.h"
21
22 #include <stdio.h>
23 #include <stdlib.h>
24
25 #include "mpi.h"
26 #include "ompi/constants.h"
27 #include "opal/util/output.h"
28 #include "ompi/mca/mca.h"
29 #include "opal/mca/base/base.h"
30 #include "ompi/mca/io/io.h"
31 #include "ompi/mca/io/base/base.h"
32 #include "ompi/mca/io/base/io_base_request.h"
33
34
35
36 /*
37 * Private functions
38 */
39 static int init_query(const mca_base_component_t *ls,
40 bool enable_progress_threads,
41 bool enable_mpi_threads);
42 static int init_query_2_0_0(const mca_base_component_t *ls,
43 bool enable_progress_threads,
44 bool enable_mpi_threads);
45
46 /*
47 * Scan down the list of successfully opened components and query each of
48 * them (the opened list will be one or more components. If the user
49 * requested a specific component, it will be the only component in the
50 * opened list). Create and populate the available list of all
51 * components who indicate that they want to be considered for selection.
52 * Close all components who do not want to be considered for selection,
53 * and destroy the opened list.
54 *
55 * It is *not* an error if there are no io components available.
56 * Appropriate run-time MPI exceptions will be invoked during
57 * MPI_FILE_OPEN and MPI_FILE_DELETE.
58 */
59 int mca_io_base_find_available(bool enable_progress_threads,
60 bool enable_mpi_threads)
61 {
62 mca_base_component_list_item_t *cli, *next;
63
64 /* The list of components that we should check has already been
65 established in mca_io_base_open. */
66
67 OPAL_LIST_FOREACH_SAFE(cli, next, &ompi_io_base_framework.framework_components, mca_base_component_list_item_t) {
68 const mca_base_component_t *component = cli->cli_component;
69
70 /* Call a subroutine to do the work, because the component may
71 represent different versions of the io MCA. */
72
73 if (OMPI_SUCCESS != init_query(component,
74 enable_progress_threads,
75 enable_mpi_threads)) {
76
77 /* If the component doesn't want to run, then close it.
78 It's already had its close() method invoked; now close
79 it out of the DSO repository (if it's there). */
80 opal_list_remove_item(&ompi_io_base_framework.framework_components, &cli->super);
81 mca_base_component_close(component, ompi_io_base_framework.framework_output);
82 OBJ_RELEASE(cli);
83 }
84 }
85
86 /* All done */
87
88 return OMPI_SUCCESS;
89 }
90
91
92 /*
93 * Query a component, see if it wants to run at all. If it does, save
94 * some information. If it doesn't, close it.
95 */
96 static int init_query(const mca_base_component_t *m,
97 bool enable_progress_threads,
98 bool enable_mpi_threads)
99 {
100 int ret;
101
102 opal_output_verbose(10, ompi_io_base_framework.framework_output,
103 "io:find_available: querying io component %s",
104 m->mca_component_name);
105
106 /* This component has already been successfully opened. So now
107 query it. */
108
109 if (2 == m->mca_type_major_version &&
110 0 == m->mca_type_minor_version &&
111 0 == m->mca_type_release_version) {
112 ret = init_query_2_0_0(m, enable_progress_threads,
113 enable_mpi_threads);
114 } else {
115 /* Unrecognized io API version */
116
117 opal_output_verbose(10, ompi_io_base_framework.framework_output,
118 "io:find_available: unrecognized io API version (%d.%d.%d)",
119 m->mca_type_major_version,
120 m->mca_type_minor_version,
121 m->mca_type_release_version);
122 /* JMS show_help */
123 return OMPI_ERROR;
124 }
125
126 /* Query done -- look at the return value to see what happened */
127
128 if (OMPI_SUCCESS != ret) {
129 opal_output_verbose(10, ompi_io_base_framework.framework_output,
130 "io:find_available: io component %s is not available",
131 m->mca_component_name);
132 } else {
133 opal_output_verbose(10, ompi_io_base_framework.framework_output,
134 "io:find_available: io component %s is available",
135 m->mca_component_name);
136 }
137
138 /* All done */
139
140 return ret;
141 }
142
143
144 /*
145 * Query a specific component, io v2.0.0
146 */
147 static int init_query_2_0_0(const mca_base_component_t *component,
148 bool enable_progress_threads,
149 bool enable_mpi_threads)
150 {
151 mca_io_base_component_2_0_0_t *io =
152 (mca_io_base_component_2_0_0_t *) component;
153
154 return io->io_init_query(enable_progress_threads,
155 enable_mpi_threads);
156 }