namespace map { DefaultGrid const GridRepo::mDefault = DefaultGrid(); GridRepo::GridRepo() : Repository<IGrid>( mDefault ) { int32_t id = AutoId( "absolute" ); mElements.insert( id, new AbsoluteGrid( AutoId( "absolute" ) ) ); id = AutoId( "matrix" ); mElements.insert( id, new MatrixGrid( AutoId( "matrix" ) ) ); } void DefaultGrid::Update( double DeltaTime ) { } DefaultGrid::DefaultGrid() : IGrid( -1 ) { } } // namespace map
// entire process grid if and only if the dimensions of the process grid // are coprime. template<typename T> class DistMatrix<T,STAR,MD> : public AbstractDistMatrix<T> { public: // Typedefs // ======== typedef AbstractDistMatrix<T> absType; typedef DistMatrix<T,STAR,MD> type; // Constructors and destructors // ============================ // Create a 0 x 0 distributed matrix DistMatrix( const El::Grid& g=DefaultGrid(), int root=0 ); // Create a height x width distributed matrix DistMatrix ( Int height, Int width, const El::Grid& g=DefaultGrid(), int root=0 ); // Create a copy of distributed matrix A DistMatrix( const type& A ); DistMatrix( const absType& A ); template<Dist U,Dist V> DistMatrix( const DistMatrix<T,U,V>& A ); template<Dist U,Dist V> DistMatrix( const BlockDistMatrix<T,U,V>& A ); // Move constructor DistMatrix( type&& A ) EL_NOEXCEPT; ~DistMatrix(); DistMatrix<T,STAR,MD>* Construct ( const El::Grid& g, int root ) const override; DistMatrix<T,MD,STAR>* ConstructTranspose
#ifndef ELEM_CORE_DISTMATRIX_VC_STAR_DECL_HPP #define ELEM_CORE_DISTMATRIX_VC_STAR_DECL_HPP namespace elem { // Partial specialization to A[VC,* ]. // // The columns of these distributed matrices are spread throughout the // process grid in a column-major fashion, while the rows are not // distributed. template<typename T> class DistMatrix<T,VC,STAR> : public AbstractDistMatrix<T> { public: // Create a 0 x 0 distributed matrix DistMatrix( const elem::Grid& g=DefaultGrid() ); // Create a height x width distributed matrix DistMatrix( Int height, Int width, const elem::Grid& g=DefaultGrid() ); // Create a height x width distributed matrix with specified alignments DistMatrix ( Int height, Int width, Int colAlignment, const elem::Grid& g ); // Create a height x width distributed matrix with specified alignments // and leading dimension DistMatrix ( Int height, Int width, Int colAlignment, Int ldim, const elem::Grid& g ); // View a constant distributed matrix's buffer
void UpdateRealPartOfDiagonal ( BASE(T) alpha, const DistMatrix<BASE(T),UDiag,VDiag>& d, Int offset=0 ); void UpdateImagPartOfDiagonal ( BASE(T) alpha, const DistMatrix<BASE(T),UDiag,VDiag>& d, Int offset=0 ); #endif // ifndef SWIG protected: // Private constructors // ==================== // Inherited constructors are part of C++11 but not yet widely supported. //using AbstractDistMatrix<T>::AbstractDistMatrix; // Create a 0 x 0 distributed matrix GeneralDistMatrix( const elem::Grid& g=DefaultGrid(), Int root=0 ); // Diagonal helper routines // ======================== #ifndef SWIG template<typename S,class Function> void GetDiagonalHelper ( DistMatrix<S,UDiag,VDiag>& d, Int offset, Function func ) const; template<typename S,class Function> void SetDiagonalHelper ( const DistMatrix<S,UDiag,VDiag>& d, Int offset, Function func ); #endif // ifndef SWIG // Friend declarations // =================== #ifndef SWIG
class AbstractDistMatrix { public: // Typedefs // ======== typedef AbstractDistMatrix<T> type; // Constructors and destructors // ============================ // Move constructor AbstractDistMatrix( type&& A ) EL_NOEXCEPT; virtual ~AbstractDistMatrix(); virtual AbstractDistMatrix<T>* Construct ( const El::Grid& g=DefaultGrid(), Int root=0 ) const = 0; virtual AbstractDistMatrix<T>* ConstructTranspose ( const El::Grid& g=DefaultGrid(), Int root=0 ) const = 0; virtual AbstractDistMatrix<T>* ConstructDiagonal ( const El::Grid& g=DefaultGrid(), Int root=0 ) const = 0; // TODO: ConstructPartialCol and friends? // Assignment and reconfiguration // ============================== // Move assignment type& operator=( type&& A ); void Empty(); void EmptyData(); void SetGrid( const El::Grid& grid ); void Resize( Int height, Int width );
Int GlobalCol( Int jLoc ) const override EL_NO_EXCEPT; // Diagonal manipulation // ===================== bool DiagonalAlignedWith ( const El::DistData& d, Int offset=0 ) const override EL_NO_EXCEPT; bool DiagonalAlignedWith ( const El::ElementalData& d, Int offset=0 ) const EL_NO_EXCEPT; int DiagonalRoot( Int offset=0 ) const override EL_NO_EXCEPT; int DiagonalAlign( Int offset=0 ) const override EL_NO_EXCEPT; protected: // Protected constructors // ====================== // Create a 0 x 0 distributed matrix ElementalMatrix( const El::Grid& g=DefaultGrid(), int root=0 ); private: // Exchange metadata with another matrix // ===================================== void ShallowSwap( type& A ); template<typename S,Dist J,Dist K,DistWrap wrap> friend class DistMatrix; }; template<typename T> void AssertConforming1x2 ( const ElementalMatrix<T>& AL, const ElementalMatrix<T>& AR ); template<typename T> void AssertConforming2x1
( const El::BlockCyclicData& d, Int offset=0 ) const; int DiagonalRoot( Int offset=0 ) const; int DiagonalAlign( Int offset=0 ) const; protected: // Member variables // ================ // Process grid and distribution metadata // -------------------------------------- Int blockHeight_, blockWidth_; Int colCut_, rowCut_; // Private constructors // ==================== BlockCyclicMatrix( const El::Grid& g=DefaultGrid(), int root=0 ); BlockCyclicMatrix ( const El::Grid& g, Int blockHeight, Int blockWidth, int root=0 ); private: Int NewLocalHeight( Int height ) const; Int NewLocalWidth( Int width ) const; Int NewLocalHeight_( Int height ) const EL_NO_EXCEPT; Int NewLocalWidth_( Int width ) const EL_NO_EXCEPT; // Exchange metadata with another matrix // ===================================== void ShallowSwap( type& A ); template<typename S,Dist J,Dist K,DistWrap wrap> friend class DistMatrix;
DistMatrix<T,MD,STAR>* ConstructDiagonal ( const El::Grid& g=DefaultGrid(), Int root=0 ) const override;
DistMatrix<T,MR,MC>* ConstructTranspose ( const El::Grid& g=DefaultGrid(), Int root=0 ) const override;
DistMatrix<T,MC,MR>* Construct ( const El::Grid& g=DefaultGrid(), Int root=0 ) const override;
{ public: // Typedefs // ======== typedef AbstractBlockDistMatrix<T> absType; typedef GeneralBlockDistMatrix<T,MC,MR> genType; typedef BlockDistMatrix<T,MC,MR> type; // Constructors and destructors // ============================ // Inherited constructors are part of C++11 but not yet widely supported. //using GeneralBlockDistMatrix<T,MC,MR>::GeneralBlockDistMatrix; // Create a 0 x 0 distributed matrix with default (and unpinned) block size BlockDistMatrix( const elem::Grid& g=DefaultGrid(), Int root=0 ); // Create a 0 x 0 distributed matrix with fixed block size BlockDistMatrix ( const elem::Grid& g, Int blockHeight, Int blockWidth, Int root=0 ); // Create a height x width distributed matrix with default block size BlockDistMatrix ( Int height, Int width, const elem::Grid& g=DefaultGrid(), Int root=0 ); // Create a height x width distributed matrix with fixed block size BlockDistMatrix ( Int height, Int width, const elem::Grid& g, Int blockHeight, Int blockWidth, Int root=0 ); // Create a copy of distributed matrix A (redistributing if necessary) BlockDistMatrix( const type& A ); template<Dist U,Dist V> BlockDistMatrix( const BlockDistMatrix<T,U,V>& A ); template<Dist U,Dist V> BlockDistMatrix( const DistMatrix<T,U,V>& A ); // Move constructor
BlockDistMatrix<T,VC,STAR>* Construct ( const El::Grid& g=DefaultGrid(), Int root=0 ) const override;
BlockDistMatrix<T,STAR,VR>* ConstructTranspose ( const El::Grid& g=DefaultGrid(), Int root=0 ) const override;