fixes for VecPlaceArray/VecResetArray

Lisandro Dalcin dalcinl at gmail.com
Wed Dec 3 19:51:16 CST 2008


Yes, but those VecCreateXXXWithArray() and null arrays are intended
for create stub vecs for something like creating a VecScatter(). If
PETSc creates such vector, it sould never return, or expose them to
users, they do not have allocated space.

I cannot see a use case of placing a NULL array. The vector is left in
a useless state, and the allocated memory is still there.

I believe that if one wants to clear the array, we should use
VecReplaceArray(). This a different beast.

Anyway, if this is just a difference in opinions or low-level details
I´m missing, please just backout the changeset.


On Wed, Dec 3, 2008 at 9:28 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
>   One can call VecCreateXXXWithArray() with a null pointer for the array so
> that
> means there is already an established history of valid Vecs with null
> arrays.
> I'd like you do undo the changes you made unless you have a specific reason
> for making the change (besides the reason of not having a Vec with a null
> array).
>
>   Barry
>
> On Dec 3, 2008, at 5:37 PM, Lisandro Dalcin wrote:
>
>> On Wed, Dec 3, 2008 at 8:08 PM, Matthew Knepley <knepley at gmail.com> wrote:
>>>
>>> On Wed, Dec 3, 2008 at 5:04 PM, Lisandro Dalcin <dalcinl at gmail.com>
>>> wrote:
>>>>
>>>> I've pushed some fixes for VecPlaceArray/VecResetArray, trying to the
>>>> pair a bit more smarter. However, the I'm not sure what's the use case
>>>> in VecPlaceArray for accepting NULL for the array. Just in case, I did
>>>> not changed this, but if NULL is actually pased, then the call is now
>>>> non-op. Is this fine? I'm missing something??
>>>
>>> I think you would like to reset the array back to NULL sometimes, to
>>> clear
>>> out
>>> memory of an old array it no longer owns. Is this right?
>>>
>>
>> Not sure if I understood you comment, but the companion call
>> VecResetArray() restores the original array. Before my fix, the Vec
>> was left actually pointing to a NULL.
>>
>>
>>
>>>
>>>>
>>>> --
>>>> Lisandro Dalcín
>>>> ---------------
>>>> Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
>>>> Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
>>>> Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
>>>> PTLC - Güemes 3450, (3000) Santa Fe, Argentina
>>>> Tel/Fax: +54-(0)342-451.1594
>>>
>>> --
>>> 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
>>>
>>
>>
>>
>> --
>> Lisandro Dalcín
>> ---------------
>> Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
>> Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
>> Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
>> PTLC - Güemes 3450, (3000) Santa Fe, Argentina
>> Tel/Fax: +54-(0)342-451.1594
>>
>
>



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594




More information about the petsc-dev mailing list