Date: 2016-07-24T16:57:09+00:00

Actual source code: matelemimpl.h
petsc-3.7.3 2016-07-24
Report Typos and Errors

      1: #if !defined(_matelemimpl_h)
      2: #define _matelemimpl_h

      4: #include <El.hpp>
      5: #include <petsc/private/matimpl.h>
      6: #include <petscmatelemental.h>

      8: typedef struct {
      9:   PetscInt commsize;
     10:   PetscInt m[2];       /* Number of entries in a local block of the row (column) space */
     11:   PetscInt mr[2];      /* First incomplete/ragged rank of (row) column space.
     12:                           We expose a blocked ordering to the user because that is what all other PETSc infrastructure uses.
     13:                           With the blocked ordering when the number of processes do not evenly divide the vector size,
     14:                           we still need to be able to convert from PETSc/blocked ordering to VC/VR ordering. */
     15:   El::Grid                                     *grid;
     16:   El::DistMatrix<PetscElemScalar>              *emat;
     17:   El::DistMatrix<PetscInt,El::VC,El::STAR> *pivot; /* pivot vector representing the pivot matrix P in PA = LU */
     18:   PetscBool roworiented;               /* if true, row oriented input (default) */
     19: } Mat_Elemental;

     21: typedef struct {
     22:   El::Grid *grid;
     23:   PetscInt   grid_refct;
     24: } Mat_Elemental_Grid;

     26: /*
     27:  P2RO, RO2P, E2RO and RO2E convert indices between PETSc <-> (Rank,Offset) <-> Elemental
     28:  (PETSc parallel vectors can be used with Elemental matries without changes)
     29: */
     30: PETSC_STATIC_INLINE void P2RO(Mat A,PetscInt rc,PetscInt p,PetscInt *rank,PetscInt *offset)
     31: {
     32:   Mat_Elemental *a       = (Mat_Elemental*)A->data;
     33:   PetscInt      critical = a->m[rc]*a->mr[rc];
     34:   if (p < critical) {
     35:     *rank   = p / a->m[rc];
     36:     *offset = p % a->m[rc];
     37:   } else {
     38:     *rank   = a->mr[rc] + (p - critical) / (a->m[rc] - 1);
     39:     *offset = (p - critical) % (a->m[rc] - 1);
     40:   }
     41: }
     42: PETSC_STATIC_INLINE void RO2P(Mat A,PetscInt rc,PetscInt rank,PetscInt offset,PetscInt *p)
     43: {
     44:   Mat_Elemental *a = (Mat_Elemental*)A->data;
     45:   if (rank < a->mr[rc]) {
     46:     *p = rank*a->m[rc] + offset;
     47:   } else {
     48:     *p = a->mr[rc]*a->m[rc] + (rank - a->mr[rc])*(a->m[rc]-1) + offset;
     49:   }
     50: }

     52: PETSC_STATIC_INLINE void E2RO(Mat A,PetscInt rc,PetscInt p,PetscInt *rank,PetscInt *offset)
     53: {
     54:   Mat_Elemental *a = (Mat_Elemental*)A->data;
     55:   *rank   = p % a->commsize;
     56:   *offset = p / a->commsize;
     57: }
     58: PETSC_STATIC_INLINE void RO2E(Mat A,PetscInt rc,PetscInt rank,PetscInt offset,PetscInt *e)
     59: {
     60:   Mat_Elemental *a = (Mat_Elemental*)A->data;
     61:   *e = offset * a->commsize + rank;
     62: }

     64: #endif