On Thu, May 17, 2012 at 12:06 PM, Christian Staudt < christian.staudt at ira.uka.de> wrote:
> Hello petsc4py users, > > I need some advice on petsc4py and how it can coexist with other > approaches to get high performance with Python. Here's the situation: > > - I am working on a reimplementation of a graph laplacian solver that uses > a multigrid approach. [1] > - The original sequential implementation is in MATLAB, so Python was a > natural choice because it makes it easy to translate concepts from MATLAB. > The project is not small and translating everything to C++ would have been > difficult and tedious. Numpy/Scipy also provide many equivalents for > built-in MATLAB functions. > - Unlike the original implementation, the new version should be > parallelized. Here, PETSc (via petsc4py) should provide the parallel data > structures and some operations. > - There are probably functions for which pure Python does not deliver the > necessary speed (and PETSc probably does not provide the operations > needed). I am researching how to rewrite such performance-critical parts in > C/C++, and embed them in the Python code - using methods like scipy.weave > or ctypes. [2] > - My question: Is it possible to share PETSc objects between the Python > code and the embedded C/C++ code? For example, pass a PETSc.Mat via Python, > operate on it with C/C++ and return the matrix to Python? > Yes, PETSc is just C code, so this works the same way. Matt > In general: Do you think my approach makes sense? I am new to PETSc and > have not done high performance Python before, so I hope to learn from your > answers, hints and criticism. > > Chris > > > [1] https://code.google.com/p/lamg/ > [2] > http://www.scipy.org/PerformancePython#head-cafc55bbf8fd74071b2c2ebcfb6f24ed1989d540 -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120517/f1ef94bf/attachment.htm>
