root/ompi/mca/io/ompio/io_ompio_file_set_view.c

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

DEFINITIONS

This source file includes following definitions.
  1. datatype_duplicate
  2. mca_io_ompio_file_set_view
  3. mca_io_ompio_file_get_view

   1 /*
   2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2016 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2008-2018 University of Houston. All rights reserved.
  13  * Copyright (c) 2015-2018 Research Organization for Information Science
  14  *                         and Technology (RIST). All rights reserved.
  15  * Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
  16  *  $COPYRIGHT$
  17  *
  18  *  Additional copyrights may follow
  19  *
  20  *  $HEADER$
  21  */
  22 
  23 #include "ompi_config.h"
  24 
  25 #include "ompi/communicator/communicator.h"
  26 #include "ompi/info/info.h"
  27 #include "ompi/file/file.h"
  28 #include "ompi/mca/pml/pml.h"
  29 #include "opal/datatype/opal_convertor.h"
  30 #include "ompi/datatype/ompi_datatype.h"
  31 #include <stdlib.h>
  32 #include <stdio.h>
  33 
  34 #include <unistd.h>
  35 #include "io_ompio.h"
  36 
  37 static int datatype_duplicate (ompi_datatype_t *oldtype, ompi_datatype_t **newtype );
  38 static int datatype_duplicate  (ompi_datatype_t *oldtype, ompi_datatype_t **newtype )
  39 {
  40     ompi_datatype_t *type;
  41     if( ompi_datatype_is_predefined(oldtype) ) {
  42         OBJ_RETAIN(oldtype);
  43         *newtype = oldtype;
  44         return OMPI_SUCCESS;
  45     }
  46 
  47     if ( OMPI_SUCCESS != ompi_datatype_duplicate (oldtype, &type)){
  48         ompi_datatype_destroy (&type);
  49         return MPI_ERR_INTERN;
  50     }
  51     
  52     ompi_datatype_set_args( type, 0, NULL, 0, NULL, 1, &oldtype, MPI_COMBINER_DUP );
  53 
  54     *newtype = type;
  55     return OMPI_SUCCESS;
  56 }
  57 
  58 int mca_io_ompio_file_set_view (ompi_file_t *fp,
  59                                 OMPI_MPI_OFFSET_TYPE disp,
  60                                 ompi_datatype_t *etype,
  61                                 ompi_datatype_t *filetype,
  62                                 const char *datarep,
  63                                 opal_info_t *info)
  64 {
  65     int ret=OMPI_SUCCESS;
  66     mca_common_ompio_data_t *data;
  67     ompio_file_t *fh;
  68 
  69     if ( (strcmp(datarep, "native") && strcmp(datarep, "NATIVE") &&
  70           strcmp(datarep, "external32") && strcmp(datarep, "EXTERNAL32"))) {
  71         return MPI_ERR_UNSUPPORTED_DATAREP;
  72     }
  73 
  74     data = (mca_common_ompio_data_t *) fp->f_io_selected_data;
  75 
  76     /* we need to call the internal file set view twice: once for the individual
  77        file pointer, once for the shared file pointer (if it is existent)
  78     */
  79     fh = &data->ompio_fh;
  80   
  81     OPAL_THREAD_LOCK(&fp->f_lock);
  82     ret = mca_common_ompio_set_view(fh, disp, etype, filetype, datarep, info);
  83     OPAL_THREAD_UNLOCK(&fp->f_lock);
  84     return ret;
  85 }
  86 
  87 int mca_io_ompio_file_get_view (struct ompi_file_t *fp,
  88                                 OMPI_MPI_OFFSET_TYPE *disp,
  89                                 struct ompi_datatype_t **etype,
  90                                 struct ompi_datatype_t **filetype,
  91                                 char *datarep)
  92 {
  93     mca_common_ompio_data_t *data;
  94     ompio_file_t *fh;
  95 
  96     data = (mca_common_ompio_data_t *) fp->f_io_selected_data;
  97     fh = &data->ompio_fh;
  98 
  99     OPAL_THREAD_LOCK(&fp->f_lock);
 100     *disp = fh->f_disp;
 101     datatype_duplicate (fh->f_etype, etype);
 102     datatype_duplicate (fh->f_orig_filetype, filetype);
 103     strcpy (datarep, fh->f_datarep);
 104     OPAL_THREAD_UNLOCK(&fp->f_lock);
 105 
 106     return OMPI_SUCCESS;
 107 }
 108 

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