[petsc-users] proper Fortran usage for PetscMemoryGetMaximumUsage
Anthony Haas
aph at email.arizona.edu
Fri Jul 3 13:35:37 CDT 2015
Hi Barry,
I tried what you suggested. When I use the flag -memory_info,
PetscMemoryGetMaximumUsage returns a nonzero value. If I do not use
-memory_info, PetscMemoryGetMaximumUsage returns a zero value on all
processes. Regarding PetscMemoryGetCurrentUsage, it returns a nonzero
value with or without the -memory_info flag. As for the debugger, I set
a breakpoint at the function location (break
PetscMemoryGetMaximumUsage), then use run. When the program reaches the
breakpoint, I use step and then print to examine mem (see below).
Thanks,
Anthony
PetscMemoryGetMaximumUsage (mem=0x7fffffffcca0)
at /home/anthony/LIB/petsc-3.6.0/src/sys/memory/mem.c:153
153 if (!PetscMemoryCollectMaximumUsage)
SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"To use this function
you must first call PetscMemorySetGetMaximumUsage()");
(gdb)
154 *mem = PetscMemoryMaximumUsage;
(gdb) print *mem
$1 = 6.9533558072018098e-310
(gdb) step
155 PetscFunctionReturn(0);
(gdb)
156 }
(gdb)
petscmemorygetmaximumusage_ (mem=0x7fffffffcca0, __ierr=0x7fffffffcd74)
at /home/anthony/LIB/petsc-3.6.0/src/sys/memory/ftn-auto/memf.c:52
52 }
(gdb)
petsc::setupsolvegevp (nx=25, ny=25, nxy=625, alpha=0,
beta=3.1415926535897931, re=1000) at module_petsc.F90:367
367 call MPI_Barrier(MPI_COMM_WORLD,ierr);CHKERRQ(ierr)
(gdb) print mem
$2 = 0
On 07/02/2015 06:10 PM, Barry Smith wrote:
>> On Jul 2, 2015, at 7:03 PM, Anthony Paul Haas <aph at email.arizona.edu> wrote:
>>
>> Hi Barry,
>>
>> Here it is. Note that the options -memory_info and -malloc_log provide proper data but I wanted to monitor some operations more closely.
> That's odd, they all use the same mechanism.
>
> Run on one processor in the debugger use the PETSc command line option -start_in_debugger noxterm
>
> then put a breakpoint in PetscMemoryGetMaximumUsage and see what the values are when it gets there.
>
> Also run the same code with the option -memory_info maybe the PetscMemorySetGetMaximumUsage() isn't working, though it should,
>
> Barry
>
>> Thanks,
>>
>> Anthony
>>
>> On Thu, Jul 2, 2015 at 4:49 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>>
>> It is PetscLogDouble which is an alias for real*8.
>>
>> Only certain systems give easy access to the memory usage. Send the file $PETSC_ARCH/include/petscconf.h and I'll check if yours is suppose to be able to.
>>
>> Barry
>>
>>
>>> On Jul 2, 2015, at 4:51 PM, Anthony Paul Haas <aph at email.arizona.edu> wrote:
>>>
>>> Hi,
>>>
>>> Could you please tell me what is the proper Fortran usage for PetscMemoryGetMaximumUsage? Do I need to define mem (see below) as PetscInt or PetscLogDouble? I tried both and in both case I got zero memory for all the processes.
>>>
>>> I did:
>>>
>>> 1st try: PetscLogDouble mem
>>> 2nd try: PetscInt mem
>>>
>>> call SlepcInitialize(PETSC_NULL_CHARACTER,ierr)
>>>
>>> call MPI_COMM_SIZE(MPI_COMM_WORLD,size,ierr)
>>> call MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr)
>>>
>>> call PetscMemorySetGetMaximumUsage(ierr)
>>>
>>>
>>> .... some code with allocate, MatCreate, MatsetValues,...
>>>
>>> call PetscMemoryGetMaximumUsage(mem,ierr)
>>>
>>> write(*,*)'On Processor',rank,'memory:',mem
>>>
>>>
>>> Thanks,
>>>
>>> Anthony
>>
>> <petscconf.h>
More information about the petsc-users
mailing list