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

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_File_read_shared

   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_read_shared = PMPI_File_read_shared
  14 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
  15 #pragma _HP_SECONDARY_DEF PMPI_File_read_shared MPI_File_read_shared
  16 #elif defined(HAVE_PRAGMA_CRI_DUP)
  17 #pragma _CRI duplicate MPI_File_read_shared as PMPI_File_read_shared
  18 /* end of weak pragmas */
  19 #elif defined(HAVE_WEAK_ATTRIBUTE)
  20 int MPI_File_read_shared(MPI_File fh, void *buf, int count, MPI_Datatype datatype,
  21                          MPI_Status *status) __attribute__((weak,alias("PMPI_File_read_shared")));
  22 #endif
  23 
  24 /* Include mapping from MPI->PMPI */
  25 #define MPIO_BUILD_PROFILING
  26 #include "mpioprof.h"
  27 #endif
  28 
  29 /* status object not filled currently */
  30 
  31 /*@
  32     MPI_File_read_shared - Read using shared file pointer
  33 
  34 Input Parameters:
  35 . fh - file handle (handle)
  36 . count - number of elements in buffer (nonnegative integer)
  37 . datatype - datatype of each buffer element (handle)
  38 
  39 Output Parameters:
  40 . buf - initial address of buffer (choice)
  41 . status - status object (Status)
  42 
  43 .N fortran
  44 @*/
  45 int MPI_File_read_shared(MPI_File fh, void *buf, int count,
  46                          MPI_Datatype datatype, MPI_Status *status)
  47 {
  48     int error_code, buftype_is_contig, filetype_is_contig;
  49     static char myname[] = "MPI_FILE_READ_SHARED";
  50     MPI_Count datatype_size;
  51     ADIO_Offset off, shared_fp, incr, bufsize;
  52     ADIO_File adio_fh;
  53     void *xbuf=NULL, *e32_buf=NULL;
  54 
  55     ROMIO_THREAD_CS_ENTER();
  56 
  57     adio_fh = MPIO_File_resolve(fh);
  58 
  59     /* --BEGIN ERROR HANDLING-- */
  60     MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code);
  61     MPIO_CHECK_COUNT(adio_fh, count, myname, error_code);
  62     MPIO_CHECK_DATATYPE(adio_fh, datatype, myname, error_code);
  63     /* --END ERROR HANDLING-- */
  64 
  65     MPI_Type_size_x(datatype, &datatype_size);
  66 
  67     /* --BEGIN ERROR HANDLING-- */
  68     MPIO_CHECK_COUNT_SIZE(adio_fh, count, datatype_size, myname, error_code);
  69     /* --END ERROR HANDLING-- */
  70 
  71     if (count*datatype_size == 0)
  72     {
  73 #ifdef HAVE_STATUS_SET_BYTES
  74         MPIR_Status_set_bytes(status, datatype, 0);
  75 #endif
  76         error_code = MPI_SUCCESS;
  77         goto fn_exit;
  78     }
  79 
  80     /* --BEGIN ERROR HANDLING-- */
  81     MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
  82     MPIO_CHECK_READABLE(adio_fh, myname, error_code);
  83     MPIO_CHECK_FS_SUPPORTS_SHARED(adio_fh, myname, error_code);
  84     /* --END ERROR HANDLING-- */
  85 
  86     ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
  87     ADIOI_Datatype_iscontig(adio_fh->filetype, &filetype_is_contig);
  88 
  89     ADIOI_TEST_DEFERRED(adio_fh, myname, &error_code);
  90 
  91     incr = (count*datatype_size)/adio_fh->etype_size;
  92 
  93     ADIO_Get_shared_fp(adio_fh, incr, &shared_fp, &error_code);
  94     /* --BEGIN ERROR HANDLING-- */
  95     if (error_code != MPI_SUCCESS)
  96     {
  97         error_code = MPIO_Err_return_file(adio_fh, error_code);
  98         goto fn_exit;
  99     }
 100     /* --END ERROR HANDLING-- */
 101 
 102     xbuf = buf;
 103     if (adio_fh->is_external32)
 104     {
 105         MPI_Aint e32_size = 0;
 106         error_code = MPIU_datatype_full_size(datatype, &e32_size);
 107         if (error_code != MPI_SUCCESS)
 108             goto fn_exit;
 109 
 110         e32_buf = ADIOI_Malloc(e32_size*count);
 111         xbuf = e32_buf;
 112     }
 113 
 114     /* contiguous or strided? */
 115     if (buftype_is_contig && filetype_is_contig)
 116     {
 117         /* convert count and shared_fp to bytes */
 118         bufsize = datatype_size * count;
 119         off = adio_fh->disp + adio_fh->etype_size * shared_fp;
 120 
 121         /* if atomic mode requested, lock (exclusive) the region, because there
 122            could be a concurrent noncontiguous request. On NFS, locking 
 123            is done in the ADIO_ReadContig.*/
 124 
 125         if ((adio_fh->atomicity) && (adio_fh->file_system != ADIO_NFS))
 126             ADIOI_WRITE_LOCK(adio_fh, off, SEEK_SET, bufsize);
 127 
 128         ADIO_ReadContig(adio_fh, xbuf, count, datatype, ADIO_EXPLICIT_OFFSET,
 129                         off, status, &error_code); 
 130 
 131         if ((adio_fh->atomicity) && (adio_fh->file_system != ADIO_NFS))
 132             ADIOI_UNLOCK(adio_fh, off, SEEK_SET, bufsize);
 133     }
 134     else
 135     {
 136         ADIO_ReadStrided(adio_fh, xbuf, count, datatype, ADIO_EXPLICIT_OFFSET,
 137                           shared_fp, status, &error_code);
 138         /* For strided and atomic mode, locking is done in ADIO_ReadStrided */
 139     }
 140 
 141     /* --BEGIN ERROR HANDLING-- */
 142     if (error_code != MPI_SUCCESS)
 143         error_code = MPIO_Err_return_file(adio_fh, error_code);
 144     /* --END ERROR HANDLING-- */
 145 
 146     if (e32_buf != NULL) {
 147         error_code = MPIU_read_external32_conversion_fn(buf, datatype,
 148                 count, e32_buf);
 149         ADIOI_Free(e32_buf);
 150     }
 151 fn_exit:
 152     ROMIO_THREAD_CS_EXIT();
 153 
 154     return error_code;
 155 }

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