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 2011 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 
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 
00098   int CreateFromSends( const int & NumExportIDs,
00099                        const int * ExportPIDs,
00100            bool Deterministic,
00101                        int & NumRemoteIDs );
00102 
00127   int CreateFromRecvs( const int & NumRemoteIDs,
00128                        const int * RemoteGIDs,
00129                        const int * RemotePIDs,
00130            bool Deterministic,
00131                        int & NumExportIDs,
00132                        int *& ExportGIDs,
00133                        int *& ExportPIDs);
00135 
00137 
00138 
00140   int Do( char * export_objs,
00141           int obj_size,
00142           int & len_import_objs,
00143           char *& import_objs );
00144 
00146   int DoReverse( char * export_objs,
00147                  int obj_size,
00148                  int & len_import_objs,
00149                  char *& import_objs );
00150 
00152   int DoPosts( char * export_objs,
00153                int obj_size,
00154                int & len_import_objs,
00155                char *& import_objs );
00157   int DoWaits();
00158 
00160   int DoReversePosts( char * export_objs,
00161                       int obj_size,
00162                       int & len_import_objs,
00163                       char *& import_objs );
00164 
00166   int DoReverseWaits();
00168 
00170 
00171 
00173   int Do( char * export_objs,
00174           int obj_size,
00175           int *& sizes,
00176           int & len_import_objs,
00177           char *& import_objs );
00178   
00180   int DoReverse( char * export_objs,
00181                  int obj_size,
00182                  int *& sizes,
00183                  int & len_import_objs,
00184                  char *& import_objs );
00185   
00187   int DoPosts( char * export_objs,
00188                int obj_size,
00189                int *& sizes,
00190                int & len_import_objs,
00191                char *& import_objs);
00192   
00194   int DoReversePosts( char * export_objs,
00195                       int obj_size,
00196                       int *& sizes,
00197                       int & len_import_objs,
00198                       char *& import_objs );
00200   
00201 
00203 
00204 
00205   int NumReceives() const {return nrecvs_;}
00206 
00208   int NumSends() const {return nsends_;}
00209 
00211   int MaxSendLength() const {return max_send_length_;}
00212 
00214   int TotalReceiveLength() const { return total_recv_length_;}
00215 
00217   const int * ProcsFrom() const {return procs_from_;}
00218   
00220   const int * ProcsTo() const {return procs_to_;}
00221 
00223 
00224   const int * LengthsFrom() const {return lengths_from_;}
00225 
00227 
00228   const int * LengthsTo() const {return lengths_to_;}
00229 
00231 
00233 
00234   void Print(ostream & os) const;
00236   private:
00237 
00238     int ComputeRecvs_( int my_proc,
00239                  int nprocs );
00240 
00241     int ComputeSends_( int num_imports,
00242            const int *& import_ids,
00243            const int *& import_procs,
00244            int & num_exports,
00245            int *& export_ids,
00246            int *& export_procs,
00247            int my_proc );
00248 
00249 
00250     int Resize_(int *sizes);
00251 
00252     int Sort_ints_( int *vals, int *other, int nvals );
00253 
00254   private:
00255     Epetra_MpiDistributor& operator=(const Epetra_MpiDistributor& src);
00256 
00257     int * lengths_to_;
00258     int * procs_to_;
00259     int * indices_to_;
00260     int   size_indices_to_;
00261 
00262     int * lengths_from_;
00263     int * procs_from_;
00264     int * indices_from_;
00265     int   size_indices_from_;
00266 
00267     bool  resized_;
00268     int * sizes_;
00269 
00270     int * sizes_to_;
00271     int * starts_to_;
00272     int * starts_to_ptr_;
00273     int * indices_to_ptr_;
00274 
00275     int * sizes_from_;
00276     int * starts_from_;
00277     int * starts_from_ptr_;
00278     int * indices_from_ptr_;
00279 
00280     int   nrecvs_;
00281     int   nsends_;
00282     int   nexports_;
00283 
00284     int   self_msg_;
00285 
00286     int   max_send_length_;
00287     int   total_recv_length_;
00288 
00289     int   tag_;
00290 
00291     const Epetra_MpiComm * epComm_;
00292     const MPI_Comm      comm_;
00293 
00294     MPI_Request * request_;
00295     MPI_Status  * status_;
00296 
00297     bool no_delete_;
00298 
00299     char * send_array_;
00300     int send_array_size_;
00301 
00302     Epetra_MpiDistributor * comm_plan_reverse_;
00303 
00304 };
00305 #endif /* EPETRA_MPIDISTRIBUTOR_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines