Jose,
Start by making PetscSplitReduction an opaque pointer to the actual struct.
For example
typedef struct _n_PetscSplitReduction *PetscSplitReduction;
goes in the public include include/petscsys.h
typedef struct {
- MPI_Comm comm;
- MPI_Request request;
- PetscBool async;
- PetscScalar *lvalues; /* this are the reduced values before call to
MPI_Allreduce() */
- PetscScalar *gvalues; /* values after call to MPI_Allreduce() */
- void **invecs; /* for debugging only, vector/memory used with
each op */
- PetscInt *reducetype; /* is particular value to be summed or maxed? */
- SRState state; /* are we calling xxxBegin() or xxxEnd()? */
- PetscInt maxops; /* total amount of space we have for requests */
- PetscInt numopsbegin; /* number of requests that have been queued in */
- PetscInt numopsend; /* number of requests that have been gotten by
user */
-} _n_PetscSplitReduction;
goes in the private include include/petsc-private/petscimpl.h
Then you need to decide how to access the material inside the struct.
1) Do you want all PETSc users to be able to access stuff in the struct and
modify it or
2) Do you want a few places in SLEPc to take advantage of the
PetscSplitReduction abilities?
I am guessing you want 2) in that case just have your SLEPc code include the
petscimpl.h and access the structure directly. This is what we do in, for
example VecDotBegin() etc
If you want 1) then you have a lot of work ahead of you because you need to
abstract all the operations you want to do on PetscSplitReduction and provide
methods to do those operations and then call those operations from SLEPc.
Basically your “Jed sin” (which is far worse than a cardinal sin) was putting
this private data structure directly in the public interface of PETSc, i.e. in
petscsys.h
Barry
On Sep 10, 2014, at 8:43 AM, Jose E. Roman <[email protected]> wrote:
>
> El 09/07/2014, a las 23:39, Jed Brown escribió:
>
>> Satish Balay <[email protected]> writes:
>>
>>> merged to maint now.
>>
>> Satish, we can't have this non-namespaced stuff in 'maint' (it really
>> can break user code). The struct definition should really be private
>> (so if Jose needs to access fields, we need to write interface
>> functions).
>>
>> I'm sorry about my radio silence on this issue. The travel has been
>> more disruptive than usual for having time to write code.
>
>
> This is still not done. Please tell me how you would like to have it done and
> I will do it.
>
> My request was to make PetscSplitReductionGet, PetscSplitReductionEnd,
> PetscSplitReductionExtend public.
>
> My initial commit was: https://bitbucket.org/petsc/petsc/commits/e8058a0
> (branch jose/split-reduction).
>
> Thanks.
> Jose
>
>
>