PEXSI
 All Classes Namespaces Files Functions Variables Typedefs Pages
pselinv_unsym.hpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012 The Regents of the University of California,
3  through Lawrence Berkeley National Laboratory.
4 
5  Authors: Lin Lin and Mathias Jacquelin
6 
7  This file is part of PEXSI. All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions are met:
11 
12  (1) Redistributions of source code must retain the above copyright notice, this
13  list of conditions and the following disclaimer.
14  (2) Redistributions in binary form must reproduce the above copyright notice,
15  this list of conditions and the following disclaimer in the documentation
16  and/or other materials provided with the distribution.
17  (3) Neither the name of the University of California, Lawrence Berkeley
18  National Laboratory, U.S. Dept. of Energy nor the names of its contributors may
19  be used to endorse or promote products derived from this software without
20  specific prior written permission.
21 
22  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
26  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33  You are under no obligation whatsoever to provide any bug fixes, patches, or
34  upgrades to the features, functionality or performance of the source code
35  ("Enhancements") to anyone; however, if you choose to make your Enhancements
36  available either publicly, or directly to Lawrence Berkeley National
37  Laboratory, without imposing a separate written license agreement for such
38  Enhancements, then you hereby grant the following license: a non-exclusive,
39  royalty-free perpetual license to install, use, modify, prepare derivative
40  works, incorporate into other computer software, distribute, and sublicense
41  such enhancements or derivative works thereof, in binary and source code form.
42 */
46 #ifndef _PEXSI_PSELINV_UNSYM_HPP_
47 #define _PEXSI_PSELINV_UNSYM_HPP_
48 
49 // *********************************************************************
50 // Common utilities
51 // *********************************************************************
52 
53 #include "pexsi/environment.hpp"
54 #include "pexsi/NumVec.hpp"
55 #include "pexsi/NumMat.hpp"
56 #include "pexsi/sparse_matrix.hpp"
57 
59 #include "pexsi/mpi_interf.hpp"
60 #include "pexsi/utility.hpp"
61 #include "pexsi/blas.hpp"
62 #include "pexsi/lapack.hpp"
63 #include "pexsi/pselinv.hpp"
64 
65 #include <set>
66 
67 
68 
69 namespace PEXSI{
70 
71 
72  struct CDBuffers;
73 
74  template<typename T>
75  bool LBlockEqualComparator(const LBlock<T> & a,const LBlock<T> & b){
76  return a.blockIdx==b.blockIdx;
77  }
78  template<typename T>
79  bool LBlockComparator(const LBlock<T> & a,const LBlock<T> & b){
80  return a.blockIdx<b.blockIdx;
81  }
82 
83  template<typename T>
84  bool UBlockComparator(const UBlock<T> & a,const UBlock<T> & b){
85  return a.blockIdx<b.blockIdx;
86  }
87 
88 
89 
90  /**********************************************************************
91  * Main data structure in PSelInv: PMatrixUnsym
92  **********************************************************************/
93 
155 
156  template<typename T>
157  class PMatrixUnsym: public PMatrix<T>{
158 
159  protected:
160  // *********************************************************************
161  // Variables
162  // *********************************************************************
163  // Data variables
164 
165  std::vector<std::vector<UBlock<T> > > Ucol_;
166  std::vector<std::vector<LBlock<T> > > Lrow_;
167 
168  std::vector<Int > UcolSize_;
169  std::vector<Int > LrowSize_;
170 
171  // Communication variables
172  // This is the tag used for mpi communication for selinv
173 
174  enum{
175  SELINV_TAG_U_SIZE,
176  SELINV_TAG_U_CONTENT,
177  SELINV_TAG_L_SIZE,
178  SELINV_TAG_L_CONTENT,
179  SELINV_TAG_UCOL_SIZE,
180  SELINV_TAG_UCOL_CONTENT,
181  SELINV_TAG_LROW_SIZE,
182  SELINV_TAG_LROW_CONTENT,
183  SELINV_TAG_L_REDUCE,
184  SELINV_TAG_U_REDUCE,
185  SELINV_TAG_D_SIZE,
186  SELINV_TAG_D_CONTENT,
187  SELINV_TAG_D_REDUCE,
188  SELINV_TAG_U_SIZE_CD,
189  SELINV_TAG_U_CONTENT_CD,
190  SELINV_TAG_L_SIZE_CD,
191  SELINV_TAG_L_CONTENT_CD,
192  SELINV_TAG_COUNT
193  };
194 
195 
196 
197 
199  NumMat<T> UUpdateBuf;
200  std::vector<Int> ColLocalPtr;
201  std::vector<Int> BlockIdxLocalU;
202  std::vector<char> SstrLrowSend;
203  std::vector<char> SstrUcolSend;
204  std::vector<char> SstrLrowRecv;
205  std::vector<char> SstrUcolRecv;
206  Int SizeSstrLrowSend;
207  Int SizeSstrUcolSend;
208  Int SizeSstrLrowRecv;
209  Int SizeSstrUcolRecv;
210  };
211 
213  inline void SelInvIntra_P2p(Int lidx);
214 
217  std::vector<LBlock<T> > & LcolRecv,
218  std::vector<LBlock<T> > & LrowRecv,
219  std::vector<UBlock<T> > & UcolRecv,
220  std::vector<UBlock<T> > & UrowRecv,
221  NumMat<T> & AinvBuf,
222  NumMat<T> & LBuf,
223  NumMat<T> & UBuf);
224 
226  inline void UnpackData( SuperNodeBufferTypeUnsym & snode,
227  std::vector<LBlock<T> > & LcolRecv,
228  std::vector<LBlock<T> > & LrowRecv,
229  std::vector<UBlock<T> > & UcolRecv,
230  std::vector<UBlock<T> > & UrowRecv
231  );
232 
234  inline void ComputeDiagUpdate(SuperNodeBufferTypeUnsym & snode);
235 
237  inline void SendRecvCD(
238  std::vector<SuperNodeBufferTypeUnsym > & arrSuperNodes,
239  Int stepSuper
240  );
241 
242 
243  inline void SendRecvSizesCD(std::vector<Int > & arrSuperNodes, Int stepSuper, CDBuffers & buffers);
244  inline void IRecvContentCD( std::vector<Int > & arrSuperNodes, Int stepSuper, CDBuffers & buffers);
245  inline void WaitContentLCD( std::vector<Int > & arrSuperNodes, Int stepSuper, CDBuffers & buffers);
246  inline void WaitContentUCD( std::vector<Int > & arrSuperNodes, Int stepSuper, CDBuffers & buffers);
247 
248 
249 
250 
251 
252 
253  public:
254  // *********************************************************************
255  // Public member functions
256  // *********************************************************************
257 
258  PMatrixUnsym():PMatrix<T>() {}
259 
260  PMatrixUnsym( const GridType* g, const SuperNodeType* s, const PEXSI::PSelInvOptions * o, const PEXSI::SuperLUOptions * oLU );
261 
262  //virtual ~PMatrixUnsym() { statusOFS<<"DESTRUCTOR UNSYM CALLED"<<std::endl; }
263 
264  void Setup( const GridType* g, const SuperNodeType* s, const PEXSI::PSelInvOptions * o, const PEXSI::SuperLUOptions * oLU );
265 
268  //Int NumBlockL( Int jLocal ) const { return L_[jLocal].size(); }
269 
272  //Int NumBlockU( Int iLocal ) const { return U_[iLocal].size(); }
273 
274 
277  std::vector<LBlock<T> >& Lrow( Int iLocal ) { return Lrow_[iLocal]; }
278 
281  std::vector<UBlock<T> >& Ucol( Int jLocal ) { return Ucol_[jLocal]; }
282 
283 
288  virtual void ConstructCommunicationPattern( );
289 
290 
295 
296 
325  virtual void PreSelInv( );
326 
443  virtual void SelInv( );
444 
446  void SelInv_P2p( );
447 
448  };
449 
450 
451 
452 } // namespace PEXSI
453 
454 
456 
457 #endif //_PEXSI_PSELINV_UNSYM_HPP_
void UnpackData(SuperNodeBufferTypeUnsym &snode, std::vector< LBlock< T > > &LcolRecv, std::vector< LBlock< T > > &LrowRecv, std::vector< UBlock< T > > &UcolRecv, std::vector< UBlock< T > > &UrowRecv)
UnpackData.
Definition: pselinv_unsym_impl.hpp:1727
Environmental variables.
void SelInvIntra_P2p(Int lidx)
SelInvIntra_P2p.
Definition: pselinv_unsym_impl.hpp:1925
A thin interface for passing parameters to set the SuperLU options.
Definition: superlu_dist_internal.hpp:62
void ComputeDiagUpdate(SuperNodeBufferTypeUnsym &snode)
ComputeDiagUpdate.
Definition: pselinv_unsym_impl.hpp:1862
SuperNodeType describes mapping between supernode and column, the permutation information, and potentially the elimination tree (not implemented here).
Definition: pselinv.hpp:165
Interface with SuperLU_Dist (version 3.0 and later)
Thin interface to LAPACK.
void SelInv_lookup_indexes(SuperNodeBufferTypeUnsym &snode, std::vector< LBlock< T > > &LcolRecv, std::vector< LBlock< T > > &LrowRecv, std::vector< UBlock< T > > &UcolRecv, std::vector< UBlock< T > > &UrowRecv, NumMat< T > &AinvBuf, NumMat< T > &LBuf, NumMat< T > &UBuf)
SelInv_lookup_indexes.
Definition: pselinv_unsym_impl.hpp:112
Main file for parallel selected inversion.
Definition: pselinv.hpp:598
Definition: pselinv_unsym_impl.hpp:434
LBlock stores a nonzero block in the lower triangular part or the diagonal part in PSelInv...
Definition: pselinv.hpp:181
Sparse matrix and Distributed sparse matrix in compressed column format.
GridType is the PSelInv way of defining the grid.
Definition: pselinv.hpp:128
Numerical matrix.
Interface with MPI to facilitate communication.
std::vector< LBlock< T > > & Lrow(Int iLocal)
NumBlockL returns the number of nonzero L blocks for the local block column jLocal.
Definition: pselinv_unsym.hpp:277
Various utility subroutines.
virtual void ConstructCommunicationPattern()
ConstructCommunicationPattern constructs the communication pattern to be used later in the selected i...
Definition: pselinv_unsym_impl.hpp:3557
Implementation of the parallel SelInv.
UBlock stores a nonzero block in the upper triangular part in PSelInv.
Definition: pselinv.hpp:233
Definition: pselinv_unsym.hpp:198
Thin interface to BLAS.
PMatrix contains the main data structure and the computational routine for the parallel selected inve...
Definition: ngchol_interf.hpp:57
void SendRecvCD(std::vector< SuperNodeBufferTypeUnsym > &arrSuperNodes, Int stepSuper)
SendRecvCD_UpdateU.
Definition: pselinv_unsym_impl.hpp:1124
std::vector< UBlock< T > > & Ucol(Int jLocal)
Ucol returns the vector of nonzero U blocks for the local block col jLocal.
Definition: pselinv_unsym.hpp:281
virtual void SelInv()
SelInv is the main function for the selected inversion.
Definition: pselinv_unsym_impl.hpp:3258
void ConstructCommunicationPattern_P2p()
ConstructCommunicationPattern_P2p constructs the communication pattern to be used later in the select...
Definition: pselinv_unsym_impl.hpp:3565
Numerical vector.
A thin interface for passing parameters to set the PSelInv options.
Definition: pselinv.hpp:101
virtual void PreSelInv()
PreSelInv prepares the structure in L_ and U_ so that SelInv only involves matrix-matrix multiplicati...
Definition: pselinv_unsym_impl.hpp:3306
void SelInv_P2p()
Point-to-point version of the selected inversion.
Definition: pselinv_unsym_impl.hpp:3264
PMatrixUnsym contains the main data structure and the computational routine for the parallel selected...
Definition: pselinv.hpp:978