root/ompi/mca/io/romio321/romio/mpi-io/prealloc.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_File_preallocate

   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 "mpioimpl.h"
   9 
  10 #ifdef HAVE_WEAK_SYMBOLS
  11 
  12 #if defined(HAVE_PRAGMA_WEAK)
  13 #pragma weak MPI_File_preallocate = PMPI_File_preallocate
  14 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
  15 #pragma _HP_SECONDARY_DEF PMPI_File_preallocate MPI_File_preallocate
  16 #elif defined(HAVE_PRAGMA_CRI_DUP)
  17 #pragma _CRI duplicate MPI_File_preallocate as PMPI_File_preallocate
  18 /* end of weak pragmas */
  19 #elif defined(HAVE_WEAK_ATTRIBUTE)
  20 int MPI_File_preallocate(MPI_File fh, MPI_Offset size) __attribute__((weak,alias("PMPI_File_preallocate")));
  21 #endif
  22 
  23 /* Include mapping from MPI->PMPI */
  24 #define MPIO_BUILD_PROFILING
  25 #include "mpioprof.h"
  26 #endif
  27 
  28 /*@
  29     MPI_File_preallocate - Preallocates storage space for a file
  30 
  31 Input Parameters:
  32 . fh - file handle (handle)
  33 . size - size to preallocate (nonnegative integer)
  34 
  35 .N fortran
  36 @*/
  37 int MPI_File_preallocate(MPI_File fh, MPI_Offset size)
  38 {
  39     ADIO_Fcntl_t *fcntl_struct;
  40     int error_code=0, mynod=0;
  41     ADIO_File adio_fh;
  42     static char myname[] = "MPI_FILE_PREALLOCATE";
  43     MPI_Offset tmp_sz, max_sz, min_sz;
  44 #ifdef MPI_hpux
  45     int fl_xmpi;
  46 
  47     HPMP_IO_START(fl_xmpi, BLKMPIFILEPREALLOCATE, TRDTBLOCK,
  48                   adio_fh, MPI_DATATYPE_NULL, -1);
  49 #endif /* MPI_hpux */
  50 
  51     ROMIO_THREAD_CS_ENTER();
  52 
  53     adio_fh = MPIO_File_resolve(fh);
  54 
  55     /* --BEGIN ERROR HANDLING-- */
  56     MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code);
  57 
  58     if (size < 0) {
  59         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  60                                           myname, __LINE__, MPI_ERR_ARG,
  61                                           "**iobadsize", 0);
  62         error_code = MPIO_Err_return_file(adio_fh, error_code);
  63         goto fn_exit;
  64     }
  65 
  66     tmp_sz = size;
  67     MPI_Allreduce(&tmp_sz, &max_sz, 1, ADIO_OFFSET, MPI_MAX, adio_fh->comm);
  68     MPI_Allreduce(&tmp_sz, &min_sz, 1, ADIO_OFFSET, MPI_MIN, adio_fh->comm);
  69 
  70     if (max_sz != min_sz) {
  71         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  72                                           myname, __LINE__, MPI_ERR_ARG,
  73                                           "**notsame", 0);
  74         error_code = MPIO_Err_return_file(adio_fh, error_code);
  75         goto fn_exit;
  76     }
  77     /* --END ERROR HANDLING-- */
  78 
  79     if (size == 0) goto fn_exit;
  80 
  81     ADIOI_TEST_DEFERRED(adio_fh, myname, &error_code);
  82 
  83     MPI_Comm_rank(adio_fh->comm, &mynod);
  84     if (!mynod) {
  85         fcntl_struct = (ADIO_Fcntl_t *) ADIOI_Malloc(sizeof(ADIO_Fcntl_t));
  86         fcntl_struct->diskspace = size;
  87         ADIO_Fcntl(adio_fh, ADIO_FCNTL_SET_DISKSPACE, fcntl_struct, &error_code);
  88         ADIOI_Free(fcntl_struct);
  89         /* --BEGIN ERROR HANDLING-- */
  90         if (error_code != MPI_SUCCESS)
  91             error_code = MPIO_Err_return_file(adio_fh, error_code);
  92         /* --END ERROR HANDLING-- */
  93     }
  94     MPI_Barrier(adio_fh->comm);
  95     
  96 #ifdef MPI_hpux
  97     HPMP_IO_END(fl_xmpi, adio_fh, MPI_DATATYPE_NULL, -1);
  98 #endif /* MPI_hpux */
  99 
 100 
 101 fn_exit:
 102     ROMIO_THREAD_CS_EXIT();
 103 
 104     /* TODO: bcast result? */
 105     if (!mynod) return error_code;
 106     else return MPI_SUCCESS;
 107 }

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