"Fossies" - the Fresh Open Source Software Archive

Member "openmpi-3.1.6/ompi/mca/io/romio314/romio/adio/common/ad_close.c" (18 Mar 2020, 4030 Bytes) of package /linux/misc/openmpi-3.1.6.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ad_close.c" see the Fossies "Dox" file reference documentation.

    1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
    2 /*
    3  *
    4  *   Copyright (C) 1997 University of Chicago.
    5  *   See COPYRIGHT notice in top-level directory.
    6  */
    7 
    8 #include "adio.h"
    9 #include "adio_extern.h"
   10 
   11 #ifdef HAVE_UNISTD_H
   12 #include <unistd.h>
   13 #endif
   14 
   15 void ADIO_Close(ADIO_File fd, int *error_code)
   16 {
   17     int i, j, k, combiner, myrank, err, is_contig;
   18     static char myname[] = "ADIO_CLOSE";
   19 
   20     if (fd->async_count) {
   21     *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
   22                        myname, __LINE__, MPI_ERR_IO, "**io",
   23                        "**io %s", strerror(errno));
   24     return;
   25     }
   26 
   27     /* because of deferred open, this warants a bit of explaining.  First, if
   28      * we've done aggregation,
   29      * then close the file.  Then, if any process left has done independent
   30      * i/o, close the file.  Otherwise, we'll skip the fs-specific close and
   31      * just say everything is a-ok.
   32      *
   33      * XXX: is it ok for those processes with a "real" communicator and those
   34      * with "MPI_COMM_SELF" to both call ADIOI_xxx_Close at the same time ?
   35      * everyone who ever opened the file will close it. Is order important? Is
   36      * timing important?
   37      */
   38     if (fd->hints->deferred_open && fd->is_agg) {
   39         (*(fd->fns->ADIOI_xxx_Close))(fd, error_code);
   40     } else {
   41         if(fd->is_open)  {
   42             (*(fd->fns->ADIOI_xxx_Close))(fd, error_code);
   43         } else {
   44             *error_code = MPI_SUCCESS;
   45         }
   46 
   47     }
   48 
   49     if (fd->access_mode & ADIO_DELETE_ON_CLOSE) {
   50     /* if we are doing aggregation and deferred open, then it's possible
   51      * that rank 0 does not have access to the file. make sure only an
   52      * aggregator deletes the file.*/
   53     MPI_Comm_rank(fd->comm, &myrank);
   54     if (myrank == fd->hints->ranklist[0]) {
   55         ADIO_Delete(fd->filename, &err);
   56     }
   57     MPI_Barrier(fd->comm);
   58     }
   59 
   60     if (fd->fortran_handle != -1) {
   61     ADIOI_Ftable[fd->fortran_handle] = MPI_FILE_NULL;
   62     }
   63 
   64     if (fd->hints && fd->hints->ranklist) ADIOI_Free(fd->hints->ranklist);
   65     if (fd->hints && fd->hints->cb_config_list) ADIOI_Free(fd->hints->cb_config_list);
   66 
   67     /* This BlueGene platform-specific free must be done in the common code
   68      * because the malloc's for these hint data structures are done at the
   69      * scope of ADIO_Open within the SetInfo call (ADIOI_GPFS_SetInfo which
   70      * calls ADIOI_BG_gen_agg_ranklist).  They cannot be done in the
   71      * ADIOI_GPFS_Close because of the file creation case where the
   72      * ADIOI_GPFS_Close and re-open via ADIOI_GPFS_Open are done which results
   73      * in a double-free - ADIOI_GPFS_Open does not redo the SetInfo...  */
   74 #ifdef BGQPLATFORM
   75     if (fd->hints && fd->hints->fs_hints.bg.bridgelist)
   76       ADIOI_Free(fd->hints->fs_hints.bg.bridgelist);
   77     if (fd->hints && fd->hints->fs_hints.bg.bridgelistnum)
   78       ADIOI_Free(fd->hints->fs_hints.bg.bridgelistnum);
   79 #endif
   80 
   81     /* Persistent File Realms */
   82     if (fd->hints->cb_pfr == ADIOI_HINT_ENABLE) {
   83     /* AAR, FSIZE, and User provided uniform File realms */
   84     if (1) {
   85         ADIOI_Delete_flattened (fd->file_realm_types[0]);
   86         MPI_Type_free (&fd->file_realm_types[0]);
   87     }
   88     else {
   89         for (i=0; i<fd->hints->cb_nodes; i++) {
   90         ADIOI_Datatype_iscontig(fd->file_realm_types[i], &is_contig);
   91         if (!is_contig)
   92             ADIOI_Delete_flattened(fd->file_realm_types[i]);
   93         MPI_Type_free (&fd->file_realm_types[i]);
   94         }
   95     }
   96     ADIOI_Free(fd->file_realm_st_offs);
   97     ADIOI_Free(fd->file_realm_types);
   98     }
   99     if (fd->hints) ADIOI_Free(fd->hints);
  100 
  101 
  102 
  103     MPI_Comm_free(&(fd->comm));
  104     ADIOI_Free(fd->filename);
  105 
  106     MPI_Type_get_envelope(fd->etype, &i, &j, &k, &combiner);
  107     if (combiner != MPI_COMBINER_NAMED) MPI_Type_free(&(fd->etype));
  108 
  109     ADIOI_Datatype_iscontig(fd->filetype, &is_contig);
  110     if (!is_contig) ADIOI_Delete_flattened(fd->filetype);
  111 
  112     MPI_Type_get_envelope(fd->filetype, &i, &j, &k, &combiner);
  113     if (combiner != MPI_COMBINER_NAMED) MPI_Type_free(&(fd->filetype));
  114 
  115     MPI_Info_free(&(fd->info));
  116 
  117     if (fd->io_buf != NULL) ADIOI_Free(fd->io_buf);
  118 
  119     /* memory for fd is freed in MPI_File_close */
  120 }