root/ompi/mca/io/romio321/romio/adio/ad_piofs/ad_piofs_hints.c

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

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_PIOFS_SetInfo

   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 "ad_piofs.h"
   9 
  10 void ADIOI_PIOFS_SetInfo(ADIO_File fd, MPI_Info users_info, int *error_code)
  11 {
  12     piofs_create_t piofs_create;
  13     piofs_statfs_t piofs_statfs;
  14     char *value, *path, *slash;
  15     int flag, tmp_val, str_factor=-1, str_unit=-1, start_iodev=-1;
  16     int err, myrank, perm, old_mask, nioservers;
  17 
  18     if ((fd->info) == MPI_INFO_NULL) {
  19         /* This must be part of the open call. can set striping parameters 
  20            if necessary. */ 
  21         MPI_Info_create(&(fd->info));
  22         
  23         /* has user specified striping parameters 
  24            and do they have the same value on all processes? */
  25         if (users_info != MPI_INFO_NULL) {
  26             value = (char *) ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char));
  27 
  28             ADIOI_Info_get(users_info, "striping_factor", MPI_MAX_INFO_VAL, 
  29                          value, &flag);
  30             if (flag) {
  31                 str_factor=atoi(value);
  32                 tmp_val = str_factor;
  33                 MPI_Bcast(&tmp_val, 1, MPI_INT, 0, fd->comm);
  34                 if (tmp_val != str_factor) {
  35                     FPRINTF(stderr, "ADIOI_PIOFS_SetInfo: the value for key \"striping_factor\" must be the same on all processes\n");
  36                     MPI_Abort(MPI_COMM_WORLD, 1);
  37                 }
  38             }
  39 
  40             ADIOI_Info_get(users_info, "striping_unit", MPI_MAX_INFO_VAL, 
  41                          value, &flag);
  42             if (flag) {
  43                 str_unit=atoi(value);
  44                 tmp_val = str_unit;
  45                 MPI_Bcast(&tmp_val, 1, MPI_INT, 0, fd->comm);
  46                 if (tmp_val != str_unit) {
  47                     FPRINTF(stderr, "ADIOI_PIOFS_SetInfo: the value for key \"striping_unit\" must be the same on all processes\n");
  48                     MPI_Abort(MPI_COMM_WORLD, 1);
  49                 }
  50             }
  51 
  52             ADIOI_Info_get(users_info, "start_iodevice", MPI_MAX_INFO_VAL, 
  53                          value, &flag);
  54             if (flag) {
  55                 start_iodev=atoi(value);
  56                 tmp_val = start_iodev;
  57                 MPI_Bcast(&tmp_val, 1, MPI_INT, 0, fd->comm);
  58                 if (tmp_val != start_iodev) {
  59                     FPRINTF(stderr, "ADIOI_PIOFS_SetInfo: the value for key \"start_iodevice\" must be the same on all processes\n");
  60                     MPI_Abort(MPI_COMM_WORLD, 1);
  61                 }
  62             }
  63 
  64             ADIOI_Free(value);
  65 
  66          /* if user has specified striping info, process 0 tries to set it */
  67             if ((str_factor > 0) || (str_unit > 0) || (start_iodev >= 0)) {
  68                 MPI_Comm_rank(fd->comm, &myrank);
  69                 if (!myrank) {
  70                     int len;
  71 
  72                     if (fd->perm == ADIO_PERM_NULL) {
  73                         old_mask = umask(022);
  74                         umask(old_mask);
  75                         perm = old_mask ^ 0666;
  76                     }
  77                     else perm = fd->perm;
  78 
  79                     /* to find out the number of I/O servers, I need
  80                        the path to the directory containing the file */
  81 
  82                     path = ADIOI_Strdup(fd->filename);
  83                     len = strlen(path) + 1;
  84                     slash = strrchr(path, '/');
  85                     if (!slash) ADIOI_Strncpy(path, ".", len);
  86                     else {
  87                         if (slash == path) *(path + 1) = '\0';
  88                         else *slash = '\0';
  89                     }
  90                     ADIOI_Strncpy(piofs_statfs.name, path, len);
  91                     err = piofsioctl(0, PIOFS_STATFS, &piofs_statfs);
  92                     nioservers = (err) ? -1 : piofs_statfs.f_nodes;
  93 
  94                     ADIOI_Free(path);
  95 
  96                     str_factor = ADIOI_MIN(nioservers, str_factor);
  97                     if (start_iodev >= nioservers) start_iodev = -1;
  98 
  99                     ADIOI_Strncpy(piofs_create.name, fd->filename, len);
 100                     piofs_create.bsu = (str_unit > 0) ? str_unit : -1;
 101                     piofs_create.cells = (str_factor > 0) ? str_factor : -1;
 102                     piofs_create.permissions = perm;
 103                     piofs_create.base_node = (start_iodev >= 0) ? 
 104                                                      start_iodev : -1;
 105                     piofs_create.flags = 0;
 106 
 107                     err = piofsioctl(0, PIOFS_CREATE, &piofs_create);
 108                 }
 109                 MPI_Barrier(fd->comm);
 110             }
 111         }
 112     }   
 113         
 114     /* set the values for collective I/O and data sieving parameters */
 115     ADIOI_GEN_SetInfo(fd, users_info, error_code);
 116 
 117     *error_code = MPI_SUCCESS;
 118 }

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