General matrix interative solver

Satish Balay balay at mcs.anl.gov
Thu Oct 12 18:45:46 CDT 2006


On Thu, 12 Oct 2006, Julian wrote:

> I am now using MatCreateSeqSBAIJ() - I am assuming the second
> parameter bs=1 in my case because I am using one processor. Is that
> correct ?

No - it refers to a blocksize. The matrix could have a block
structure.  In this case - the correct blocksize can be specified. The
matrix operations will exploit this block structure for better
performance.

bs=1 is a fine [This is the equivalent of AIJ type in the block
notation]

> The method of creating a matrix I used was taken from Pavel Solin's
> book 'Partial Differential Equations and the finite Element
> Method'. Is there any particular reason why is should follow this
> method:
> mat = (double*)malloc(sizeof(Mat))
> MatCreateSeqSBAIJ(PETSC_COMM_SELF, 1, L, L, PETSC_DEFAULT, nnz, (Mat*)mat);
> In the examples that I have seen in the petsc website I don't see
> this statement where memory is allocated.

No - you should just use PETSc example codes a guidelines. i.e

   Mat mat;
   MatCreateSeqSBAIJ(PETSC_COMM_SELF, 1, L, L, PETSC_DEFAULT, nnz, &mat);

Mat is just a pointer - and all the memory allocation required is done
inside XXXCreate() routines.

> Anyway, I changed my code to the following:
> 	PetscInitialize(0,0,"petscOptions.txt",0);
> 
> 	int i;
> 	int *nnz;
> 	nnz=new int[L];
> 	for(i=0;i<L;i++){
> 		nnz[i]=row[i].getNum();
> 	}
> 
> 	Assert( mat = (double*)malloc(sizeof(Mat)) );
> 	MatCreateSeqSBAIJ(PETSC_COMM_SELF, 1, L, L, PETSC_DEFAULT, nnz, (Mat*)mat);
> 	delete [] nnz;

> And I'm still getting stuck at the same place... There is a
> difference though.. Now the assembly process is even slower than
> before (when there was no preallocation) I noticed that it is
> getting stuck around the 200th MAT_FLUSH_ASSEMBLY call.. I don't
> know if that is significant.Is there some limit on how many times
> MAT_FLUSH_ASSEMBLY can be called ?

MAT_FLUSH_ASSEMBLY is cheap - in sequential mode - but expensive in parallel
mode [becasue of parallel syncronization]. However ...

> This is the petsc output I get:
> [0] PetscInitializePETSc successfully started: number of processors = 1
> [0] PetscGetHostNameRejecting domainname, likely is NIS ALPHA2.ÿÿ0ÿÿ
> [0] PetscInitializeRunning on machine: ALPHA2
> [0] PetscCommDuplicateDuplicating a communicator 1 1 max tags = 100000000 

The above log is incomplete. You should be looking for lines with the string 'malloc'

Satish

> 
> I also tried this :
> 	mat = new Mat;
> 	MatCreateSeqSBAIJ(PETSC_COMM_SELF, 1, L, L, PETSC_DEFAULT, nnz, mat);
> 
> And got the same performance.


More information about the petsc-users mailing list