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

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

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_PVFS2_WriteContig
  2. ADIOI_PVFS2_WriteStridedListIO
  3. ADIOI_PVFS2_WriteStridedDtypeIO
  4. ADIOI_PVFS2_WriteStrided

   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 "ad_pvfs2.h"
   9 #include "adio_extern.h"
  10 #include "ad_pvfs2_io.h"
  11 #include "ad_pvfs2_common.h"
  12 
  13 void ADIOI_PVFS2_WriteContig(ADIO_File fd, const void *buf, int count,
  14                              MPI_Datatype datatype, int file_ptr_type,
  15                              ADIO_Offset offset, ADIO_Status *status,
  16                              int *error_code)
  17 {
  18     int ret;
  19     MPI_Count datatype_size, len;
  20     PVFS_Request file_req, mem_req;
  21     PVFS_sysresp_io resp_io;
  22     ADIOI_PVFS2_fs *pvfs_fs;
  23     static char myname[] = "ADIOI_PVFS2_WRITECONTIG";
  24 
  25     pvfs_fs = (ADIOI_PVFS2_fs*)fd->fs_ptr;
  26 
  27     MPI_Type_size_x(datatype, &datatype_size);
  28     len = datatype_size * count;
  29 
  30     ret = PVFS_Request_contiguous(len, PVFS_BYTE, &mem_req);
  31     /* --BEGIN ERROR HANDLING-- */
  32     if (ret != 0) {
  33         *error_code = MPIO_Err_create_code(MPI_SUCCESS,
  34                                            MPIR_ERR_RECOVERABLE,
  35                                            myname, __LINE__,
  36                                            ADIOI_PVFS2_error_convert(ret),
  37                                            "Error in PVFS_Request_contiguous (memory)", 0);
  38         return;
  39     }
  40     /* --END ERROR HANDLING-- */
  41 
  42     ret = PVFS_Request_contiguous(len, PVFS_BYTE, &file_req);
  43     /* --BEGIN ERROR HANDLING-- */
  44     if (ret != 0) {
  45         *error_code = MPIO_Err_create_code(MPI_SUCCESS,
  46                                            MPIR_ERR_RECOVERABLE,
  47                                            myname, __LINE__,
  48                                            ADIOI_PVFS2_error_convert(ret),
  49                                            "Error in PVFS_Request_contiguous (file)", 0);
  50         return;
  51     }
  52     /* --END ERROR HANDLING-- */
  53 
  54     if (file_ptr_type == ADIO_EXPLICIT_OFFSET) {
  55 #ifdef ADIOI_MPE_LOGGING
  56         MPE_Log_event( ADIOI_MPE_write_a, 0, NULL );
  57 #endif
  58         ret = PVFS_sys_write(pvfs_fs->object_ref, file_req, offset,  (void *)buf,
  59                              mem_req, &(pvfs_fs->credentials), &resp_io);
  60 #ifdef ADIOI_MPE_LOGGING
  61         MPE_Log_event( ADIOI_MPE_write_b, 0, NULL );
  62 #endif
  63         /* --BEGIN ERROR HANDLING-- */
  64         if (ret != 0) {
  65             *error_code = MPIO_Err_create_code(MPI_SUCCESS,
  66                                                MPIR_ERR_RECOVERABLE,
  67                                                myname, __LINE__,
  68                                                ADIOI_PVFS2_error_convert(ret),
  69                                                "Error in PVFS_sys_write", 0);
  70             goto fn_exit;
  71         }
  72         /* --END ERROR HANDLING-- */
  73 
  74         fd->fp_sys_posn = offset + (int) resp_io.total_completed;
  75     }
  76     else {
  77 #ifdef ADIOI_MPE_LOGGING
  78         MPE_Log_event( ADIOI_MPE_write_a, 0, NULL );
  79 #endif
  80         ret = PVFS_sys_write(pvfs_fs->object_ref, file_req, fd->fp_ind, (void *)buf,
  81                              mem_req, &(pvfs_fs->credentials), &resp_io);
  82 #ifdef ADIOI_MPE_LOGGING
  83         MPE_Log_event( ADIOI_MPE_write_b, 0, NULL );
  84 #endif
  85         /* --BEGIN ERROR HANDLING-- */
  86         if (ret != 0) {
  87             *error_code = MPIO_Err_create_code(MPI_SUCCESS,
  88                                                MPIR_ERR_RECOVERABLE,
  89                                                myname, __LINE__,
  90                                                ADIOI_PVFS2_error_convert(ret),
  91                                                "Error in PVFS_sys_write", 0);
  92             goto fn_exit;
  93         }
  94         /* --END ERROR HANDLING-- */
  95         fd->fp_ind += (int)resp_io.total_completed;
  96         fd->fp_sys_posn = fd->fp_ind;
  97     }
  98 #ifdef HAVE_STATUS_SET_BYTES
  99     MPIR_Status_set_bytes(status, datatype, resp_io.total_completed);
 100 #endif
 101     *error_code = MPI_SUCCESS;
 102 fn_exit:
 103     PVFS_Request_free(&file_req);
 104     PVFS_Request_free(&mem_req);
 105     return;
 106 }
 107 
 108 int ADIOI_PVFS2_WriteStridedListIO(ADIO_File fd, const void *buf, int count,
 109                                    MPI_Datatype datatype, int file_ptr_type,
 110                                    ADIO_Offset offset, ADIO_Status *status,
 111                                    int *error_code)
 112 {
 113     return ADIOI_PVFS2_StridedListIO(fd, (void *)buf, count,
 114                                      datatype, file_ptr_type,
 115                                      offset, status,
 116                                      error_code, WRITE);
 117 }
 118 
 119 int ADIOI_PVFS2_WriteStridedDtypeIO(ADIO_File fd, const void *buf, int count,
 120                                     MPI_Datatype datatype, int file_ptr_type,
 121                                     ADIO_Offset offset, ADIO_Status *status, 
 122                                     int *error_code)
 123 {
 124     return ADIOI_PVFS2_StridedDtypeIO(fd, (void *)buf, count,
 125                                       datatype, file_ptr_type,
 126                                       offset, status, error_code,
 127                                       WRITE);
 128 }
 129 
 130 
 131 void ADIOI_PVFS2_WriteStrided(ADIO_File fd, const void *buf, int count,
 132                               MPI_Datatype datatype, int file_ptr_type,
 133                               ADIO_Offset offset, ADIO_Status *status,
 134                               int *error_code)
 135 {
 136     /* four ways (to date) that we can carry out strided i/o accesses:
 137      * - naive posix
 138      * - 'true' Datatype (from avery)
 139      * - new List I/O (from avery)
 140      * - classic List I/O  (the one that's always been in ROMIO)
 141      * I imagine we'll keep Datatype as an optional optimization, and afer a
 142      * release or two promote it to the default 
 143      */
 144 
 145     /* a lot of near-duplication from ADIOI_PVFS2_ReadStrided: for
 146      * debugging/testing it's helpful to be able to turn on and off these
 147      * optimizations separately for the read and write cases */
 148     int ret = -1;
 149     if ( fd->hints->fs_hints.pvfs2.posix_write == ADIOI_HINT_ENABLE) {
 150         ADIOI_GEN_WriteStrided_naive(fd, buf, count,
 151                                      datatype, file_ptr_type,
 152                                      offset, status, error_code);
 153         return;
 154     }
 155     if ( fd->hints->fs_hints.pvfs2.dtype_write == ADIOI_HINT_ENABLE) {
 156         ret = ADIOI_PVFS2_WriteStridedDtypeIO(fd, buf, count,
 157                                               datatype, file_ptr_type,
 158                                               offset, status, error_code);
 159 
 160         /* Fall back to list I/O if datatype I/O didn't work */
 161         if (ret != 0)
 162         {
 163             fprintf(stderr,
 164                     "Falling back to list I/O since datatype I/O failed\n");
 165             ret = ADIOI_PVFS2_WriteStridedListIO(fd, buf, count,
 166                                                  datatype, file_ptr_type,
 167                                                  offset, status, error_code);
 168         }
 169         return;
 170     }
 171     /* Use list I/O in the base case */
 172     if (fd->hints->fs_hints.pvfs2.listio_write == ADIOI_HINT_ENABLE) {
 173         ret = ADIOI_PVFS2_WriteStridedListIO(fd, buf, count, datatype, 
 174                         file_ptr_type, offset, status, error_code);
 175         return;
 176     }
 177 
 178     /* Use classic list I/O if no hints given base case */
 179     ADIOI_PVFS2_OldWriteStrided(fd, buf, count, datatype,
 180             file_ptr_type, offset, status, error_code);
 181     return;
 182 }

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