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

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_File_read_all
  2. MPIOI_File_read_all

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *   Copyright (C) 1997 University of Chicago. 
   4  *   See COPYRIGHT notice in top-level directory.
   5  */
   6 
   7 #include "mpioimpl.h"
   8 
   9 #ifdef HAVE_WEAK_SYMBOLS
  10 
  11 #if defined(HAVE_PRAGMA_WEAK)
  12 #pragma weak MPI_File_read_all = PMPI_File_read_all
  13 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
  14 #pragma _HP_SECONDARY_DEF PMPI_File_read_all MPI_File_read_all
  15 #elif defined(HAVE_PRAGMA_CRI_DUP)
  16 #pragma _CRI duplicate MPI_File_read_all as PMPI_File_read_all
  17 /* end of weak pragmas */
  18 #elif defined(HAVE_WEAK_ATTRIBUTE)
  19 int MPI_File_read_all(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status)
  20     __attribute__((weak,alias("PMPI_File_read_all")));
  21 #endif
  22 
  23 /* Include mapping from MPI->PMPI */
  24 #define MPIO_BUILD_PROFILING
  25 #include "mpioprof.h"
  26 #endif
  27 
  28 /* status object not filled currently */
  29 
  30 /*@
  31     MPI_File_read_all - Collective read using individual file pointer
  32 
  33 Input Parameters:
  34 . fh - file handle (handle)
  35 . count - number of elements in buffer (nonnegative integer)
  36 . datatype - datatype of each buffer element (handle)
  37 
  38 Output Parameters:
  39 . buf - initial address of buffer (choice)
  40 . status - status object (Status)
  41 
  42 .N fortran
  43 @*/
  44 int MPI_File_read_all(MPI_File fh, void *buf, int count,
  45                       MPI_Datatype datatype, MPI_Status *status)
  46 {
  47     int error_code;
  48     static char myname[] = "MPI_FILE_READ_ALL";
  49 #ifdef MPI_hpux
  50     int fl_xmpi;
  51 
  52     HPMP_IO_START(fl_xmpi, BLKMPIFILEREADALL, TRDTBLOCK, fh, datatype, count);
  53 #endif /* MPI_hpux */
  54 
  55     error_code = MPIOI_File_read_all(fh, (MPI_Offset) 0,
  56                                      ADIO_INDIVIDUAL, buf,
  57                                      count, datatype, myname, status);
  58 
  59 #ifdef MPI_hpux
  60     HPMP_IO_END(fl_xmpi, fh, datatype, count);
  61 #endif /* MPI_hpux */
  62 
  63     return error_code;
  64 }
  65 
  66 /* Note: MPIOI_File_read_all also used by MPI_File_read_at_all */
  67 /* prevent multiple definitions of this routine */
  68 #ifdef MPIO_BUILD_PROFILING
  69 int MPIOI_File_read_all(MPI_File fh,
  70                         MPI_Offset offset,
  71                         int file_ptr_type,
  72                         void *buf,
  73                         int count,
  74                         MPI_Datatype datatype,
  75                         char *myname,
  76                         MPI_Status *status)
  77 {
  78     int error_code;
  79     MPI_Count datatype_size;
  80     ADIO_File adio_fh;
  81     void *xbuf=NULL, *e32_buf=NULL;
  82 
  83     ROMIO_THREAD_CS_ENTER();
  84 
  85     adio_fh = MPIO_File_resolve(fh);
  86 
  87     /* --BEGIN ERROR HANDLING-- */
  88     MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code);
  89     MPIO_CHECK_COUNT(adio_fh, count, myname, error_code);
  90     MPIO_CHECK_DATATYPE(adio_fh, datatype, myname, error_code);
  91 
  92     if (file_ptr_type == ADIO_EXPLICIT_OFFSET && offset < 0)
  93     {
  94         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  95                                           myname, __LINE__, MPI_ERR_ARG,
  96                                           "**iobadoffset", 0);
  97         error_code = MPIO_Err_return_file(adio_fh, error_code);
  98         goto fn_exit;
  99     }
 100     /* --END ERROR HANDLING-- */
 101 
 102     MPI_Type_size_x(datatype, &datatype_size);
 103 
 104     /* --BEGIN ERROR HANDLING-- */
 105     MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
 106     MPIO_CHECK_READABLE(adio_fh, myname, error_code);
 107     MPIO_CHECK_NOT_SEQUENTIAL_MODE(adio_fh, myname, error_code);
 108     MPIO_CHECK_COUNT_SIZE(adio_fh, count, datatype_size, myname, error_code);
 109     /* --END ERROR HANDLING-- */
 110 
 111     xbuf = buf;
 112     if (adio_fh->is_external32)
 113     {
 114         MPI_Aint e32_size = 0;
 115         error_code = MPIU_datatype_full_size(datatype, &e32_size);
 116         if (error_code != MPI_SUCCESS)
 117             goto fn_exit;
 118 
 119         e32_buf = ADIOI_Malloc(e32_size*count);
 120         xbuf = e32_buf;
 121     }
 122 
 123     ADIO_ReadStridedColl(adio_fh, xbuf, count, datatype, file_ptr_type,
 124                          offset, status, &error_code);
 125 
 126     /* --BEGIN ERROR HANDLING-- */
 127     if (error_code != MPI_SUCCESS)
 128         error_code = MPIO_Err_return_file(adio_fh, error_code);
 129     /* --END ERROR HANDLING-- */
 130 
 131     if (e32_buf != NULL) {
 132         error_code = MPIU_read_external32_conversion_fn(buf, datatype,
 133                 count, e32_buf);
 134         ADIOI_Free(e32_buf);
 135     }
 136 
 137 fn_exit:
 138     ROMIO_THREAD_CS_EXIT();
 139 
 140     return error_code;
 141 }
 142 #endif

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