Epetra Package Browser (Single Doxygen Collection) Development
Epetra_MpiDistributor.h
Go to the documentation of this file.
00001 /*
00002 //@HEADER
00003 // ************************************************************************
00004 // 
00005 //               Epetra: Linear Algebra Services Package 
00006 //                 Copyright 2001 Sandia Corporation
00007 // 
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00039 // 
00040 // ************************************************************************
00041 //@HEADER
00042 */
00043 
00044 #ifndef EPETRA_MPIDISTRIBUTOR_H
00045 #define EPETRA_MPIDISTRIBUTOR_H
00046 #include "Epetra_Object.h"
00047 #include "Epetra_Distributor.h"
00048 class Epetra_MpiComm;
00049 #include <mpi.h>
00050 
00052 
00059 class Epetra_MpiDistributor: public Epetra_Object, public virtual Epetra_Distributor {
00060     
00061   public:
00062 
00064 
00065 
00067   Epetra_MpiDistributor(const Epetra_MpiComm & Comm);
00068 
00070   Epetra_MpiDistributor(const Epetra_MpiDistributor & Distributor);
00071 
00073   Epetra_Distributor * Clone(){return(dynamic_cast<Epetra_Distributor *>(new Epetra_MpiDistributor(*this)));};
00074 
00076   virtual ~Epetra_MpiDistributor();
00078 
00079   
00081 
00082 
00083 
00094   int CreateFromSends( const int & NumExportIDs,
00095                        const int * ExportPIDs,
00096            bool Deterministic,
00097                        int & NumRemoteIDs );
00098 
00100 
00117   int CreateFromRecvs( const int & NumRemoteIDs,
00118                        const int * RemoteGIDs,
00119                        const int * RemotePIDs,
00120            bool Deterministic,
00121                        int & NumExportIDs,
00122                        int *& ExportGIDs,
00123                        int *& ExportPIDs);
00125 
00127 
00128 
00130   int Do( char * export_objs,
00131           int obj_size,
00132           int & len_import_objs,
00133           char *& import_objs );
00134 
00136   int DoReverse( char * export_objs,
00137                  int obj_size,
00138                  int & len_import_objs,
00139                  char *& import_objs );
00140 
00142   int DoPosts( char * export_objs,
00143                int obj_size,
00144                int & len_import_objs,
00145                char *& import_objs );
00147   int DoWaits();
00148 
00150   int DoReversePosts( char * export_objs,
00151                       int obj_size,
00152                       int & len_import_objs,
00153                       char *& import_objs );
00154 
00156   int DoReverseWaits();
00158 
00160 
00161 
00163   int Do( char * export_objs,
00164           int obj_size,
00165           int *& sizes,
00166           int & len_import_objs,
00167           char *& import_objs );
00168   
00170   int DoReverse( char * export_objs,
00171                  int obj_size,
00172                  int *& sizes,
00173                  int & len_import_objs,
00174                  char *& import_objs );
00175   
00177   int DoPosts( char * export_objs,
00178                int obj_size,
00179                int *& sizes,
00180                int & len_import_objs,
00181                char *& import_objs);
00182   
00184   int DoReversePosts( char * export_objs,
00185                       int obj_size,
00186                       int *& sizes,
00187                       int & len_import_objs,
00188                       char *& import_objs );
00190   
00192 
00193   void Print(ostream & os) const;
00195   private:
00196 
00197     int ComputeRecvs_( int my_proc,
00198                  int nprocs );
00199 
00200     int ComputeSends_( int num_imports,
00201            const int *& import_ids,
00202            const int *& import_procs,
00203            int & num_exports,
00204            int *& export_ids,
00205            int *& export_procs,
00206            int my_proc );
00207 
00208 
00209     int Resize_(int *sizes);
00210 
00211     int Sort_ints_( int *vals, int *other, int nvals );
00212 
00213   private:
00214     Epetra_MpiDistributor& operator=(const Epetra_MpiDistributor& src);
00215 
00216     int * lengths_to_;
00217     int * procs_to_;
00218     int * indices_to_;
00219     int   size_indices_to_;
00220 
00221     int * lengths_from_;
00222     int * procs_from_;
00223     int * indices_from_;
00224     int   size_indices_from_;
00225 
00226     bool  resized_;
00227     int * sizes_;
00228 
00229     int * sizes_to_;
00230     int * starts_to_;
00231     int * starts_to_ptr_;
00232     int * indices_to_ptr_;
00233 
00234     int * sizes_from_;
00235     int * starts_from_;
00236     int * starts_from_ptr_;
00237     int * indices_from_ptr_;
00238 
00239     int   nrecvs_;
00240     int   nsends_;
00241     int   nexports_;
00242 
00243     int   self_msg_;
00244 
00245     int   max_send_length_;
00246     int   total_recv_length_;
00247 
00248     int   tag_;
00249 
00250     const Epetra_MpiComm * epComm_;
00251     const MPI_Comm      comm_;
00252 
00253     MPI_Request * request_;
00254     MPI_Status  * status_;
00255 
00256     bool no_delete_;
00257 
00258     char * send_array_;
00259     int send_array_size_;
00260 
00261     Epetra_MpiDistributor * comm_plan_reverse_;
00262 
00263 };
00264 #endif /* EPETRA_MPIDISTRIBUTOR_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines