root/ompi/mpi/cxx/request_inln.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. Wait
  2. Wait
  3. Free
  4. Test
  5. Test
  6. Waitany
  7. Waitany
  8. Testany
  9. Testany
  10. Waitall
  11. Waitall
  12. Testall
  13. Testall
  14. Waitsome
  15. Waitsome
  16. Testsome
  17. Testsome
  18. Cancel
  19. Start
  20. Startall
  21. Get_status
  22. Get_status
  23. Start
  24. Complete

   1 // -*- c++ -*-
   2 //
   3 // Copyright (c) 2004-2005 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) 2006-2008 Cisco Systems, Inc.  All rights reserved.
  14 // Copyright (c) 2007      Sun Microsystems, Inc.  All rights reserved.
  15 // $COPYRIGHT$
  16 //
  17 // Additional copyrights may follow
  18 //
  19 // $HEADER$
  20 //
  21 
  22 //
  23 // Point-to-Point Communication
  24 //
  25 
  26 inline void
  27 MPI::Request::Wait(MPI::Status &status)
  28 {
  29   (void)MPI_Wait(&mpi_request, &status.mpi_status);
  30 }
  31 
  32 inline void
  33 MPI::Request::Wait()
  34 {
  35   (void)MPI_Wait(&mpi_request, MPI_STATUS_IGNORE);
  36 }
  37 
  38 inline void
  39 MPI::Request::Free()
  40 {
  41   (void)MPI_Request_free(&mpi_request);
  42 }
  43 
  44 inline bool
  45 MPI::Request::Test(MPI::Status &status)
  46 {
  47   int t;
  48   (void)MPI_Test(&mpi_request, &t, &status.mpi_status);
  49   return OPAL_INT_TO_BOOL(t);
  50 }
  51 
  52 inline bool
  53 MPI::Request::Test()
  54 {
  55   int t;
  56   (void)MPI_Test(&mpi_request, &t, MPI_STATUS_IGNORE);
  57   return OPAL_INT_TO_BOOL(t);
  58 }
  59 
  60 inline int
  61 MPI::Request::Waitany(int count, MPI::Request array[],
  62                              MPI::Status& status)
  63 {
  64   int index, i;
  65   MPI_Request* array_of_requests = new MPI_Request[count];
  66   for (i=0; i < count; i++) {
  67     array_of_requests[i] = array[i];
  68   }
  69   (void)MPI_Waitany(count, array_of_requests, &index, &status.mpi_status);
  70   for (i=0; i < count; i++) {
  71     array[i] = array_of_requests[i];
  72   }
  73   delete [] array_of_requests;
  74   return index;
  75 }
  76 
  77 inline int
  78 MPI::Request::Waitany(int count, MPI::Request array[])
  79 {
  80   int index, i;
  81   MPI_Request* array_of_requests = new MPI_Request[count];
  82   for (i=0; i < count; i++) {
  83     array_of_requests[i] = array[i];
  84   }
  85   (void)MPI_Waitany(count, array_of_requests, &index, MPI_STATUS_IGNORE);
  86   for (i=0; i < count; i++) {
  87     array[i] = array_of_requests[i];
  88   }
  89   delete [] array_of_requests;
  90   return index; //JGS, Waitany return value
  91 }
  92 
  93 inline bool
  94 MPI::Request::Testany(int count, MPI::Request array[],
  95                              int& index, MPI::Status& status)
  96 {
  97   int i, flag;
  98   MPI_Request* array_of_requests = new MPI_Request[count];
  99   for (i=0; i < count; i++) {
 100     array_of_requests[i] = array[i];
 101   }
 102   (void)MPI_Testany(count, array_of_requests, &index, &flag, &status.mpi_status);
 103   for (i=0; i < count; i++) {
 104     array[i] = array_of_requests[i];
 105   }
 106   delete [] array_of_requests;
 107   return (bool)(flag != 0 ? true : false);
 108 }
 109 
 110 inline bool
 111 MPI::Request::Testany(int count, MPI::Request array[], int& index)
 112 {
 113   int i, flag;
 114   MPI_Request* array_of_requests = new MPI_Request[count];
 115   for (i=0; i < count; i++) {
 116     array_of_requests[i] = array[i];
 117   }
 118   (void)MPI_Testany(count, array_of_requests, &index, &flag,
 119                     MPI_STATUS_IGNORE);
 120   for (i=0; i < count; i++) {
 121     array[i] = array_of_requests[i];
 122   }
 123   delete [] array_of_requests;
 124   return OPAL_INT_TO_BOOL(flag);
 125 }
 126 
 127 inline void
 128 MPI::Request::Waitall(int count, MPI::Request req_array[],
 129                              MPI::Status stat_array[])
 130 {
 131   int i;
 132   MPI_Request* array_of_requests = new MPI_Request[count];
 133   MPI_Status* array_of_statuses = new MPI_Status[count];
 134   for (i=0; i < count; i++) {
 135     array_of_requests[i] = req_array[i];
 136   }
 137   (void)MPI_Waitall(count, array_of_requests, array_of_statuses);
 138   for (i=0; i < count; i++) {
 139     req_array[i] = array_of_requests[i];
 140     stat_array[i] = array_of_statuses[i];
 141   }
 142   delete [] array_of_requests;
 143   delete [] array_of_statuses;
 144 }
 145 
 146 inline void
 147 MPI::Request::Waitall(int count, MPI::Request req_array[])
 148 {
 149   int i;
 150   MPI_Request* array_of_requests = new MPI_Request[count];
 151 
 152   for (i=0; i < count; i++) {
 153     array_of_requests[i] = req_array[i];
 154   }
 155   (void)MPI_Waitall(count, array_of_requests, MPI_STATUSES_IGNORE);
 156 
 157   for (i=0; i < count; i++) {
 158     req_array[i] = array_of_requests[i];
 159   }
 160 
 161   delete [] array_of_requests;
 162 }
 163 
 164 inline bool
 165 MPI::Request::Testall(int count, MPI::Request req_array[],
 166                              MPI::Status stat_array[])
 167 {
 168   int i, flag;
 169   MPI_Request* array_of_requests = new MPI_Request[count];
 170   MPI_Status* array_of_statuses = new MPI_Status[count];
 171   for (i=0; i < count; i++) {
 172     array_of_requests[i] = req_array[i];
 173   }
 174   (void)MPI_Testall(count, array_of_requests, &flag, array_of_statuses);
 175   for (i=0; i < count; i++) {
 176     req_array[i] = array_of_requests[i];
 177     stat_array[i] = array_of_statuses[i];
 178   }
 179   delete [] array_of_requests;
 180   delete [] array_of_statuses;
 181   return OPAL_INT_TO_BOOL(flag);
 182 }
 183 
 184 inline bool
 185 MPI::Request::Testall(int count, MPI::Request req_array[])
 186 {
 187   int i, flag;
 188   MPI_Request* array_of_requests = new MPI_Request[count];
 189 
 190   for (i=0; i < count; i++) {
 191     array_of_requests[i] = req_array[i];
 192   }
 193   (void)MPI_Testall(count, array_of_requests, &flag, MPI_STATUSES_IGNORE);
 194 
 195   for (i=0; i < count; i++) {
 196     req_array[i] = array_of_requests[i];
 197   }
 198   delete [] array_of_requests;
 199 
 200   return OPAL_INT_TO_BOOL(flag);
 201 }
 202 
 203 inline int
 204 MPI::Request::Waitsome(int incount, MPI::Request req_array[],
 205                               int array_of_indices[], MPI::Status stat_array[])
 206 {
 207   int i, outcount;
 208   MPI_Request* array_of_requests = new MPI_Request[incount];
 209   MPI_Status* array_of_statuses = new MPI_Status[incount];
 210   for (i=0; i < incount; i++) {
 211     array_of_requests[i] = req_array[i];
 212   }
 213   (void)MPI_Waitsome(incount, array_of_requests, &outcount,
 214                      array_of_indices, array_of_statuses);
 215   for (i=0; i < incount; i++) {
 216     req_array[i] = array_of_requests[i];
 217     stat_array[i] = array_of_statuses[i];
 218   }
 219   delete [] array_of_requests;
 220   delete [] array_of_statuses;
 221   return outcount;
 222 }
 223 
 224 inline int
 225 MPI::Request::Waitsome(int incount, MPI::Request req_array[],
 226                               int array_of_indices[])
 227 {
 228   int i, outcount;
 229   MPI_Request* array_of_requests = new MPI_Request[incount];
 230 
 231   for (i=0; i < incount; i++) {
 232     array_of_requests[i] = req_array[i];
 233   }
 234   (void)MPI_Waitsome(incount, array_of_requests, &outcount,
 235                      array_of_indices, MPI_STATUSES_IGNORE);
 236 
 237   for (i=0; i < incount; i++) {
 238     req_array[i] = array_of_requests[i];
 239   }
 240   delete [] array_of_requests;
 241 
 242   return outcount;
 243 }
 244 
 245 inline int
 246 MPI::Request::Testsome(int incount, MPI::Request req_array[],
 247                               int array_of_indices[], MPI::Status stat_array[])
 248 {
 249   int i, outcount;
 250   MPI_Request* array_of_requests = new MPI_Request[incount];
 251   MPI_Status* array_of_statuses = new MPI_Status[incount];
 252   for (i=0; i < incount; i++) {
 253     array_of_requests[i] = req_array[i];
 254   }
 255   (void)MPI_Testsome(incount, array_of_requests, &outcount,
 256                      array_of_indices, array_of_statuses);
 257   for (i=0; i < incount; i++) {
 258     req_array[i] = array_of_requests[i];
 259     stat_array[i] = array_of_statuses[i];
 260   }
 261   delete [] array_of_requests;
 262   delete [] array_of_statuses;
 263   return outcount;
 264 }
 265 
 266 inline int
 267 MPI::Request::Testsome(int incount, MPI::Request req_array[],
 268                               int array_of_indices[])
 269 {
 270   int i, outcount;
 271   MPI_Request* array_of_requests = new MPI_Request[incount];
 272 
 273   for (i=0; i < incount; i++) {
 274     array_of_requests[i] = req_array[i];
 275   }
 276   (void)MPI_Testsome(incount, array_of_requests, &outcount,
 277                      array_of_indices, MPI_STATUSES_IGNORE);
 278 
 279   for (i=0; i < incount; i++) {
 280     req_array[i] = array_of_requests[i];
 281   }
 282   delete [] array_of_requests;
 283 
 284   return outcount;
 285 }
 286 
 287 inline void
 288 MPI::Request::Cancel(void) const
 289 {
 290   (void)MPI_Cancel(const_cast<MPI_Request *>(&mpi_request));
 291 }
 292 
 293 inline void
 294 MPI::Prequest::Start()
 295 {
 296   (void)MPI_Start(&mpi_request);
 297 }
 298 
 299 inline void
 300 MPI::Prequest::Startall(int count, MPI:: Prequest array_of_requests[])
 301 {
 302   //convert the array of Prequests to an array of MPI_requests
 303   MPI_Request* mpi_requests = new MPI_Request[count];
 304   int i;
 305   for (i=0; i < count; i++) {
 306     mpi_requests[i] = array_of_requests[i];
 307   }
 308   (void)MPI_Startall(count, mpi_requests);
 309   for (i=0; i < count; i++) {
 310     array_of_requests[i].mpi_request = mpi_requests[i] ;
 311   }
 312   delete [] mpi_requests;
 313 }
 314 
 315 inline bool MPI::Request::Get_status(MPI::Status& status) const
 316 {
 317     int flag = 0;
 318     MPI_Status c_status;
 319 
 320     // Call the underlying MPI function rather than simply returning
 321     // status.mpi_status because we may have to invoke the generalized
 322     // request query function
 323     (void)MPI_Request_get_status(mpi_request, &flag, &c_status);
 324     if (flag) {
 325         status = c_status;
 326     }
 327     return OPAL_INT_TO_BOOL(flag);
 328 }
 329 
 330 inline bool MPI::Request::Get_status() const
 331 {
 332     int flag;
 333 
 334     // Call the underlying MPI function rather than simply returning
 335     // status.mpi_status because we may have to invoke the generalized
 336     // request query function
 337     (void)MPI_Request_get_status(mpi_request, &flag, MPI_STATUS_IGNORE);
 338     return OPAL_INT_TO_BOOL(flag);
 339 }
 340 
 341 inline MPI::Grequest
 342 MPI::Grequest::Start(Query_function *query_fn, Free_function *free_fn,
 343         Cancel_function *cancel_fn, void *extra)
 344 {
 345     MPI_Request grequest = 0;
 346     Intercept_data_t *new_extra =
 347         new MPI::Grequest::Intercept_data_t;
 348 
 349     new_extra->id_extra = extra;
 350     new_extra->id_cxx_query_fn = query_fn;
 351     new_extra->id_cxx_free_fn = free_fn;
 352     new_extra->id_cxx_cancel_fn = cancel_fn;
 353     (void) MPI_Grequest_start(ompi_mpi_cxx_grequest_query_fn_intercept,
 354                               ompi_mpi_cxx_grequest_free_fn_intercept,
 355                               ompi_mpi_cxx_grequest_cancel_fn_intercept,
 356                               new_extra, &grequest);
 357 
 358     return(grequest);
 359 }
 360 
 361 inline void
 362 MPI::Grequest::Complete()
 363 {
 364     (void) MPI_Grequest_complete(mpi_request);
 365 }
 366 

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