root/ompi/mpi/tool/finalize.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPI_T_finalize

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
   4  *                         reserved.
   5  * Copyright (c) 2014-2018 Cisco Systems, Inc.  All rights reserved
   6  * Copyright (c) 2017      IBM Corporation. All rights reserved.
   7  * $COPYRIGHT$
   8  *
   9  * Additional copyrights may follow
  10  *
  11  * $HEADER$
  12  */
  13 
  14 
  15 #include "ompi/mpi/tool/mpit-internal.h"
  16 
  17 #include "ompi/runtime/ompi_info_support.h"
  18 #include "opal/include/opal/sys/atomic.h"
  19 #include "opal/runtime/opal.h"
  20 
  21 #if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES
  22 #pragma weak MPI_T_finalize = PMPI_T_finalize
  23 #endif
  24 
  25 #if OMPI_PROFILING_DEFINES
  26 #include "ompi/mpi/tool/profile/defines.h"
  27 #endif
  28 
  29 
  30 int MPI_T_finalize (void)
  31 {
  32     ompi_mpit_lock ();
  33 
  34     if (!mpit_is_initialized ()) {
  35         ompi_mpit_unlock ();
  36         return MPI_T_ERR_NOT_INITIALIZED;
  37     }
  38 
  39     if (0 == --ompi_mpit_init_count) {
  40         (void) ompi_info_close_components ();
  41 
  42         int32_t state = ompi_mpi_state;
  43         if ((state < OMPI_MPI_STATE_INIT_COMPLETED ||
  44              state >= OMPI_MPI_STATE_FINALIZE_PAST_COMM_SELF_DESTRUCT) &&
  45             (NULL != ompi_mpi_main_thread)) {
  46             /* we are not between MPI_Init and MPI_Finalize so we
  47              * have to free the ompi_mpi_main_thread */
  48             OBJ_RELEASE(ompi_mpi_main_thread);
  49             ompi_mpi_main_thread = NULL;
  50         }
  51 
  52         (void) opal_finalize_util ();
  53     }
  54 
  55     ompi_mpit_unlock ();
  56 
  57     return MPI_SUCCESS;
  58 }

/* [<][>][^][v][top][bottom][index][help] */