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