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

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_File_iread_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_iread_shared = PMPI_File_iread_shared
  14 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
  15 #pragma _HP_SECONDARY_DEF PMPI_File_iread_shared MPI_File_iread_shared
  16 #elif defined(HAVE_PRAGMA_CRI_DUP)
  17 #pragma _CRI duplicate MPI_File_iread_shared as PMPI_File_iread_shared
  18 /* end of weak pragmas */
  19 #elif defined(HAVE_WEAK_ATTRIBUTE)
  20 int MPI_File_iread_shared(MPI_File fh, void *buf, int count, MPI_Datatype datatype,
  21                           MPIO_Request *request) __attribute__((weak,alias("PMPI_File_iread_shared")));
  22 #endif
  23 
  24 /* Include mapping from MPI->PMPI */
  25 #define MPIO_BUILD_PROFILING
  26 #include "mpioprof.h"
  27 #endif
  28 
  29 #ifdef HAVE_MPI_GREQUEST
  30 #include "mpiu_greq.h"
  31 
  32 /*@
  33     MPI_File_iread_shared - Nonblocking read using shared file pointer
  34 
  35 Input Parameters:
  36 . fh - file handle (handle)
  37 . count - number of elements in buffer (nonnegative integer)
  38 . datatype - datatype of each buffer element (handle)
  39 
  40 Output Parameters:
  41 . buf - initial address of buffer (choice)
  42 . request - request object (handle)
  43 
  44 .N fortran
  45 @*/
  46 int MPI_File_iread_shared(MPI_File fh, void *buf, int count,
  47                           MPI_Datatype datatype, MPI_Request *request)
  48 {
  49     int error_code, buftype_is_contig, filetype_is_contig;
  50     ADIO_Offset bufsize;
  51     ADIO_File adio_fh;
  52     static char myname[] = "MPI_FILE_IREAD_SHARED";
  53     MPI_Count datatype_size, incr;
  54     MPI_Status status;
  55     ADIO_Offset off, shared_fp;
  56     MPI_Offset nbytes=0;
  57 
  58     ROMIO_THREAD_CS_ENTER();
  59 
  60     adio_fh = MPIO_File_resolve(fh);
  61 
  62     /* --BEGIN ERROR HANDLING-- */
  63     MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code);
  64     MPIO_CHECK_COUNT(adio_fh, count, myname, error_code);
  65     MPIO_CHECK_DATATYPE(adio_fh, datatype, myname, error_code);
  66     /* --END ERROR HANDLING-- */
  67 
  68     MPI_Type_size_x(datatype, &datatype_size);
  69 
  70     /* --BEGIN ERROR HANDLING-- */
  71     MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
  72     MPIO_CHECK_FS_SUPPORTS_SHARED(adio_fh, myname, error_code);
  73     MPIO_CHECK_COUNT_SIZE(adio_fh, count, datatype_size, myname, error_code);
  74     /* --END ERROR HANDLING-- */
  75 
  76     ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
  77     ADIOI_Datatype_iscontig(adio_fh->filetype, &filetype_is_contig);
  78 
  79     ADIOI_TEST_DEFERRED(adio_fh, myname, &error_code);
  80 
  81     incr = (count*datatype_size)/adio_fh->etype_size;
  82     ADIO_Get_shared_fp(adio_fh, incr, &shared_fp, &error_code);
  83 
  84     /* --BEGIN ERROR HANDLING-- */
  85     if (error_code != MPI_SUCCESS)
  86     {
  87         /* note: ADIO_Get_shared_fp should have set up error code already? */
  88         MPIO_Err_return_file(adio_fh, error_code);
  89     }
  90     /* --END ERROR HANDLING-- */
  91 
  92     if (buftype_is_contig && filetype_is_contig)
  93     {
  94     /* convert count and shared_fp to bytes */
  95         bufsize = datatype_size * count;
  96         off = adio_fh->disp + adio_fh->etype_size * shared_fp;
  97         if (!(adio_fh->atomicity))
  98         {
  99             ADIO_IreadContig(adio_fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
 100                         off, request, &error_code);
 101         }
 102         else
 103         {
 104             /* to maintain strict atomicity semantics with other concurrent
 105               operations, lock (exclusive) and call blocking routine */
 106 
 107             if (adio_fh->file_system != ADIO_NFS)
 108             {
 109                 ADIOI_WRITE_LOCK(adio_fh, off, SEEK_SET, bufsize);
 110             }
 111 
 112             ADIO_ReadContig(adio_fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
 113                             off, &status, &error_code);  
 114 
 115             if (adio_fh->file_system != ADIO_NFS)
 116             {
 117                 ADIOI_UNLOCK(adio_fh, off, SEEK_SET, bufsize);
 118             }
 119             if (error_code == MPI_SUCCESS){
 120                     nbytes = count * datatype_size;
 121             }
 122             MPIO_Completed_request_create(&adio_fh, nbytes, &error_code, request);
 123         }
 124     }
 125     else
 126     {
 127         ADIO_IreadStrided(adio_fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
 128                            shared_fp, request, &error_code);
 129     }
 130 
 131     /* --BEGIN ERROR HANDLING-- */
 132     if (error_code != MPI_SUCCESS)
 133         error_code = MPIO_Err_return_file(adio_fh, error_code);
 134     /* --END ERROR HANDLING-- */
 135 
 136 fn_exit:
 137     ROMIO_THREAD_CS_EXIT();
 138     return error_code;
 139 }
 140 #endif

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