Bindings for more SF calls

Issue #108 resolved
Lawrence Mitchell created an issue

I'd like to add bindings for the PetscSF communication calls (PetscSFReduceBegin/End and friends).

But, there's a problem. The C signatures for these calls are all of the form:

PetscSFReduceBegin(SF sf, MPI_Datatype unit, const void* leaddata, void* rootdata, MPI_Op op);

But, this requires that any petsc4py binding references mpi4py, since I need to be able to either pass in (or create) the unit datatype, as well as the MPI_Op.

I know that right now petsc4py does not depend on mpi4py (since PETSc can be built without MPI).

What's the best way to square this circle? Hide these implementations behind a compile time cython DEF WITH_MPI4PY ?

Comments (6)

  1. Lisandro Dalcin

    I think the compile time time DEF WITH_MPI4PY will not work as you expect, DEF defines compile time constants, it cannot be used for conditional compilation. I'm afraid that the only way to go is to follow the nasty low level code we already use for communicators, look at petscmpi.pxi.

  2. Lisandro Dalcin

    So, in short, you have to implement mpi4py_{Datatype|Op}_Get, just cust&paste&replace, and cross fingers this is still working.

  3. Lisandro Dalcin

    Oh, OK, you are right. Sorry about the confusion. Still, the approach I suggested my prove better, that way mpi4py becomes a runtime dependency rather than a compile time one. And given that we already do that for Comm, why not following the pattern for Op and Datatype?

  4. Log in to comment