File: mca_base_components_close.c

package info (click to toggle)
openmpi 5.0.8-4
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 201,684 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 (97 lines) | stat: -rw-r--r-- 3,564 bytes parent folder | download | duplicates (5)
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
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
 *                         University Research and Technology
 *                         Corporation.  All rights reserved.
 * Copyright (c) 2004-2006 The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * Copyright (c) 2004-2006 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) 2013-2015 Los Alamos National Security, LLC. All rights
 *                         reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#include "opal_config.h"

#include "opal/class/opal_list.h"
#include "opal/constants.h"
#include "opal/mca/base/base.h"
#include "opal/mca/base/mca_base_component_repository.h"
#include "opal/mca/mca.h"
#include "opal/util/output.h"

void mca_base_component_unload(const mca_base_component_t *component, int output_id)
{
    int ret;

    /* Unload */
    opal_output_verbose(MCA_BASE_VERBOSE_COMPONENT, output_id,
                        "mca: base: close: unloading component %s", component->mca_component_name);

    ret = mca_base_var_group_find(component->mca_project_name, component->mca_type_name,
                                  component->mca_component_name);
    if (0 <= ret) {
        mca_base_var_group_deregister(ret);
    }

    mca_base_component_repository_release(component);
}

void mca_base_component_close(const mca_base_component_t *component, int output_id)
{
    /* Close */
    if (NULL != component->mca_close_component) {
        if (OPAL_SUCCESS == component->mca_close_component()) {
            opal_output_verbose(MCA_BASE_VERBOSE_COMPONENT, output_id,
                                "mca: base: close: component %s closed",
                                component->mca_component_name);
        } else {
            opal_output_verbose(MCA_BASE_VERBOSE_COMPONENT, output_id,
                                "mca: base: close: component %s refused to close [drop it]",
                                component->mca_component_name);
            return;
        }
    }

    mca_base_component_unload(component, output_id);
}

int mca_base_framework_components_close(mca_base_framework_t *framework,
                                        const mca_base_component_t *skip)
{
    return mca_base_components_close(framework->framework_output, &framework->framework_components,
                                     skip);
}

int mca_base_components_close(int output_id, opal_list_t *components,
                              const mca_base_component_t *skip)
{
    mca_base_component_list_item_t *cli, *next;

    /* Close and unload all components in the available list, except the
       "skip" item.  This is handy to close out all non-selected
       components.  It's easier to simply remove the entire list and
       then simply re-add the skip entry when done. */

    OPAL_LIST_FOREACH_SAFE (cli, next, components, mca_base_component_list_item_t) {
        if (skip == cli->cli_component) {
            continue;
        }

        mca_base_component_close(cli->cli_component, output_id);
        opal_list_remove_item(components, &cli->super);

        OBJ_RELEASE(cli);
    }

    /* All done */
    return OPAL_SUCCESS;
}