[petsc-dev] Fwd: [petsc-users] Unexpected "Out of memory error" with SLEPC

Barry Smith bsmith at mcs.anl.gov
Thu Jun 26 15:53:21 CDT 2014


On Jun 26, 2014, at 3:42 PM, Karl Rupp <rupp at iue.tuwien.ac.at> wrote:

>> 
>>   I was thinking of catching the overflow BEFORE it hits the malloc.  For example in DMSetUp_DA_3D() we have the unattractive code
>> 
>> #if !defined(PETSC_USE_64BIT_INDICES)
>>   if (((Petsc64bitInt) M)*((Petsc64bitInt) N)*((Petsc64bitInt) P)*((Petsc64bitInt) dof) > (Petsc64bitInt) PETSC_MPI_INT_MAX) SETERRQ3(comm,PETSC_ERR_INT_OVERFLOW,"Mesh of %D by %D by %D (dof) is too large for 32 bit indices",M,N,dof);
>> #endif
>> 
>>   Maybe we could introduce some macros like
>> 
>> #if !defined(PETSC_USE_64BIT_INDICES)
>> #define  PetscCheckOverflow2(M,N) if (((Petsc64bitInt) M)*((Petsc64bitInt) N) > (Petsc64bitInt) PETSC_MPI_INT_MAX) SETERRQ3(comm,PETSC_ERR_INT_OVERFLOW,”Multiply of %D by %D bis too large for 32 bit indices",M,N;
>> #else
>> #define  PetscCheckOverflow2(a,b)
>> #endif
>> 
>> and then check large products when they are likely to occur.
> 
> That's even better in terms of the error message. There are some beasts like the following:
> 
> src/mat/impls/aij/mpi/mumps/mumps.c:
> ierr = PetscMalloc((2*nz*sizeof(PetscInt)+nz*sizeof(PetscScalar)),
>                    &row);CHKERRQ(ierr);

   This beast is outdate bad style and needs to be fixed to for example use PetscMalloc2()

> 
> which would require multiiple PetscCheckOverflowX() uses, but I consider this acceptable.
> 
> Best regards,
> Karli




More information about the petsc-dev mailing list