File: atomic_base_available.c

package info (click to toggle)
openmpi 5.0.8-3
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 201,692 kB
  • sloc: ansic: 613,078; makefile: 42,353; sh: 11,194; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,179; python: 1,859; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (137 lines) | stat: -rw-r--r-- 4,699 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
 * Copyright (c) 2013      Mellanox Technologies, Inc.
 *                         All rights reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "oshmem_config.h"

#include "opal/class/opal_list.h"
#include "oshmem/mca/mca.h"
#include "opal/mca/base/base.h"
#include "opal/mca/base/mca_base_component_repository.h"

#include "oshmem/constants.h"
#include "oshmem/util/oshmem_util.h"
#include "oshmem/mca/atomic/atomic.h"
#include "oshmem/mca/atomic/base/base.h"

/*
 * Private functions
 */
static int init_query(const mca_base_component_t * ls,
                      bool enable_progress_threads,
                      bool enable_threads);

/*
 * Scan down the list of successfully opened components and query each of
 * them (the opened list will be one or more components.  If the user
 * requested a specific component, it will be the only component in the
 * opened list).  Create and populate the available list of all
 * components who indicate that they want to be considered for selection.
 * Close all components who do not want to be considered for selection,
 * and destroy the opened list.
 *
 * Also find the basic component while we're doing all of this, and save
 * it in a global variable so that we can find it easily later (e.g.,
 * during scope selection).
 */
int mca_atomic_base_find_available(bool enable_progress_threads,
                                   bool enable_threads)
{
    mca_base_component_list_item_t *cli, *next;
    const mca_base_component_t *component;

    OPAL_LIST_FOREACH_SAFE(cli, next, &oshmem_atomic_base_framework.framework_components, mca_base_component_list_item_t) {
        component = cli->cli_component;

        /* Call a subroutine to do the work, because the component may
           represent different versions of the coll MCA. */

        if (OSHMEM_SUCCESS != init_query(component, enable_progress_threads,
                                       enable_threads)) {
            /* If the component doesn't want to run, then close it.
               Now close it out and release it from the DSO repository (if it's there). */
            opal_list_remove_item(&oshmem_atomic_base_framework.framework_components, &cli->super);
            mca_base_component_close(component, oshmem_atomic_base_framework.framework_output);
            OBJ_RELEASE(cli);
        }
    }

    /* If we have no collective components available, it's an error.
       Thanks for playing! */

    if (opal_list_get_size(&oshmem_atomic_base_framework.framework_components) == 0) {
        ATOMIC_VERBOSE(10,
                      "atomic:find_available: no components available!");
        return OSHMEM_ERROR;
    }

    /* All done */

    return mca_atomic_base_select();
}

/*
 * Query a component, see if it wants to run at all.  If it does, save
 * some information.  If it doesn't, close it.
 */
static int init_query(const mca_base_component_t * component,
                      bool enable_progress_threads,
                      bool enable_threads)
{
    int ret;

    ATOMIC_VERBOSE(10,
                   "atomic:find_available: querying atomic component %s",
                   component->mca_component_name);

    /* This component has already been successfully opened.  So now
     query it. */

    if (1 == component->mca_type_major_version
            && 0 == component->mca_type_minor_version
            && 0 == component->mca_type_release_version) {

        mca_atomic_base_component_t *atomic =
                (mca_atomic_base_component_t *) component;

        ret = atomic->atomic_startup(enable_progress_threads, enable_threads);
    } else {
        /* Unrecognized coll API version */

        ATOMIC_VERBOSE(10,
                       "atomic:find_available: unrecognized atomic API version (%d.%d.%d, ignored)",
                      component->mca_type_major_version,
                      component->mca_type_minor_version,
                      component->mca_type_release_version);
        return OSHMEM_ERROR;
    }

    /* Query done -- look at the return value to see what happened */

    if (OSHMEM_SUCCESS != ret) {
        ATOMIC_VERBOSE(10,
                       "atomic:find_available: atomic component %s is not available",
                       component->mca_component_name);
        if (NULL != component->mca_close_component) {
            component->mca_close_component();
        }
    } else {
        ATOMIC_VERBOSE(10,
                       "atomic:find_available: atomic component %s is available",
                       component->mca_component_name);
    }

    /* All done */

    return ret;
}