root/ompi/mca/io/romio321/romio/adio/ad_pvfs2/ad_pvfs2_read.c

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

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_PVFS2_ReadContig
  2. ADIOI_PVFS2_ReadStridedListIO
  3. ADIOI_PVFS2_ReadStridedDtypeIO
  4. ADIOI_PVFS2_ReadStrided

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- 
   2  *     vim: ts=8 sts=4 sw=4 noexpandtab 
   3  * 
   4  *   Copyright (C) 1997 University of Chicago. 
   5  *   See COPYRIGHT notice in top-level directory.
   6  */
   7 
   8 #include "adio.h"
   9 #include "adio_extern.h"
  10 #include "ad_pvfs2.h"
  11 #include "ad_pvfs2_io.h"
  12 #include "ad_pvfs2_common.h"
  13 
  14 void ADIOI_PVFS2_ReadContig(ADIO_File fd, void *buf, int count, 
  15                             MPI_Datatype datatype, int file_ptr_type,
  16                             ADIO_Offset offset, ADIO_Status *status,
  17                             int *error_code)
  18 {
  19     int ret;
  20     MPI_Count datatype_size, len;
  21     PVFS_Request file_req, mem_req;
  22     PVFS_sysresp_io resp_io;
  23     ADIOI_PVFS2_fs *pvfs_fs;
  24     static char myname[] = "ADIOI_PVFS2_READCONTIG";
  25 
  26     pvfs_fs = (ADIOI_PVFS2_fs*)fd->fs_ptr;
  27 
  28     MPI_Type_size_x(datatype, &datatype_size);
  29     len = datatype_size * count;
  30 
  31     ret = PVFS_Request_contiguous(len, PVFS_BYTE, &mem_req);
  32     /* --BEGIN ERROR HANDLING-- */
  33     if (ret != 0) {
  34         *error_code = MPIO_Err_create_code(MPI_SUCCESS,
  35                                            MPIR_ERR_RECOVERABLE,
  36                                            myname, __LINE__,
  37                                            ADIOI_PVFS2_error_convert(ret),
  38                                            "Error in pvfs_request_contig (memory)", 0);
  39         return;
  40     }
  41     /* --END ERROR HANDLING-- */
  42 
  43     ret = PVFS_Request_contiguous(len, PVFS_BYTE, &file_req);
  44     /* --BEGIN ERROR HANDLING-- */
  45     if (ret != 0) {
  46         *error_code = MPIO_Err_create_code(MPI_SUCCESS,
  47                                            MPIR_ERR_RECOVERABLE,
  48                                            myname, __LINE__,
  49                                            ADIOI_PVFS2_error_convert(ret),
  50                                            "Error in pvfs_request_contig (file)", 0);
  51         return;
  52     }
  53     /* --END ERROR HANDLING-- */
  54 
  55     if (file_ptr_type == ADIO_INDIVIDUAL) {
  56         /* copy individual file pointer into offset variable, continue */
  57         offset = fd->fp_ind;
  58     }
  59 
  60 #ifdef ADIOI_MPE_LOGGING
  61     MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );
  62 #endif
  63     ret = PVFS_sys_read(pvfs_fs->object_ref, file_req, offset, buf, 
  64                         mem_req, &(pvfs_fs->credentials), &resp_io);
  65 #ifdef ADIOI_MPE_LOGGING
  66     MPE_Log_event( ADIOI_MPE_read_b, 0, NULL );
  67 #endif
  68     /* --BEGIN ERROR HANDLING-- */
  69     if (ret != 0 ) {
  70         *error_code = MPIO_Err_create_code(MPI_SUCCESS,
  71                                            MPIR_ERR_RECOVERABLE,
  72                                            myname, __LINE__,
  73                                            ADIOI_PVFS2_error_convert(ret),
  74                                            "Error in PVFS_sys_read", 0);
  75         goto fn_exit;
  76     }
  77     /* --END ERROR HANDLING-- */
  78 
  79     if (file_ptr_type == ADIO_INDIVIDUAL) {
  80         fd->fp_ind += (int) resp_io.total_completed;
  81         /* TODO: WHY THE INT CAST? */
  82     }
  83     fd->fp_sys_posn = offset + (int)resp_io.total_completed;
  84 
  85 #ifdef HAVE_STATUS_SET_BYTES
  86     MPIR_Status_set_bytes(status, datatype, resp_io.total_completed);
  87 #endif
  88 
  89     *error_code = MPI_SUCCESS;
  90 fn_exit:
  91     PVFS_Request_free(&mem_req);
  92     PVFS_Request_free(&file_req);
  93     return;
  94 }
  95 
  96 static int ADIOI_PVFS2_ReadStridedListIO(ADIO_File fd, void *buf, int count,
  97                                   MPI_Datatype datatype, int file_ptr_type,
  98                                   ADIO_Offset offset, ADIO_Status *status,
  99                                   int *error_code)
 100 {
 101     return ADIOI_PVFS2_StridedListIO(fd, buf, count,
 102                                      datatype, file_ptr_type,
 103                                      offset, status,
 104                                      error_code, READ);
 105 }
 106 
 107 static int ADIOI_PVFS2_ReadStridedDtypeIO(ADIO_File fd, void *buf, int count,
 108                                    MPI_Datatype datatype, int file_ptr_type,
 109                                    ADIO_Offset offset, ADIO_Status *status, 
 110                                    int *error_code)
 111 {
 112     return ADIOI_PVFS2_StridedDtypeIO(fd, buf, count,
 113                                       datatype, file_ptr_type,
 114                                       offset, status, error_code,
 115                                       READ);
 116 }
 117 
 118 void ADIOI_PVFS2_ReadStrided(ADIO_File fd, void *buf, int count,
 119                              MPI_Datatype datatype, int file_ptr_type,
 120                              ADIO_Offset offset, ADIO_Status *status, int
 121                              *error_code)
 122 {
 123     /* four ways (to date) that we can carry out strided i/o accesses:
 124      * - naive posix
 125      * - 'true' Datatype (from avery)
 126      * - new List I/O (from avery)
 127      * - classic List I/O  (the one that's always been in ROMIO)
 128      * I imagine we'll keep Datatype as an optional optimization, and afer a
 129      * release or two promote it to the default 
 130      */
 131     int ret = -1;
 132 
 133     if (fd->hints->fs_hints.pvfs2.posix_read == ADIOI_HINT_ENABLE) {
 134         ADIOI_GEN_ReadStrided(fd, buf, count, datatype, 
 135                 file_ptr_type, offset, status, error_code);
 136         return;
 137     }
 138     if (fd->hints->fs_hints.pvfs2.dtype_read == ADIOI_HINT_ENABLE) {
 139         ret = ADIOI_PVFS2_ReadStridedDtypeIO(fd, buf, count,
 140                                              datatype, file_ptr_type,
 141                                              offset, status, error_code);
 142 
 143         /* Fall back to list I/O if datatype I/O didn't work */
 144         if (ret != 0)
 145         {
 146             fprintf(stderr,
 147                     "Falling back to list I/O since datatype I/O failed\n");
 148             ret = ADIOI_PVFS2_ReadStridedListIO(fd, buf, count,
 149                                                 datatype, file_ptr_type,
 150                                                 offset, status, error_code);
 151         }
 152         return;
 153     }
 154     if (fd->hints->fs_hints.pvfs2.listio_read == ADIOI_HINT_ENABLE) {
 155         ret = ADIOI_PVFS2_ReadStridedListIO(fd, buf, count, datatype,
 156                 file_ptr_type, offset, status, error_code);
 157         return;
 158     }
 159     /* Use classic list I/O if no hints given base case */
 160 
 161     ADIOI_PVFS2_OldReadStrided(fd, buf, count, datatype, 
 162             file_ptr_type, offset, status, error_code);
 163     return;
 164 }
 165 
 166 
 167 /*
 168  * vim: ts=8 sts=4 sw=4 noexpandtab 
 169  */

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