File: opal_finalize.c

package info (click to toggle)
openmpi 3.1.3-11
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 118,572 kB
  • sloc: ansic: 628,972; f90: 17,993; makefile: 13,761; sh: 7,051; java: 6,360; perl: 3,215; cpp: 2,225; python: 1,350; lex: 988; fortran: 52; tcl: 12
file content (197 lines) | stat: -rw-r--r-- 5,678 bytes parent folder | download | duplicates (3)
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
 * Copyright (c) 2004-2010 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-2005 The Regents of the University of California.
 *                         All rights reserved.
 * Copyright (c) 2008-2015 Cisco Systems, Inc.  All rights reserved.
 * Copyright (c) 2010-2015 Los Alamos National Security, LLC.
 *                         All rights reserved.
 * Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
 * Copyright (c) 2016-2017 Research Organization for Information Science
 *                         and Technology (RIST). All rights reserved.
 * Copyright (c) 2017      Amazon.com, Inc. or its affiliates.
 *                         All Rights reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

/** @file **/

#include "opal_config.h"

#include "opal/class/opal_object.h"
#include "opal/dss/dss.h"
#include "opal/util/output.h"
#include "opal/util/malloc.h"
#include "opal/util/net.h"
#include "opal/util/proc.h"
#include "opal/util/keyval_parse.h"
#include "opal/util/show_help.h"
#include "opal/memoryhooks/memory.h"
#include "opal/mca/base/base.h"
#include "opal/runtime/opal.h"
#include "opal/constants.h"
#include "opal/datatype/opal_datatype.h"
#include "opal/mca/if/base/base.h"
#include "opal/mca/installdirs/base/base.h"
#include "opal/mca/memchecker/base/base.h"
#include "opal/mca/memcpy/base/base.h"
#include "opal/mca/backtrace/base/base.h"
#include "opal/mca/reachable/base/base.h"
#include "opal/mca/timer/base/base.h"
#include "opal/mca/hwloc/base/base.h"
#include "opal/mca/event/base/base.h"
#include "opal/runtime/opal_progress.h"
#include "opal/mca/shmem/base/base.h"
#if OPAL_ENABLE_FT_CR    == 1
#include "opal/mca/compress/base/base.h"
#endif

#include "opal/runtime/opal_cr.h"
#include "opal/mca/crs/base/base.h"
#include "opal/threads/tsd.h"

extern int opal_initialized;
extern int opal_util_initialized;
extern bool opal_init_called;

int
opal_finalize_util(void)
{
    if( --opal_util_initialized != 0 ) {
        if( opal_util_initialized < 0 ) {
            return OPAL_ERROR;
        }
        return OPAL_SUCCESS;
    }

    /* close interfaces code. */
    (void) mca_base_framework_close(&opal_if_base_framework);

    (void) mca_base_framework_close(&opal_event_base_framework);

    /* Clear out all the registered MCA params */
    opal_deregister_params();
    mca_base_var_finalize();

    opal_net_finalize();

    /* keyval lex-based parser */
    opal_util_keyval_parse_finalize();

    (void) mca_base_framework_close(&opal_installdirs_base_framework);

    mca_base_close();

    /* finalize the memory allocator */
    opal_malloc_finalize();

    /* finalize the show_help system */
    opal_show_help_finalize();

    /* finalize the output system.  This has to come *after* the
       malloc code, as the malloc code needs to call into this, but
       the malloc code turning off doesn't affect opal_output that
       much */
    opal_output_finalize();

    /* close the dss */
    opal_dss_close();

    opal_datatype_finalize();

    /* finalize the class/object system */
    opal_class_finalize();

    free (opal_process_info.nodename);
    opal_process_info.nodename = NULL;

    return OPAL_SUCCESS;
}


int
opal_finalize(void)
{
    if( --opal_initialized != 0 ) {
        if( opal_initialized < 0 ) {
            return OPAL_ERROR;
        }
        return OPAL_SUCCESS;
    }

    opal_progress_finalize();

    /* close the checkpoint and restart service */
    opal_cr_finalize();

#if OPAL_ENABLE_FT_CR    == 1
    (void) mca_base_framework_close(&opal_compress_base_framework);
#endif

    (void) mca_base_framework_close(&opal_reachable_base_framework);

    (void) mca_base_framework_close(&opal_event_base_framework);

    /* close high resolution timers */
    (void) mca_base_framework_close(&opal_timer_base_framework);

    (void) mca_base_framework_close(&opal_backtrace_base_framework);
    (void) mca_base_framework_close(&opal_memchecker_base_framework);

    /* close the memcpy framework */
    (void) mca_base_framework_close(&opal_memcpy_base_framework);

    /* finalize the memory manager / tracker */
    opal_mem_hooks_finalize();

    /* close the hwloc framework */
    (void) mca_base_framework_close(&opal_hwloc_base_framework);

    /* close the shmem framework */
    (void) mca_base_framework_close(&opal_shmem_base_framework);

    /* cleanup the main thread specific stuff */
    opal_tsd_keys_destruct();

    /* finalize util code */
    opal_finalize_util();

    return OPAL_SUCCESS;
}


void opal_finalize_test(void)
{
    /* Clear out all the registered MCA params */
    mca_base_var_finalize();

    (void) mca_base_framework_close(&opal_installdirs_base_framework);

    /* finalize the mca */
    mca_base_close();

    /* finalize the show_help system */
    opal_show_help_finalize();

    /* finalize the output system.  This has to come *after* the
       malloc code, as the malloc code needs to call into this, but
       the malloc code turning off doesn't affect opal_output that
       much */
    opal_output_finalize();

    /* close the dss */
    opal_dss_close();

    /* finalize the class/object system */
    opal_class_finalize();
}