File: mtl_base_frame.c

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 202,312 kB
  • sloc: ansic: 612,441; makefile: 42,495; sh: 11,230; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,154; python: 1,856; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (119 lines) | stat: -rw-r--r-- 4,504 bytes parent folder | download | duplicates (2)
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
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
 *                         University Research and Technology
 *                         Corporation.  All rights reserved.
 * Copyright (c) 2004-2005 The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
 *                         University of Stuttgart.  All rights reserved.
 * Copyright (c) 2004-2006 The Regents of the University of California.
 *                         All rights reserved.
 * Copyright (c) 2015-2018 Los Alamos National Security, LLC.  All rights
 *                         reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#include "ompi_config.h"

#include "ompi/mca/mca.h"
#include "opal/util/output.h"
#include "opal/mca/base/base.h"


#include "ompi/constants.h"
#include "ompi/mca/mtl/mtl.h"
#include "ompi/mca/mtl/base/base.h"

/*
 * The following file was created by configure.  It contains extern
 * statements and the definition of an array of pointers to each
 * component's public mca_base_component_t struct.
 */

#include "ompi/mca/mtl/base/static-components.h"

mca_mtl_base_component_t *ompi_mtl_base_selected_component = NULL;
mca_mtl_base_module_t *ompi_mtl = NULL;

/*
 * Function for selecting one component from all those that are
 * available.
 *
 * For now, we take the first component that says it can run.  Might
 * need to reexamine this at a later time.
 */
int
ompi_mtl_base_select (bool enable_progress_threads,
                      bool enable_mpi_threads,
                      int *priority)
{
    int ret = OMPI_ERR_NOT_FOUND;
    mca_mtl_base_component_t *best_component = NULL;
    mca_mtl_base_module_t *best_module = NULL;
    int best_priority;

    /*
     * Select the best component
     */
    if( OPAL_SUCCESS != mca_base_select("mtl", ompi_mtl_base_framework.framework_output,
                                        &ompi_mtl_base_framework.framework_components,
                                        (mca_base_module_t **) &best_module,
                                        (mca_base_component_t **) &best_component,
                                        &best_priority) ) {
        /* notify caller that no available component found */
        return ret;
    }

    opal_output_verbose( 10, ompi_mtl_base_framework.framework_output,
                         "select: initializing %s component %s",
                         best_component->mtl_version.mca_type_name,
                         best_component->mtl_version.mca_component_name );

    if (NULL == best_component->mtl_init(enable_progress_threads,
                                          enable_mpi_threads, &best_component->accelerator_support)) {
        opal_output_verbose( 10, ompi_mtl_base_framework.framework_output,
                             "select: init returned failure for component %s",
                             best_component->mtl_version.mca_component_name );
    } else {
        opal_output_verbose( 10, ompi_mtl_base_framework.framework_output,
                             "select: init returned success");
        ompi_mtl_base_selected_component = best_component;
        ompi_mtl = best_module;
        *priority = best_priority;
        ret = OMPI_SUCCESS;
    }

    /* All done */
    if (NULL == ompi_mtl) {
        opal_output_verbose( 10, ompi_mtl_base_framework.framework_output,
                             "select: no component selected");
    } else {
        opal_output_verbose( 10, ompi_mtl_base_framework.framework_output,
                             "select: component %s selected",
                             ompi_mtl_base_selected_component->
                             mtl_version.mca_component_name );
    }
    return ret;
}


static int
ompi_mtl_base_close(void)
{
    /* NTH: Should we be freeing the mtl module here? */
    ompi_mtl = NULL;
    ompi_mtl_base_selected_component = NULL;

    /* Close all remaining available modules (may be one if this is a
       OMPI RTE program, or [possibly] multiple if this is ompi_info) */
    return mca_base_framework_components_close(&ompi_mtl_base_framework, NULL);
}

MCA_BASE_FRAMEWORK_DECLARE(ompi, mtl, NULL, NULL, NULL, ompi_mtl_base_close,
                           mca_mtl_base_static_components, 0);