[petsc-users] loosing preallocation information
Alexander Grayver
agrayver at gfz-potsdam.de
Tue Mar 8 02:16:52 CST 2011
Hello Barry,
I'm absolutely sure that I passed PETSC_NULL and #include
"finclude/petscsys.h" is defined in the beginning of my subroutine. This
line
write(*,*) PETSC_NULL, " ", sizeof(PETSC_NULL)
gives me
0 4
I also was surprised this macro didn't work properly, but I thought it
was my misunderstanding of PETSc code.
I use IFC 11.1 and ICC 11.1 as compilers under 64x linux.
My configline is:
./configure --with-petsc-arch=openmpi-intel-complex-debug
--with-mpi-dir=/opt/mpi/intel/openmpi-1.4.2 --with-scalar-type=complex
--with-blas-lapack-dir=/opt/intel/Compiler/11.1/072/mkl/lib/em64t
--with-precision=double --with-x=0
If you need any information let me know.
On 07.03.2011 23:58, Barry Smith wrote:
> On Mar 7, 2011, at 9:48 AM, Ethan Coon wrote:
>
>> On Mon, 2011-03-07 at 15:41 +0100, Alexander Grayver wrote:
>>> It works! Great, Matt.
>>>
>>> I guess there is no other way to know all these small issues but to
>>> get all possible errors? :)
> This should not have happened. Here is
>
> void PETSC_STDCALL matcreateseqaij_(MPI_Comm *comm,PetscInt *m,PetscInt *n,PetscInt *nz,
> PetscInt *nnz,Mat *newmat,PetscErrorCode *ierr)
> {
> CHKFORTRANNULLINTEGER(nnz);
> *ierr = MatCreateSeqAIJ(MPI_Comm_f2c(*(MPI_Fint *)&*comm),*m,*n,*nz,nnz,newmat);
> }
>
> and here is
>
> #define CHKFORTRANNULLINTEGER(a) \
> if (FORTRANNULL(a) || FORTRANNULLDOUBLE(a) || FORTRANNULLSCALAR(a) || FORTRANNULLREAL(a) || FORTRANNULLOBJECT(a) || FORTRANNULLFUNCTION(a)) { \
> PetscError(PETSC_COMM_SELF,__LINE__,"fortran_interface_unknown_file",__FILE__,__SDIR__,PETSC_ERR_ARG_WRONG,PETSC_ERROR_INITIAL, \
> "Use PETSC_NULL_INTEGER"); *ierr = 1; return; } \
> else if (FORTRANNULLINTEGER(a)) { a = PETSC_NULL; }
>
> If you passed in PETSC_NULL instead of PETSC_NULL_INTEGER it should have printed a (slightly helpful) error message right at this point, it should not have gotten to that place later in the code where it stopped.
>
> Are you sure you passed in PETSC_NULL? And did you include petsc.h or petscsys.h to make sure that PETSC_NULL was defined or did you pass 0 in for nnz?
>
> I'd like to know so we can fix any PETSc bug there might be there.
>
>
>
> Barry
>
>
>> PETSc in Fortran has a lot of oddities due to the difference between the
>> languages (this "null pointer" thing and different ways of looking at
>> array bounds being the primary two). If you haven't seen it yet, you
>> should really look through Chapter 10 of the manual
>>
>> http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manual.pdf
>>
>> which explains most of them. Trust me when I say it will save you a lot
>> of frustrated time (speaking as someone who learned it the hard way!)
>>
>> Ethan
>>
>>> Jed, Matt, thank you a lot!
>>>
>>> On 07.03.2011 15:35, Matthew Knepley wrote:
>>>> On Mon, Mar 7, 2011 at 8:04 AM, Alexander Grayver
>>>> <agrayver at gfz-potsdam.de> wrote:
>>>> Jed, but why do I get in line 3003 in
>>>> src/mat/impls/aij/seq/aij.c at all? As far as understand, if
>>>> I don't pass nnz (NULL in C/C++ or PETSC_NULL in fortran) I
>>>> have to avoid this loop in aij.c code.
>>>>
>>>>
>>>>
>>>> This is the problem. Fortran does not allow this kind of flexible
>>>> checking, so there are different kinds of "NULL"s. You
>>>> need to pass PETSC_NULL_INTEGER for nnz.
>>>>
>>>>
>>>> Matt
>>>>
>>>> I don't have much experience with valgrind. Could you
>>>> provide me with right parameters to run my code under
>>>> valgrind?
>>>> Thanks a lot for your help.
>>>>
>>>>
>>>> On 07.03.2011 14:59, Jed Brown wrote:
>>>>> Looks like a memory error. Best bet is to run in Valgrind.
>>>>>
>>>>>> On Mar 7, 2011 5:52 AM, "Alexander Grayver"
>>>>>> <agrayver at gfz-potsdam.de> wrote:
>>>>>>
>>>>>> Hi Jed,
>>>>>>
>>>>>> It's getting even stranger.
>>>>>>
>>>>>> When I run this code under linux I've got error:
>>>>>>
>>>>>> [0]PETSC ERROR: --------------------- Error Message
>>>>>> ------------------------------------
>>>>>> [0]PETSC ERROR: Argument out of range!
>>>>>> [0]PETSC ERROR: nnz cannot be greater than row length:
>>>>>> local row 98 value 1455203639 rowlength 343!
>>>>>> [0]PETSC ERROR:
>>>>>> ------------------------------------------------------------------------
>>>>>> [0]PETSC ERROR: Petsc Release Version 3.1.0, Patch 7,
>>>>>> Mon Dec 20 14:26:37 CST 2010
>>>>>> [0]PETSC ERROR: See docs/changes/index.html for recent
>>>>>> updates.
>>>>>> [0]PETSC ERROR: See docs/faq.html for hints about
>>>>>> trouble shooting.
>>>>>> [0]PETSC ERROR: See docs/index.html for manual pages.
>>>>>> [0]PETSC ERROR:
>>>>>> ------------------------------------------------------------------------
>>>>>> [0]PETSC
>>>>>> ERROR: /home/mt/agrayver/mt-soft/multiem/INV3D/_tiger/em_model on a openmpi-i named glic by agrayver Mon Mar 7 14:49:43 2011
>>>>>> [0]PETSC ERROR: Libraries linked
>>>>>> from /panfs/panfs.gfz-hpcc.cluster/home/mt/agrayver/lib/petsc-3.1-p7/openmpi-intel-complex-debug/lib
>>>>>> [0]PETSC ERROR: Configure run at Fri Mar 4 12:43:58
>>>>>> 2011
>>>>>> [0]PETSC ERROR: Configure options
>>>>>> --with-petsc-arch=openmpi-intel-complex-debug
>>>>>> --with-mpi-dir=/opt/mpi/intel/openmpi-1.4.2
>>>>>> --with-scalar-type=complex
>>>>>> --with-blas-lapack-dir=/opt/intel/Compiler/11.1/072/mkl/lib/em64t --with-precision=double --with-x=0
>>>>>> [0]PETSC ERROR:
>>>>>> ------------------------------------------------------------------------
>>>>>> [0]PETSC ERROR: MatSeqAIJSetPreallocation_SeqAIJ() line
>>>>>> 3003 in src/mat/impls/aij/seq/aij.c
>>>>>> [0]PETSC ERROR: MatCreateSeqAIJ() line 2906 in
>>>>>> src/mat/impls/aij/seq/aij.c
>>>>>>
>>>>>>
>>>>>> Then I traced it under debugger both on Windows and
>>>>>> Linux and realized that it doesn't crash under Windows
>>>>>> only by luck.
>>>>>>
>>>>>> The call stack if the folowing:
>>>>>> [C] MatSeqAIJSetPreallocation_SeqAIJ, FP=7fffb4513880
>>>>>> [C] MatCreateSeqAIJ, FP=7fffb4513900
>>>>>> [C] matcreateseqaij_, FP=7fffb4513960
>>>>>> [F90] MODELING_MOD`modeling, FP=7fffb4517740
>>>>>>
>>>>>> As far as I understand after debugging the problem is
>>>>>> that nnz in MatSeqAIJSetPreallocation isn't 0 and I go
>>>>>> through this code:
>>>>>> if (nnz) {
>>>>>> for (i=0; i<B->rmap->n; i++) {
>>>>>> if (nnz[i]< 0)
>>>>>> SETERRQ2(PETSC_ERR_ARG_OUTOFRANGE,"nnz cannot be less
>>>>>> than 0: local row %d value %d",i,nnz[i]);
>>>>>> if (nnz[i]> B->cmap->n)
>>>>>> SETERRQ3(PETSC_ERR_ARG_OUTOFRANGE,"nnz cannot be greater
>>>>>> than row length: local row %d value %d rowlength %
>>>>>> d",i,nnz[i],B->cmap->n);
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> But why is nnz nonzero? I passed PETSC_NULL. It seems
>>>>>> like macros CHKFORTRANNULLINTEGER in matcreateseqaij_
>>>>>> should set it to zero, but it doesn't.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> On 06.03.2011 16:49, Jed Brown wrote:
>>>>>>
>>>>>>
>>>>>>> On Sun, Mar 6, 2011 at 07:39, Alexander Grayver
>>>>>> <agrayver at gfz-potsdam.de> wrote:
>>>>>>>> Hello,
>>>>>>> ...
>>>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> What most experimenters take for granted before they begin their
>>>> experiments is infinitely more interesting than any results to which
>>>> their experiments lead.
>>>> -- Norbert Wiener
>> --
>> ------------------------------------
>> Ethan Coon
>> Post-Doctoral Researcher
>> Applied Mathematics - T-5
>> Los Alamos National Laboratory
>> 505-665-8289
>>
>> http://www.ldeo.columbia.edu/~ecoon/
>> ------------------------------------
>>
More information about the petsc-users
mailing list