patch for seqdense
S V N Vishwanathan
vishy at mail.rsise.anu.edu.au
Sun Aug 28 17:45:04 CDT 2005
Hi!
>> I sent through a patch to implement MatMatMult* for seqdense matrices.
Hong> Where is this patch? through bk or an attached file? I don't see
Hong> MatMatMult_seqdense from
Hong> petsc-dev.
Hong> Also, do you have testing code for it? I can test it
Hong> once I see the MatMatMult_seqdense.
I think Simon forgot to add the patch file. Here is it attached
again. Please let me know if it applies cleanly.
We do not have bk but can consider licensing it if PETSc is committed to
using it in the near future and we can get write access to the source
code. But, we would much rather prefer to use an open source SCM tool.
vishy
-------------- next part --------------
diff -ur petsc-bk/src/mat/impls/dense/mpi/makefile petsc-dev/src/mat/impls/dense/mpi/makefile
--- petsc-bk/src/mat/impls/dense/mpi/makefile 2005-08-17 10:34:32.000000000 +1000
+++ petsc-dev/src/mat/impls/dense/mpi/makefile 2005-08-17 10:38:12.000000000 +1000
@@ -9,7 +9,7 @@
OBJSC = mpidense.o mmdense.o
OBJSF =
LIBBASE = libpetscmat
-DIRS =
+DIRS = plapack
MANSEC = Mat
LOCDIR = src/mat/impls/dense/mpi/
diff -ur petsc-bk/src/mat/impls/dense/seq/dense.c petsc-dev/src/mat/impls/dense/seq/dense.c
--- petsc-bk/src/mat/impls/dense/seq/dense.c 2005-08-16 14:41:57.000000000 +1000
+++ petsc-dev/src/mat/impls/dense/seq/dense.c 2005-08-17 13:18:12.000000000 +1000
@@ -1319,7 +1319,7 @@
Mat_SeqDense *mat = (Mat_SeqDense*)A->data;
PetscFunctionBegin;
- if (mat->lda != A->m) SETERRQ(PETSC_ERR_SUP,"Cannot get array for Denses matrices with LDA different from number of rows");
+ if (mat->lda != A->m) SETERRQ(PETSC_ERR_SUP,"Cannot get array for Dense matrices with LDA different from number of rows");
*array = mat->v;
PetscFunctionReturn(0);
}
@@ -1476,6 +1476,94 @@
PetscFunctionReturn(0);
}
+/* ----------------------------------------------------------------*/
+
+#undef __FUNCT__
+#define __FUNCT__ "MatMatMult_SeqDense_SeqDense"
+PetscErrorCode MatMatMult_SeqDense_SeqDense(Mat A,Mat B,MatReuse scall,PetscReal fill,Mat *C)
+{
+ PetscErrorCode ierr;
+
+ PetscFunctionBegin;
+ if (scall == MAT_INITIAL_MATRIX){
+ ierr = MatMatMultSymbolic_SeqDense_SeqDense(A,B,fill,C);CHKERRQ(ierr);
+ }
+ ierr = MatMatMultNumeric_SeqDense_SeqDense(A,B,*C);CHKERRQ(ierr);
+ PetscFunctionReturn(0);
+}
+
+
+#undef __FUNCT__
+#define __FUNCT__ "MatMatMultSymbolic_SeqDense_SeqDense"
+PetscErrorCode MatMatMultSymbolic_SeqDense_SeqDense(Mat A,Mat B,PetscReal fill,Mat *C)
+{
+ PetscFunctionBegin;
+ PetscFunctionReturn(PETSC_ERR_SUP);
+}
+
+
+#undef __FUNCT__
+#define __FUNCT__ "MatMatMultNumeric_SeqDense_SeqDense"
+PetscErrorCode MatMatMultNumeric_SeqDense_SeqDense(Mat A,Mat B,Mat C)
+{
+ Mat_SeqDense *a = (Mat_SeqDense*)A->data;
+ Mat_SeqDense *b = (Mat_SeqDense*)B->data;
+ Mat_SeqDense *c = (Mat_SeqDense*)C->data;
+ PetscBLASInt m = (PetscBLASInt)A->m, n = (PetscBLASInt)B->n, k = (PetscBLASInt)A->n;
+ PetscScalar _DOne=1.0,_DZero=0.0;
+ /* PetscErrorCode ierr; */
+
+ PetscFunctionBegin;
+
+ BLASgemm_("N","N",&m,&n,&k,&_DOne,a->v,&a->lda,b->v,&b->lda,&_DZero,c->v,&c->lda);
+
+ PetscFunctionReturn(0);
+}
+
+
+#undef __FUNCT__
+#define __FUNCT__ "MatMatMultTranspose_SeqDense_SeqDense"
+PetscErrorCode MatMatMultTranspose_SeqDense_SeqDense(Mat A,Mat B,MatReuse scall,PetscReal fill,Mat *C)
+{
+ PetscErrorCode ierr;
+
+ PetscFunctionBegin;
+ if (scall == MAT_INITIAL_MATRIX){
+ ierr = MatMatMultTransposeSymbolic_SeqDense_SeqDense(A,B,fill,C);CHKERRQ(ierr);
+ }
+ ierr = MatMatMultTransposeNumeric_SeqDense_SeqDense(A,B,*C);CHKERRQ(ierr);
+ PetscFunctionReturn(0);
+}
+
+
+#undef __FUNCT__
+#define __FUNCT__ "MatMatMultTransposeSymbolic_SeqDense_SeqDense"
+PetscErrorCode MatMatMultTransposeSymbolic_SeqDense_SeqDense(Mat A,Mat B,PetscReal fill,Mat *C)
+{
+ PetscFunctionBegin;
+ PetscFunctionReturn(PETSC_ERR_SUP);
+}
+
+
+#undef __FUNCT__
+#define __FUNCT__ "MatMatMultTransposeNumeric_SeqDense_SeqDense"
+PetscErrorCode MatMatMultTransposeNumeric_SeqDense_SeqDense(Mat A,Mat B,Mat C)
+{
+ Mat_SeqDense *a = (Mat_SeqDense*)A->data;
+ Mat_SeqDense *b = (Mat_SeqDense*)B->data;
+ Mat_SeqDense *c = (Mat_SeqDense*)C->data;
+ PetscBLASInt m = (PetscBLASInt)A->n, n = (PetscBLASInt)B->n, k = (PetscBLASInt)A->m;
+ PetscScalar _DOne=1.0,_DZero=0.0;
+ /* PetscErrorCode ierr; */
+
+ PetscFunctionBegin;
+
+ BLASgemm_("T","N",&m,&n,&k,&_DOne,a->v,&a->lda,b->v,&b->lda,&_DZero,c->v,&c->lda);
+
+ PetscFunctionReturn(0);
+}
+
+
/* -------------------------------------------------------------------*/
static struct _MatOps MatOps_Values = {MatSetValues_SeqDense,
MatGetRow_SeqDense,
@@ -1566,16 +1654,16 @@
0,
0,
0,
- 0,
-/*90*/ 0,
- 0,
0,
+/*90*/ MatMatMult_SeqDense_SeqDense,
+ MatMatMultSymbolic_SeqDense_SeqDense,
+ MatMatMultNumeric_SeqDense_SeqDense,
0,
0,
/*95*/ 0,
- 0,
- 0,
- 0,
+ MatMatMultTranspose_SeqDense_SeqDense,
+ MatMatMultTransposeSymbolic_SeqDense_SeqDense,
+ MatMatMultTransposeNumeric_SeqDense_SeqDense,
0,
/*100*/0,
0,
diff -ur petsc-bk/src/mat/impls/dense/seq/dense.h petsc-dev/src/mat/impls/dense/seq/dense.h
--- petsc-bk/src/mat/impls/dense/seq/dense.h 2005-07-11 12:46:24.000000000 +1000
+++ petsc-dev/src/mat/impls/dense/seq/dense.h 2005-08-17 11:21:09.000000000 +1000
@@ -23,5 +23,11 @@
EXTERN PetscErrorCode MatMultAdd_SeqDense(Mat A,Vec,Vec,Vec);
EXTERN PetscErrorCode MatMultTranspose_SeqDense(Mat A,Vec,Vec);
EXTERN PetscErrorCode MatMultTransposeAdd_SeqDense(Mat A,Vec,Vec,Vec);
+EXTERN PetscErrorCode MatMatMult_SeqDense_SeqDense(Mat,Mat,MatReuse,PetscReal,Mat*);
+EXTERN PetscErrorCode MatMatMultSymbolic_SeqDense_SeqDense(Mat,Mat,PetscReal,Mat*);
+EXTERN PetscErrorCode MatMatMultNumeric_SeqDense_SeqDense(Mat,Mat,Mat);
+EXTERN PetscErrorCode MatMatMultTranspose_SeqDense_SeqDense(Mat,Mat,MatReuse,PetscReal,Mat*);
+EXTERN PetscErrorCode MatMatMultTransposeSymbolic_SeqDense_SeqDense(Mat,Mat,PetscReal,Mat*);
+EXTERN PetscErrorCode MatMatMultTransposeNumeric_SeqDense_SeqDense(Mat,Mat,Mat);
#endif
-------------- next part --------------
-----
But the possibility of abuse may be a good reason for leaving
capabilities out of other computer languages, it's not a good reason for
leaving capabilities out of Perl.
-- Larry Wall in <199709251614.JAA15718 at wall.org>
More information about the petsc-dev
mailing list