[petsc-dev] changed ISCreateGeneral/NC/WithArray()

Barry Smith bsmith at mcs.anl.gov
Sun Oct 3 18:13:11 CDT 2010


On Oct 3, 2010, at 6:00 PM, Lisandro Dalcin wrote:

> On 3 October 2010 19:51, Barry Smith <bsmith at mcs.anl.gov> wrote:
>> 
>>   Well it is always "with array" since you always need to provide an array of indices, so why both with the redundant "withArray" (With VecCreateSeqWithArray() there is also a VecCreateSeq() that does not take an array, hence WithArray in that case is not redundant)?
>> 
> 
> I'm just thinking on user convenience...

   You do have a valid point. Adding the extra argument  does introduce a bit more complexity for the average user who previously just saw ISCreateGeneal() and didn't even know about the NC, or WithArray(). But I think it is the correct tradeoff (the slightly higher basic complexity) because the paradigm of deep vs shallow copy is common enough that formalizing it early overall will reduce complexity.

   Barry

> 
>> 
>>   Regarding having two routines: I found having three almost identical routines unneededly complicated.
>> 
> 
> I definitely agree.
> 
>> 
>> You still want to have two routines, one is just a subset of the functionality of the second. That is redundant and hence unneeded.
>> 
> 
> If we were using C++, don't you think we could overload
> ISCreateGeneral? But we are in C, and I see that
> ISCreateGeneralWithArray() as a developer-level call, while
> ISCreateGeneral() looks more like an user-level-call.
> 
> I'm proposing making ISCreateGeneral() a wrapper for
> ISCreateGeneralWithArray(). I do not think that the redundancy is too
> much of a trouble in such cases.
> 
>>   I do appreciate your suggestions, please keep on having them even if they don't always convince me.
>> 
> 
> Well, I'm still trying to convince you :-)
> 
>> 
>>   Barry
>> 
>> On Oct 3, 2010, at 5:45 PM, Lisandro Dalcin wrote:
>> 
>>> On 3 October 2010 14:57, Barry Smith <bsmith at mcs.anl.gov> wrote:
>>>> 
>>>>   I find the three routines ISCreateGeneral(), ISCreateGeneralNC() and ISCreateGeneralWithArray() to be confusing and code redundant.
>>>> 
>>>>   Therefore in PETSc-dev I have introduced
>>>> 
>>>> /*E
>>>>    PetscCopyMode  - Determines how an array passed to certain functions is copied or retained
>>>> 
>>>>   Level: beginner
>>>> 
>>>> $   PETSC_COPY_VALUES - the array values are copied into new space, the user is free to reuse or delete the passed in array
>>>> $   PETSC_OWN_POINTER - the array values are NOT copied, the object takes ownership of the array and will free it later, the user cannot change or
>>>> $                       delete the array. The array MUST have been obtained with PetscMalloc(). Hence this mode cannot be used in Fortran.
>>>> $   PETSC_USE_POINTER - the array values are NOT copied, the object uses the array but does NOT take ownership of the array. The user cannot use
>>>>                        the array but the user must delete the array after the object is destroyed.
>>>> 
>>>> E*/
>>>> typedef enum { PETSC_COPY_VALUES, PETSC_OWN_POINTER, PETSC_USE_POINTER} PetscCopyMode;
>>>> extern const char *PetscCopyModes[];
>>>> 
>>>> and merged  ISCreateGeneral/NC/WithArray() into a single routine with an additional PetscCopyMode argument.
>>>> 
>>>> I have also merged ISLocalToGlobalMappingCreate() and ISLocalToGlobalMappingCreateNC() into a single routine.
>>>> 
>>>> There may be other places we can use this paradigm in the future, keep your eyes open,
>>>> 
>>>>  Happy computing,
>>>> 
>>>>    Barry
>>>> 
>>> 
>>> I would prefer to have:
>>> 
>>> ISCreateGeneralWithArray(comm,n,ptr,copy_mode,&is);
>>> 
>>> and then implement
>>> 
>>> ISCreateGeneral(comm,n,ptr,&is) {
>>> return ISCreateGeneralWithArray(comm,n,ptr,PETSC_COPY_VALUES,&is);
>>> }
>>> 
>>> What do you think?
>>> 
>>> --
>>> Lisandro Dalcin
>>> ---------------
>>> CIMEC (INTEC/CONICET-UNL)
>>> Predio CONICET-Santa Fe
>>> Colectora RN 168 Km 472, Paraje El Pozo
>>> Tel: +54-342-4511594 (ext 1011)
>>> Tel/Fax: +54-342-4511169
>> 
>> 
> 
> 
> 
> -- 
> Lisandro Dalcin
> ---------------
> CIMEC (INTEC/CONICET-UNL)
> Predio CONICET-Santa Fe
> Colectora RN 168 Km 472, Paraje El Pozo
> Tel: +54-342-4511594 (ext 1011)
> Tel/Fax: +54-342-4511169




More information about the petsc-dev mailing list