-malign-double

Barry Smith bsmith at mcs.anl.gov
Sat Nov 14 12:23:21 CST 2009


On Nov 14, 2009, at 11:28 AM, Jed Brown wrote:

> Barry Smith wrote:
>>
>>
>>   Good point, I have removed it.
>>
>>   I put it in because I wanted an easy way to test that PETSc double
>> arrays are always 8 byte aligned (and the unaligned struct values  
>> were
>> giving me lots of false alarms).
>
> A related issue is PetscMallocN which (in optimized mode) gives
> unaligned arrays even if malloc always returns aligned memory.   
> Consider
>
>  PetscMalloc2(3,PetscInt,&ai,3,PetscScalar,&a);

    This call is illegal. You are required to pass the longest aligned  
arrays first leading the shortest. Hence The PetscScalar should be  
before the PetscInt.

    The debug mode should check that this requirement is satisfied; it  
currently does not check anything.

    In the real world when any of these beasts can be 32 bit or 64 bit  
one cannot always put them in the right order; but for now they should  
be ordered, PetscScalar, pointer, PetscInt

    Barry

>
> I think it is preferable for PetscMallocN to align all the pointers.
>
> Jed
>




More information about the petsc-dev mailing list