root/ompi/mca/io/romio321/romio/adio/common/ad_iread.c

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

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_GEN_IreadContig
  2. ADIOI_GEN_IreadStrided

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *
   4  *   Copyright (C) 2004 University of Chicago. 
   5  *   See COPYRIGHT notice in top-level directory.
   6  */
   7 
   8 #include "adio.h"
   9 
  10 #ifdef HAVE_UNISTD_H
  11 #include <unistd.h>
  12 #endif
  13 #ifdef HAVE_SIGNAL_H
  14 #include <signal.h>
  15 #endif
  16 #ifdef HAVE_SYS_TYPES_H
  17 #include <sys/types.h>
  18 #endif
  19 #ifdef HAVE_AIO_H
  20 #include <aio.h>
  21 #endif
  22 #ifdef HAVE_SYS_AIO_H
  23 #include <sys/aio.h>
  24 #endif
  25 
  26 #include "mpiu_greq.h"
  27 
  28 #ifdef ROMIO_HAVE_WORKING_AIO
  29 /* ADIOI_GEN_IreadContig
  30  *
  31  * This code handles two distinct cases.  If ROMIO_HAVE_WORKING_AIO is not
  32  * defined, then I/O is performed in a blocking manner.  Otherwise we post
  33  * an asynchronous I/O operation using the appropriate aio routines. 
  34  *
  35  * In the aio case we rely on ADIOI_GEN_aio(), which is implemented in
  36  * common/ad_iwrite.c.
  37  */
  38 void ADIOI_GEN_IreadContig(ADIO_File fd, void *buf, int count, 
  39                            MPI_Datatype datatype, int file_ptr_type,
  40                            ADIO_Offset offset, MPI_Request *request,
  41                            int *error_code)  
  42 {
  43     MPI_Count len, typesize;
  44     int aio_errno = 0;
  45     static char myname[] = "ADIOI_GEN_IREADCONTIG";
  46 
  47     MPI_Type_size_x(datatype, &typesize);
  48     ADIOI_Assert((count * typesize) == ((ADIO_Offset)(unsigned)count * (ADIO_Offset)typesize));
  49     len = count * typesize;
  50 
  51     if (file_ptr_type == ADIO_INDIVIDUAL) offset = fd->fp_ind;
  52     aio_errno = ADIOI_GEN_aio(fd, buf, len, offset, 0, request);
  53     if (file_ptr_type == ADIO_INDIVIDUAL) fd->fp_ind += len;
  54 
  55     fd->fp_sys_posn = -1;
  56 
  57     /* --BEGIN ERROR HANDLING-- */
  58     if (aio_errno != 0) {
  59         MPIO_ERR_CREATE_CODE_ERRNO(myname, aio_errno, error_code);
  60         return;
  61     }
  62     /* --END ERROR HANDLING-- */
  63     
  64     *error_code = MPI_SUCCESS;
  65 }
  66 #endif
  67 
  68 /* Generic implementation of IreadStrided calls the blocking ReadStrided
  69  * immediately.
  70  */
  71 void ADIOI_GEN_IreadStrided(ADIO_File fd, void *buf, int count, 
  72                             MPI_Datatype datatype, int file_ptr_type,
  73                             ADIO_Offset offset, ADIO_Request *request,
  74                             int *error_code)
  75 {
  76     ADIO_Status status;
  77     MPI_Count typesize;
  78     MPI_Offset nbytes=0;
  79 
  80     /* Call the blocking function.  It will create an error code
  81      * if necessary.
  82      */
  83     ADIO_ReadStrided(fd, buf, count, datatype, file_ptr_type, 
  84                      offset, &status, error_code);  
  85 
  86     if (*error_code == MPI_SUCCESS) {
  87         MPI_Type_size_x(datatype, &typesize);
  88         nbytes = (MPI_Offset)count*(MPI_Offset)typesize;
  89     }
  90     MPIO_Completed_request_create(&fd, nbytes, error_code, request);
  91 }

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