This source file includes following definitions.
- mca_sharedfp_sm_read
- mca_sharedfp_sm_read_ordered
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  23 #include "ompi_config.h"
  24 #include "sharedfp_sm.h"
  25 
  26 #include "mpi.h"
  27 #include "ompi/constants.h"
  28 #include "ompi/mca/sharedfp/sharedfp.h"
  29 #include "ompi/mca/sharedfp/base/base.h"
  30 
  31 int mca_sharedfp_sm_read ( ompio_file_t *fh,
  32                            void *buf, int count, MPI_Datatype datatype, MPI_Status *status)
  33 {
  34     int ret = OMPI_SUCCESS;
  35     OMPI_MPI_OFFSET_TYPE offset = 0;
  36     long bytesRequested = 0;
  37     size_t numofBytes;
  38 
  39     if( NULL == fh->f_sharedfp_data){
  40         opal_output(ompi_sharedfp_base_framework.framework_output,
  41                     "sharedfp_sm_read - module not initialized \n");
  42         return OMPI_ERROR;
  43     }
  44 
  45     
  46     opal_datatype_type_size ( &datatype->super, &numofBytes);
  47     bytesRequested = count * numofBytes;
  48 
  49     if ( mca_sharedfp_sm_verbose ) {
  50         opal_output(ompi_sharedfp_base_framework.framework_output,
  51                     "sharedfp_sm_read: Bytes Requested is %ld\n",bytesRequested);
  52     }
  53 
  54     
  55     ret = mca_sharedfp_sm_request_position(fh,bytesRequested,&offset);
  56     offset /= fh->f_etype_size;
  57 
  58     if (  -1 != ret ) {
  59         if ( mca_sharedfp_sm_verbose ) {
  60             opal_output(ompi_sharedfp_base_framework.framework_output,
  61                         "sharedfp_sm_read: Offset received is %lld\n",offset);
  62         }
  63 
  64         
  65         ret = mca_common_ompio_file_read_at(fh,offset,buf,count,datatype,status);
  66     }
  67 
  68     return ret;
  69 }
  70 
  71 int mca_sharedfp_sm_read_ordered (ompio_file_t *fh,
  72                                   void *buf,
  73                                   int count,
  74                                   struct ompi_datatype_t *datatype,
  75                                   ompi_status_public_t *status)
  76 {
  77     int ret = OMPI_SUCCESS;
  78     OMPI_MPI_OFFSET_TYPE offset = 0;
  79     long sendBuff = 0;
  80     long *buff=NULL;
  81     long offsetBuff;
  82     OMPI_MPI_OFFSET_TYPE offsetReceived = 0;
  83     long bytesRequested = 0;
  84     int recvcnt = 1, sendcnt = 1;
  85     size_t numofBytes;
  86     int i;
  87 
  88     if ( NULL == fh->f_sharedfp_data){
  89         opal_output(ompi_sharedfp_base_framework.framework_output,
  90                     "sharedfp_sm_read_ordered: module not initialized \n");
  91         return OMPI_ERROR;
  92     }
  93 
  94     
  95     opal_datatype_type_size ( &datatype->super, &numofBytes);
  96     sendBuff = count * numofBytes;
  97 
  98     if ( 0  == fh->f_rank ) {
  99         buff = (long*)malloc(sizeof(long) * fh->f_size);
 100         if (  NULL == buff )
 101             return OMPI_ERR_OUT_OF_RESOURCE;
 102     }
 103 
 104     ret = fh->f_comm->c_coll->coll_gather ( &sendBuff, 
 105                                             sendcnt, 
 106                                             OMPI_OFFSET_DATATYPE,
 107                                             buff, 
 108                                             recvcnt, 
 109                                             OMPI_OFFSET_DATATYPE, 
 110                                             0,
 111                                             fh->f_comm, 
 112                                             fh->f_comm->c_coll->coll_gather_module );
 113     if( OMPI_SUCCESS != ret){
 114         goto exit;
 115     }
 116 
 117     
 118 
 119 
 120     if (  0 == fh->f_rank ) {
 121         for (i = 0; i < fh->f_size ; i ++) {
 122             bytesRequested += buff[i];
 123             if ( mca_sharedfp_sm_verbose ) {
 124                 opal_output(ompi_sharedfp_base_framework.framework_output,
 125                             "mca_sharedfp_sm_read_ordered: Bytes requested are %ld\n",bytesRequested);
 126             }
 127         }
 128 
 129         
 130 
 131 
 132 
 133 
 134 
 135         ret = mca_sharedfp_sm_request_position(fh,bytesRequested,&offsetReceived);
 136         if( OMPI_SUCCESS != ret){
 137             goto exit;
 138         }
 139         if ( mca_sharedfp_sm_verbose ) {
 140             opal_output(ompi_sharedfp_base_framework.framework_output,
 141                         "mca_sharedfp_sm_read_ordered: Offset received is %lld\n",offsetReceived);
 142         }
 143 
 144         buff[0] += offsetReceived;
 145         for (i = 1 ; i < fh->f_size; i++)  {
 146             buff[i] += buff[i-1];
 147         }
 148     }
 149 
 150     
 151     ret = fh->f_comm->c_coll->coll_scatter ( buff, 
 152                                              sendcnt, 
 153                                              OMPI_OFFSET_DATATYPE,
 154                                              &offsetBuff, 
 155                                              recvcnt, 
 156                                              OMPI_OFFSET_DATATYPE, 
 157                                              0,
 158                                              fh->f_comm, 
 159                                              fh->f_comm->c_coll->coll_scatter_module );
 160     if( OMPI_SUCCESS != ret){
 161         goto exit;
 162     }
 163 
 164     
 165     offset = offsetBuff - sendBuff;
 166     offset /= fh->f_etype_size;
 167 
 168     if ( mca_sharedfp_sm_verbose ) {
 169         opal_output(ompi_sharedfp_base_framework.framework_output,
 170                     "mca_sharedfp_sm_read_ordered: Offset returned is %lld\n",offset);
 171     }
 172 
 173     
 174     ret = mca_common_ompio_file_read_at_all(fh,offset,buf,count,datatype,status);
 175 
 176 exit:
 177     if ( NULL != buff ) {
 178         free ( buff );
 179     }
 180 
 181     return ret;
 182 }