root/ompi/mca/io/romio321/romio/mpi-io/set_view.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_File_set_view

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   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_set_view = PMPI_File_set_view
  14 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
  15 #pragma _HP_SECONDARY_DEF PMPI_File_set_view MPI_File_set_view
  16 #elif defined(HAVE_PRAGMA_CRI_DUP)
  17 #pragma _CRI duplicate MPI_File_set_view as PMPI_File_set_view
  18 /* end of weak pragmas */
  19 #elif defined(HAVE_WEAK_ATTRIBUTE)
  20 int MPI_File_set_view(MPI_File fh, MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype,
  21                       const char *datarep, MPI_Info info) __attribute__((weak,alias("PMPI_File_set_view")));
  22 #endif
  23 
  24 /* Include mapping from MPI->PMPI */
  25 #define MPIO_BUILD_PROFILING
  26 #include "mpioprof.h"
  27 #endif
  28 
  29 /*@
  30     MPI_File_set_view - Sets the file view
  31 
  32 Input Parameters:
  33 . fh - file handle (handle)
  34 . disp - displacement (nonnegative integer)
  35 . etype - elementary datatype (handle)
  36 . filetype - filetype (handle)
  37 . datarep - data representation (string)
  38 . info - info object (handle)
  39 
  40 .N fortran
  41 @*/
  42 int MPI_File_set_view(MPI_File fh, MPI_Offset disp, MPI_Datatype etype,
  43                       MPI_Datatype filetype, ROMIO_CONST char *datarep, MPI_Info info)
  44 {
  45     int error_code;
  46     MPI_Count filetype_size, etype_size;
  47     static char myname[] = "MPI_FILE_SET_VIEW";
  48     ADIO_Offset shared_fp, byte_off;
  49     ADIO_File adio_fh;
  50 
  51     ROMIO_THREAD_CS_ENTER();
  52 
  53     adio_fh = MPIO_File_resolve(fh);
  54 
  55     /* --BEGIN ERROR HANDLING-- */
  56     MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code);
  57 
  58     if ((disp < 0) && (disp != MPI_DISPLACEMENT_CURRENT))
  59     {
  60         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  61                                           myname, __LINE__, MPI_ERR_ARG, 
  62                                           "**iobaddisp", 0);
  63         error_code = MPIO_Err_return_file(adio_fh, error_code);
  64         goto fn_exit;
  65     }
  66 
  67     /* rudimentary checks for incorrect etype/filetype.*/
  68     if (etype == MPI_DATATYPE_NULL) {
  69         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  70                                           myname, __LINE__, MPI_ERR_ARG,
  71                                           "**ioetype", 0);
  72         error_code = MPIO_Err_return_file(adio_fh, error_code);
  73         goto fn_exit;
  74     }
  75     MPIO_DATATYPE_ISCOMMITTED(etype, error_code);
  76     if (error_code != MPI_SUCCESS) {
  77         error_code = MPIO_Err_return_file(adio_fh, error_code);
  78         goto fn_exit;
  79     }
  80 
  81     if (filetype == MPI_DATATYPE_NULL) {
  82         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  83                                           myname, __LINE__, MPI_ERR_ARG,
  84                                           "**iofiletype", 0);
  85         error_code = MPIO_Err_return_file(adio_fh, error_code);
  86         goto fn_exit;
  87     }
  88     MPIO_DATATYPE_ISCOMMITTED(filetype, error_code);
  89     if (error_code != MPI_SUCCESS) {
  90         error_code = MPIO_Err_return_file(adio_fh, error_code);
  91         goto fn_exit;
  92     }
  93 
  94     if ((adio_fh->access_mode & MPI_MODE_SEQUENTIAL) &&
  95         (disp != MPI_DISPLACEMENT_CURRENT))
  96     {
  97         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  98                                           myname, __LINE__, MPI_ERR_ARG, 
  99                                           "**iodispifseq", 0);
 100         error_code = MPIO_Err_return_file(adio_fh, error_code);
 101         goto fn_exit;
 102     }
 103 
 104     if ((disp == MPI_DISPLACEMENT_CURRENT) &&
 105         !(adio_fh->access_mode & MPI_MODE_SEQUENTIAL))
 106     {
 107         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
 108                                           myname, __LINE__, MPI_ERR_ARG, 
 109                                           "**iodispifseq", 0);
 110         error_code = MPIO_Err_return_file(adio_fh, error_code);
 111         goto fn_exit;
 112     }
 113     MPIO_CHECK_INFO_ALL(info, error_code, adio_fh->comm);
 114     /* --END ERROR HANDLING-- */
 115 
 116     MPI_Type_size_x(filetype, &filetype_size);
 117     MPI_Type_size_x(etype, &etype_size);
 118 
 119     /* --BEGIN ERROR HANDLING-- */
 120     if (etype_size != 0 && filetype_size % etype_size != 0)
 121     {
 122         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
 123                                           myname, __LINE__, MPI_ERR_ARG,
 124                                           "**iofiletype", 0);
 125         error_code = MPIO_Err_return_file(adio_fh, error_code);
 126         goto fn_exit;
 127     }
 128 
 129     if ((datarep == NULL) || (strcmp(datarep, "native") &&
 130             strcmp(datarep, "NATIVE") &&
 131             strcmp(datarep, "external32") &&
 132             strcmp(datarep, "EXTERNAL32") &&
 133             strcmp(datarep, "internal") &&
 134             strcmp(datarep, "INTERNAL")) )
 135     {
 136         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
 137                                           myname, __LINE__,
 138                                           MPI_ERR_UNSUPPORTED_DATAREP, 
 139                                           "**unsupporteddatarep",0);
 140         error_code = MPIO_Err_return_file(adio_fh, error_code);
 141         goto fn_exit;
 142     }
 143     /* --END ERROR HANDLING-- */
 144 
 145     if (disp == MPI_DISPLACEMENT_CURRENT) {
 146         MPI_Barrier(adio_fh->comm);
 147         ADIO_Get_shared_fp(adio_fh, 0, &shared_fp, &error_code);
 148         /* TODO: check error code */
 149 
 150         MPI_Barrier(adio_fh->comm);
 151         ADIOI_Get_byte_offset(adio_fh, shared_fp, &byte_off);
 152         /* TODO: check error code */
 153 
 154         disp = byte_off;
 155     }
 156 
 157     ADIO_Set_view(adio_fh, disp, etype, filetype, info, &error_code);
 158 
 159     /* --BEGIN ERROR HANDLING-- */
 160     if (error_code != MPI_SUCCESS) {
 161         error_code = MPIO_Err_return_file(adio_fh, error_code);
 162         goto fn_exit;
 163     }
 164     /* --END ERROR HANDLING-- */
 165 
 166     /* reset shared file pointer to zero */
 167     if (ADIO_Feature(adio_fh, ADIO_SHARED_FP) &&
 168         (adio_fh->shared_fp_fd != ADIO_FILE_NULL))
 169     {
 170         /* only one process needs to set it to zero, but I don't want to 
 171            create the shared-file-pointer file if shared file pointers have 
 172            not been used so far. Therefore, every process that has already 
 173            opened the shared-file-pointer file sets the shared file pointer 
 174            to zero. If the file was not opened, the value is automatically 
 175            zero. Note that shared file pointer is stored as no. of etypes
 176            relative to the current view, whereas indiv. file pointer is
 177            stored in bytes. */
 178 
 179         ADIO_Set_shared_fp(adio_fh, 0, &error_code);
 180         /* --BEGIN ERROR HANDLING-- */
 181         if (error_code != MPI_SUCCESS)
 182             error_code = MPIO_Err_return_file(adio_fh, error_code);
 183         /* --END ERROR HANDLING-- */
 184     }
 185 
 186     if (ADIO_Feature(adio_fh, ADIO_SHARED_FP))
 187     {
 188         MPI_Barrier(adio_fh->comm); /* for above to work correctly */
 189     }
 190     if (strcmp(datarep, "external32") && strcmp(datarep, "EXTERNAL32"))
 191         adio_fh->is_external32 = 0;
 192     else
 193         adio_fh->is_external32 = 1;
 194 
 195 fn_exit:
 196     ROMIO_THREAD_CS_EXIT();
 197 
 198     return error_code;
 199 fn_fail:
 200         /* --BEGIN ERROR HANDLING-- */
 201         error_code = MPIO_Err_return_file(fh, error_code);
 202         goto fn_exit;
 203         /* --END ERROR HANDLING-- */
 204 }

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