[petsc-dev] differencies between MatTransposeMatMult and MatMatTransposeMult

Stefano Zampini stefano.zampini at gmail.com
Tue Apr 4 04:00:44 CDT 2017


>From the current master, in MatMatTransposeMult we have

  fA = A->ops->mattransposemult;
  if (!fA)
SETERRQ1(PetscObjectComm((PetscObject)A),PETSC_ERR_SUP,"MatMatTransposeMult
not supported for A of type %s",((PetscObject)A)->type_name);
  fB = B->ops->mattransposemult;
  if (!fB)
SETERRQ1(PetscObjectComm((PetscObject)A),PETSC_ERR_SUP,"MatMatTransposeMult
not supported for B of type %s",((PetscObject)B)->type_name);
  if (fB!=fA)
SETERRQ2(PetscObjectComm((PetscObject)A),PETSC_ERR_ARG_INCOMP,"MatMatTransposeMult
requires A, %s, to be compatible with B,
%s",((PetscObject)A)->type_name,((PetscObject)B)->type_name);

  ierr = PetscLogEventBegin(MAT_MatTransposeMult,A,B,0,0);CHKERRQ(ierr);
  if (scall == MAT_INITIAL_MATRIX) {
    ierr =
PetscLogEventBegin(MAT_MatTransposeMultSymbolic,A,B,0,0);CHKERRQ(ierr);
    ierr = (*A->ops->mattransposemultsymbolic)(A,B,fill,C);CHKERRQ(ierr);
    ierr =
PetscLogEventEnd(MAT_MatTransposeMultSymbolic,A,B,0,0);CHKERRQ(ierr);
  }
  ierr =
PetscLogEventBegin(MAT_MatTransposeMultNumeric,A,B,0,0);CHKERRQ(ierr);
  ierr = (*A->ops->mattransposemultnumeric)(A,B,*C);CHKERRQ(ierr);
  ierr =
PetscLogEventEnd(MAT_MatTransposeMultNumeric,A,B,0,0);CHKERRQ(ierr);
  ierr = PetscLogEventEnd(MAT_MatTransposeMult,A,B,0,0);CHKERRQ(ierr);

Note that  neither A->ops->mattransposemult or B->ops->mattransposemult are
used.

Instead, in MatTransposeMatMult we have

  fA = A->ops->transposematmult;
  fB = B->ops->transposematmult;
  if (fB==fA) {
    if (!fA)
SETERRQ1(PetscObjectComm((PetscObject)A),PETSC_ERR_SUP,"MatTransposeMatMult
not supported for A of type %s",((PetscObject)A)->type_name);
    transposematmult = fA;
  } else {
    /* dispatch based on the type of A and B from their PetscObject's
PetscFunctionLists. */
    char multname[256];
    ierr = PetscStrcpy(multname,"MatTransposeMatMult_");CHKERRQ(ierr);
    ierr = PetscStrcat(multname,((PetscObject)A)->type_name);CHKERRQ(ierr);
    ierr = PetscStrcat(multname,"_");CHKERRQ(ierr);
    ierr = PetscStrcat(multname,((PetscObject)B)->type_name);CHKERRQ(ierr);
    ierr = PetscStrcat(multname,"_C");CHKERRQ(ierr); /* e.g., multname =
"MatMatMult_seqdense_seqaij_C" */
    ierr =
PetscObjectQueryFunction((PetscObject)B,multname,&transposematmult);CHKERRQ(ierr);
    if (!transposematmult)
SETERRQ2(PetscObjectComm((PetscObject)A),PETSC_ERR_ARG_INCOMP,"MatTransposeMatMult
requires A, %s, to be compatible with B,
%s",((PetscObject)A)->type_name,((PetscObject)B)->type_name);
  }
  ierr = PetscLogEventBegin(MAT_TransposeMatMult,A,B,0,0);CHKERRQ(ierr);
  ierr = (*transposematmult)(A,B,scall,fill,C);CHKERRQ(ierr);
  ierr = PetscLogEventEnd(MAT_TransposeMatMult,A,B,0,0);CHKERRQ(ierr);

I would be inclined to have MatMatTransposeMult to dispatch the same way
MatTransposeMatMult does. Comments?


--
Stefano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20170404/12a0de2b/attachment.html>


More information about the petsc-dev mailing list