root/ompi/mca/io/romio321/src/io_romio321_component.c

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

DEFINITIONS

This source file includes following definitions.
  1. register_component
  2. open_component
  3. close_component
  4. init_query
  5. file_query
  6. file_unquery
  7. delete_query
  8. delete_select
  9. register_datarep

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2005 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2008-2015 Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2015      Los Alamos National Security, LLC. All rights
  15  *                         reserved.
  16  * Copyright (c) 2015-2017 Research Organization for Information Science
  17  *                         and Technology (RIST). All rights reserved.
  18  * Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
  19  * $COPYRIGHT$
  20  *
  21  * Additional copyrights may follow
  22  *
  23  * $HEADER$
  24  */
  25 
  26 #include "ompi_config.h"
  27 
  28 #include "mpi.h"
  29 #include "opal/class/opal_list.h"
  30 #include "opal/threads/mutex.h"
  31 #include "opal/mca/base/base.h"
  32 #include "ompi/mca/io/io.h"
  33 #include "io_romio321.h"
  34 
  35 #define ROMIO_VERSION_STRING "from MPICH v3.1.4"
  36 
  37 /*
  38  * Private functions
  39  */
  40 static int register_component(void);
  41 static int open_component(void);
  42 static int close_component(void);
  43 static int init_query(bool enable_progress_threads,
  44                       bool enable_mpi_threads);
  45 static const struct mca_io_base_module_2_0_0_t *
  46   file_query(struct ompi_file_t *file,
  47              struct mca_io_base_file_t **private_data,
  48              int *priority);
  49 static int file_unquery(struct ompi_file_t *file,
  50                         struct mca_io_base_file_t *private_data);
  51 
  52 static int delete_query(const char *filename, struct opal_info_t *info,
  53                         struct mca_io_base_delete_t **private_data,
  54                         bool *usable, int *priorty);
  55 static int delete_select(const char *filename, struct opal_info_t *info,
  56                          struct mca_io_base_delete_t *private_data);
  57 
  58 static int register_datarep(const char *,
  59                             MPI_Datarep_conversion_function*,
  60                             MPI_Datarep_conversion_function*,
  61                             MPI_Datarep_extent_function*,
  62                             void*);
  63 
  64 /*
  65  * Private variables
  66  */
  67 static int priority_param = 20;
  68 static int delete_priority_param = 20;
  69 
  70 
  71 /*
  72  * Global, component-wide ROMIO mutex because ROMIO is not thread safe
  73  */
  74 opal_mutex_t mca_io_romio321_mutex = {{0}};
  75 
  76 
  77 /*
  78  * Public string showing this component's version number
  79  */
  80 const char *mca_io_romio321_component_version_string =
  81 "OMPI/MPI ROMIO io MCA component version " OMPI_VERSION ", " ROMIO_VERSION_STRING;
  82 
  83 
  84 mca_io_base_component_2_0_0_t mca_io_romio321_component = {
  85     /* First, the mca_base_component_t struct containing meta information
  86        about the component itself */
  87 
  88     .io_version = {
  89         MCA_IO_BASE_VERSION_2_0_0,
  90         .mca_component_name = "romio321",
  91         MCA_BASE_MAKE_VERSION(component, OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION,
  92                               OMPI_RELEASE_VERSION),
  93         .mca_open_component = open_component,
  94         .mca_close_component = close_component,
  95         .mca_register_component_params = register_component,
  96     },
  97     .io_data = {
  98         /* The component is checkpoint ready */
  99         MCA_BASE_METADATA_PARAM_CHECKPOINT
 100     },
 101 
 102     /* Initial configuration / Open a new file */
 103 
 104     .io_init_query = init_query,
 105     .io_file_query = file_query,
 106     .io_file_unquery = file_unquery,
 107 
 108     /* Delete a file */
 109 
 110     .io_delete_query = delete_query,
 111     .io_delete_select = delete_select,
 112 
 113     .io_register_datarep = register_datarep,
 114 };
 115 
 116 static char *ompi_io_romio321_version = ROMIO_VERSION_STRING;
 117 static char *ompi_io_romio321_user_configure_params = MCA_io_romio321_USER_CONFIGURE_FLAGS;
 118 static char *ompi_io_romio321_complete_configure_params = MCA_io_romio321_COMPLETE_CONFIGURE_FLAGS;
 119 
 120 static int register_component(void)
 121 {
 122     /* Use a low priority, but allow other components to be lower */
 123     priority_param = 10;
 124     (void) mca_base_component_var_register(&mca_io_romio321_component.io_version,
 125                                            "priority", "Priority of the io romio component",
 126                                            MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
 127                                            OPAL_INFO_LVL_9,
 128                                            MCA_BASE_VAR_SCOPE_READONLY, &priority_param);
 129     delete_priority_param = 10;
 130     (void) mca_base_component_var_register(&mca_io_romio321_component.io_version,
 131                                            "delete_priority", "Delete priority of the io romio component",
 132                                            MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
 133                                            OPAL_INFO_LVL_9,
 134                                            MCA_BASE_VAR_SCOPE_READONLY, &delete_priority_param);
 135     (void) mca_base_component_var_register(&mca_io_romio321_component.io_version,
 136                                            "version", "Version of ROMIO", MCA_BASE_VAR_TYPE_STRING,
 137                                            NULL, 0, MCA_BASE_VAR_FLAG_DEFAULT_ONLY,
 138                                            OPAL_INFO_LVL_9,
 139                                            MCA_BASE_VAR_SCOPE_READONLY, &ompi_io_romio321_version);
 140     (void) mca_base_component_var_register(&mca_io_romio321_component.io_version,
 141                                            "user_configure_params",
 142                                            "User-specified command line parameters passed to ROMIO's configure script",
 143                                            MCA_BASE_VAR_TYPE_STRING, NULL, 0,
 144                                            MCA_BASE_VAR_FLAG_DEFAULT_ONLY,
 145                                            OPAL_INFO_LVL_9,
 146                                            MCA_BASE_VAR_SCOPE_READONLY, &ompi_io_romio321_user_configure_params);
 147     (void) mca_base_component_var_register(&mca_io_romio321_component.io_version,
 148                                            "complete_configure_params",
 149                                            "Complete set of command line parameters passed to ROMIO's configure script",
 150                                            MCA_BASE_VAR_TYPE_STRING, NULL, 0,
 151                                            MCA_BASE_VAR_FLAG_DEFAULT_ONLY,
 152                                            OPAL_INFO_LVL_9,
 153                                            MCA_BASE_VAR_SCOPE_READONLY, &ompi_io_romio321_complete_configure_params);
 154 
 155     return OMPI_SUCCESS;
 156 }
 157 
 158 static int open_component(void)
 159 {
 160     /* Create the mutex */
 161     OBJ_CONSTRUCT(&mca_io_romio321_mutex, opal_mutex_t);
 162 
 163     return OMPI_SUCCESS;
 164 }
 165 
 166 
 167 static int close_component(void)
 168 {
 169     OBJ_DESTRUCT(&mca_io_romio321_mutex);
 170 
 171     return OMPI_SUCCESS;
 172 }
 173 
 174 
 175 static int init_query(bool enable_progress_threads,
 176                       bool enable_mpi_threads)
 177 {
 178     /* Note that it's ok if mpi_enable_threads==true here because we
 179        self-enforce only allowing one user thread into ROMIO at a time
 180        -- this fact will be clearly documented for users (ROMIO itself
 181        is not thread safe). */
 182 
 183     return OMPI_SUCCESS;
 184 }
 185 
 186 
 187 static const struct mca_io_base_module_2_0_0_t *
 188 file_query(struct ompi_file_t *file,
 189            struct mca_io_base_file_t **private_data,
 190            int *priority)
 191 {
 192     mca_io_romio321_data_t *data;
 193 
 194     *priority = priority_param;
 195 
 196     /* Allocate a space for this module to hang private data (e.g.,
 197        the ROMIO file handle) */
 198 
 199     data = malloc(sizeof(mca_io_romio321_data_t));
 200     if (NULL == data) {
 201         return NULL;
 202     }
 203     data->romio_fh = NULL;
 204     *private_data = (struct mca_io_base_file_t*) data;
 205 
 206     /* All done */
 207 
 208     return &mca_io_romio321_module;
 209 }
 210 
 211 
 212 static int file_unquery(struct ompi_file_t *file,
 213                         struct mca_io_base_file_t *private_data)
 214 {
 215     /* Free the romio module-specific data that was allocated in
 216        _file_query(), above */
 217 
 218     if (NULL != private_data) {
 219         free(private_data);
 220     }
 221 
 222     return OMPI_SUCCESS;
 223 }
 224 
 225 
 226 static int delete_query(const char *filename, struct opal_info_t *info,
 227                         struct mca_io_base_delete_t **private_data,
 228                         bool *usable, int *priority)
 229 {
 230     *priority = delete_priority_param;
 231     *usable = true;
 232     *private_data = NULL;
 233 
 234     return OMPI_SUCCESS;
 235 }
 236 
 237 
 238 static int delete_select(const char *filename, struct opal_info_t *info,
 239                          struct mca_io_base_delete_t *private_data)
 240 {
 241     int ret;
 242 
 243 // An opal_info_t isn't a full ompi_info_t. so if we're using an MPI call
 244 // below with an MPI_Info, we need to create an equivalent MPI_Info. This
 245 // isn't ideal but it only happens a few places.
 246     ompi_info_t *ompi_info;
 247     ompi_info = OBJ_NEW(ompi_info_t);
 248     if (!ompi_info) { return(MPI_ERR_NO_MEM); }
 249     opal_info_t *opal_info = &(ompi_info->super);
 250     opal_info_dup (info, &opal_info);
 251 
 252     OPAL_THREAD_LOCK (&mca_io_romio321_mutex);
 253     ret = ROMIO_PREFIX(MPI_File_delete)(filename, ompi_info);
 254     OPAL_THREAD_UNLOCK (&mca_io_romio321_mutex);
 255 
 256     ompi_info_free(&ompi_info);
 257     return ret;
 258 }
 259 
 260 
 261 static int
 262 register_datarep(const char * datarep,
 263                  MPI_Datarep_conversion_function* read_fn,
 264                  MPI_Datarep_conversion_function* write_fn,
 265                  MPI_Datarep_extent_function* extent_fn,
 266                  void* state)
 267 {
 268     int ret;
 269 
 270     OPAL_THREAD_LOCK(&mca_io_romio321_mutex);
 271     ret = ROMIO_PREFIX(MPI_Register_datarep(datarep, read_fn, write_fn,
 272                                             extent_fn, state));
 273     OPAL_THREAD_UNLOCK(&mca_io_romio321_mutex);
 274 
 275     return ret;
 276 }

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