-:    0:Source:/home/MPI/testing/mpich2/mpich2/src/mpi/romio/mpi-io/iread.c
        -:    0:Graph:iread.gcno
        -:    0:Data:iread.gcda
        -:    0:Runs:529
        -:    0:Programs:142
        -:    1:/* -*- Mode: C; c-basic-offset:4 ; -*- */
        -:    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 = PMPI_File_iread
        -:   14:#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
        -:   15:#pragma _HP_SECONDARY_DEF PMPI_File_iread MPI_File_iread
        -:   16:#elif defined(HAVE_PRAGMA_CRI_DUP)
        -:   17:#pragma _CRI duplicate MPI_File_iread as PMPI_File_iread
        -:   18:/* end of weak pragmas */
        -:   19:#endif
        -:   20:
        -:   21:/* Include mapping from MPI->PMPI */
        -:   22:#define MPIO_BUILD_PROFILING
        -:   23:#include "mpioprof.h"
        -:   24:#endif
        -:   25:/*@
        -:   26:    MPI_File_iread - Nonblocking read using individual file pointer
        -:   27:
        -:   28:Input Parameters:
        -:   29:. fh - file handle (handle)
        -:   30:. count - number of elements in buffer (nonnegative integer)
        -:   31:. datatype - datatype of each buffer element (handle)
        -:   32:
        -:   33:Output Parameters:
        -:   34:. buf - initial address of buffer (choice)
        -:   35:. request - request object (handle)
        -:   36:
        -:   37:.N fortran
        -:   38:@*/
        -:   39:#ifdef HAVE_MPI_GREQUEST
        -:   40:#include "mpiu_greq.h"
        -:   41:#endif
        -:   42:
        -:   43:int MPI_File_iread(MPI_File mpi_fh, void *buf, int count, 
        -:   44:		   MPI_Datatype datatype, MPI_Request *request)
    88780:   45:{
    88780:   46:    int error_code=MPI_SUCCESS;
        -:   47:    static char myname[] = "MPI_FILE_IREAD";
    88780:   48:    MPIU_THREADPRIV_DECL;
        -:   49:#ifdef MPI_hpux
        -:   50:    int fl_xmpi;
        -:   51:
        -:   52:    HPMP_IO_START(fl_xmpi, BLKMPIFILEIREAD, TRDTSYSTEM, mpi_fh, datatype,
        -:   53:		  count);
        -:   54:#endif /* MPI_hpux */
        -:   55:
    88780:   56:    MPIU_THREAD_CS_ENTER(ALLFUNC,);
        -:   57:
    88780:   58:    error_code = MPIOI_File_iread(mpi_fh, (MPI_Offset) 0, ADIO_INDIVIDUAL,
        -:   59:				  buf, count, datatype, myname, request);
        -:   60:    
        -:   61:    /* --BEGIN ERROR HANDLING-- */
    88780:   62:    if (error_code != MPI_SUCCESS)
    #####:   63:	error_code = MPIO_Err_return_file(mpi_fh, error_code);
        -:   64:    /* --END ERROR HANDLING-- */
        -:   65:
        -:   66:#ifdef MPI_hpux
        -:   67:    HPMP_IO_END(fl_xmpi, mpi_fh, datatype, count);
        -:   68:#endif /* MPI_hpux */
    88780:   69:    MPIU_THREAD_CS_EXIT(ALLFUNC,);
        -:   70:
    88780:   71:    return error_code;
        -:   72:}
        -:   73:
        -:   74:/* prevent multiple definitions of this routine */
        -:   75:#ifdef MPIO_BUILD_PROFILING
        -:   76:int MPIOI_File_iread(MPI_File mpi_fh,
        -:   77:		     MPI_Offset offset,
        -:   78:		     int file_ptr_type,
        -:   79:		     void *buf,
        -:   80:		     int count,
        -:   81:		     MPI_Datatype datatype,
        -:   82:		     char *myname,
        -:   83:		     MPI_Request *request)
   177516:   84:{
        -:   85:    int error_code, bufsize, buftype_is_contig, filetype_is_contig;
        -:   86:    int datatype_size;
        -:   87:    ADIO_Status status;
        -:   88:    ADIO_File fh;
        -:   89:    ADIO_Offset off;
   177516:   90:    MPI_Offset nbytes=0;
        -:   91:
   177516:   92:    MPIR_Nest_incr();
   177516:   93:    fh = MPIO_File_resolve(mpi_fh);
        -:   94:
        -:   95:    /* --BEGIN ERROR HANDLING-- */
   177516:   96:    MPIO_CHECK_FILE_HANDLE(fh, myname, error_code);
   177516:   97:    MPIO_CHECK_COUNT(fh, count, myname, error_code);
   177516:   98:    MPIO_CHECK_DATATYPE(fh, datatype, myname, error_code);
        -:   99:
   177516:  100:    if (file_ptr_type == ADIO_EXPLICIT_OFFSET && offset < 0) {
    #####:  101:	error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
        -:  102:					  myname, __LINE__, MPI_ERR_ARG,
        -:  103:					  "**iobadoffset", 0);
    #####:  104:	error_code = MPIO_Err_return_file(fh, error_code);
    #####:  105:	goto fn_exit;
        -:  106:    }
        -:  107:    /* --END ERROR HANDLING-- */
        -:  108:
   177516:  109:    MPI_Type_size(datatype, &datatype_size);
        -:  110:
        -:  111:    /* --BEGIN ERROR HANDLING-- */
   177516:  112:    MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
   177516:  113:    MPIO_CHECK_READABLE(fh, myname, error_code);
   177516:  114:    MPIO_CHECK_NOT_SEQUENTIAL_MODE(fh, myname, error_code);
   177516:  115:    MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
        -:  116:    /* --END ERROR HANDLING-- */
        -:  117:
   177516:  118:    ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
   177516:  119:    ADIOI_Datatype_iscontig(fh->filetype, &filetype_is_contig);
        -:  120:
   177516:  121:    ADIOI_TEST_DEFERRED(fh, myname, &error_code);
        -:  122:
   177516:  123:    if (buftype_is_contig && filetype_is_contig) {
        -:  124:	/* convert count and offset to bytes */
   177484:  125:	bufsize = datatype_size * count;
        -:  126:
   177484:  127:	if (file_ptr_type == ADIO_EXPLICIT_OFFSET) {
    88720:  128:	    off = fh->disp + fh->etype_size * offset;
        -:  129:	}
        -:  130:	else {
    88764:  131:	    off = fh->fp_ind;
        -:  132:	}
        -:  133:
   177484:  134:        if (!(fh->atomicity))
   177484:  135:	    ADIO_IreadContig(fh, buf, count, datatype, file_ptr_type,
        -:  136:			off, request, &error_code); 
        -:  137:        else {
        -:  138:            /* to maintain strict atomicity semantics with other concurrent
        -:  139:              operations, lock (exclusive) and call blocking routine */
    #####:  140:	    if (ADIO_Feature(fh, ADIO_LOCKS))
        -:  141:	    {
    #####:  142:                ADIOI_WRITE_LOCK(fh, off, SEEK_SET, bufsize);
        -:  143:	    }
        -:  144:
    #####:  145:            ADIO_ReadContig(fh, buf, count, datatype, file_ptr_type, 
        -:  146:			    off, &status, &error_code);
        -:  147:
    #####:  148:	    if (ADIO_Feature(fh, ADIO_LOCKS)) 
        -:  149:	    {
    #####:  150:                ADIOI_UNLOCK(fh, off, SEEK_SET, bufsize);
        -:  151:	    }
    #####:  152:	    if (error_code == MPI_SUCCESS) {
    #####:  153:		nbytes = count*datatype_size;
        -:  154:	    }
    #####:  155:	    MPIO_Completed_request_create(&fh, nbytes, &error_code, request);
        -:  156:        }
        -:  157:    }
       32:  158:    else ADIO_IreadStrided(fh, buf, count, datatype, file_ptr_type,
        -:  159:			   offset, request, &error_code); 
        -:  160:
   177516:  161:fn_exit:
   177516:  162:    MPIR_Nest_decr();
        -:  163:
   177516:  164:    return error_code;
        -:  165:}
        -:  166:#endif